SQL/MX 2.x Reference Manual (H06.04+)

SQL/MX Functions and Expressions
HP NonStop SQL/MX Reference Manual540440-003
9-29
Examples of CONCAT
To specify the type assignment of the parameter, use the CAST expression on the
parameter as:
CAST(?p AS CHAR(7)) || '2002'
In this example, the parameter is not truncated, and the result of the concatenation is
5 March 2002.
Examples of CONCAT
Suppose that the LOGFILE table has been created in NonStop SQL/MP as:
CREATE TABLE $sys.stats.logfile
( user_key NUMERIC (3) UNSIGNED NO DEFAULT NOT NULL
,run_date DATE DEFAULT CURRENT
,run_time TIME DEFAULT CURRENT
,user_name VARCHAR (20)
,user_info VARCHAR (80)
,PRIMARY KEY (user_key))
CATALOG $sys.stats
ORGANIZATION KEY SEQUENCED;
After the table is created, you can insert the mapping into the OBJECTS table in this
way by using MXCI:
CREATE SQLMP ALIAS sys.stats.logfile $sys.stats.logfile;
Insert information consisting of a single character string before you end an MXCI
session. Use the CONCAT function to construct and insert the value:
INSERT INTO stats.logfile
(user_key, user_info)
VALUES (001, CONCAT ('Executed at ',
CAST (CURRENT_TIMESTAMP AS CHAR(26))));
Use the concatenation operator || to construct and insert the value:
INSERT INTO stats.logfile
(user_key, user_info)
VALUES (002, 'Executed at ' ||
CAST (CURRENT_TIMESTAMP AS CHAR(26)));
This table now includes:
1 2000-01-03 12:58:32 ?
Executed at 2000-01-03 12:58:32.527117
2 2000-01-03 12:58:40 ?
Executed at 2000-01-03 12:58:40.364611