Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STRING_FORMAT built-in function [CORE1314] #1733

Open
firebird-automations opened this issue Jun 9, 2007 · 8 comments
Open

STRING_FORMAT built-in function [CORE1314] #1733

firebird-automations opened this issue Jun 9, 2007 · 8 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Alexander Tyutik (tut)

Relate to CORE832
Is duplicated by CORE1341
Is duplicated by CORE3776

Votes: 10

I propose to add function which may be very convinient when working with dynamic SQL, exceptions, ets...

--------
STRING_FORMAT
--------

Function:
STRING_FORMAT(STR BY P0[, P1,...,PN]) returns STR whis all markers replaced by parameters

Example:

IF (...) THEN
EXCEPTION ERROR STRING_FORMAT("Error during inserting into table {0}. Field {1} has incorrect value {2}" BY 'MY_TABLE', 'CULUMN1', COALESCE(NEW.COLUMN1, '<NULL>'))

Result excetion message is: Error during inserting into table MY_TABLE. Field CULUMN1 has incorrect value 12345"

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

assignee: Adriano dos Santos Fernandes [ asfernandes ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Workflow: jira [ 12288 ] => Firebird [ 14795 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

Link: This issue relate to CORE832 [ CORE832 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

Link: This issue is duplicated by CORE1341 [ CORE1341 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: Bert Herngreen (bertherngreen)

CORE1341, 'Date format when casting as varchar', is closed and marked as a duplicate of this CORE1314.

Therefore I ask my question here: What about a (non-sql-standard) extension of CAST e.g.:

CAST (START_DATE AS CHAR(8) FORMAT 'yyyymmdd')
or even:
CAST ('18-08-2010' FORMAT 'dd-mm-yyyy' AS CHAR(8) FORMAT 'yyyymmdd')

Bert

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

Link: This issue is duplicated by CORE3776 [ CORE3776 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @WarmBooter

A format function would be nice, like described in CORE1341. I dont think this issue is the same as described in 1341. A function to be able to format dates and numbers (money, etc) would be nice addition to the internal function list.

@firebird-automations
Copy link
Collaborator Author

Commented by: @mrotteveel

The syntax suggested by Bert Herngreen is almost the same as defined in the standard (SQL:2016-2 6.13 <cast specification>):

"""
<cast specification> ::=
CAST <left paren>
<cast operand> AS <cast target>
[ FORMAT <cast template> ]
<right paren>

<cast operand> ::=
<value expression>
| <implicitly typed value specification>

<cast target> ::=
<domain name>
| <data type>

<cast template> ::=
<character string literal>
"""

Where <cast template> follows the rules of Subclause 9.42, "Converting a datetime to a formatted character string" or Subclause 9.43, "Converting a formatted character string to a datetime".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants