From,
https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_71/db2/rbafzregexp_like.htm
SELECT PID FROM PRODUCT
WHERE NOT REGEXP_LIKE(pid,'[0-9]{3}-[0-9]{3}-[0-9]{2}')
But when I run a similar command,
SELECT MYCOLUMN FROM MYTABLE
WHERE NOT REGEXP_LIKE(MYCOLUMN,'[0-9]{3}-[0-9]{3}-[0-9]{2}')
I get
SQL State: 42601 Vendor Code: -104 Message: [SQL0104] Token
was not valid. Valid tokens: < > = <> <= !< !> !=
= ¬< ¬> ¬= IN. Cause . . . . . : A syntax error was detected at token . Token is not a valid
token. A partial list of valid tokens is < > = <> <= !< !> != >= ¬<
¬> ¬= IN. This list assumes that the statement is correct up to the
token. The error may be earlier in the statement, but the syntax of
the statement appears to be valid up to this point. Recovery . . . :
Do one or more of the following and try the request again: -- Verify
the SQL statement in the area of the token .
Correct the statement. The error could be a missing comma or
quotation mark, it could be a misspelled word, or it could be related
to the order of clauses.
-- If the error token is , correct the SQL statement because it does not end with a valid clause.
Is there any reason why this example does not work? Is IBM v7r1 not the same as 7.1?
7.1 and v7r1 are the same thing...
The regular expression support was added as part of technology refresh (TR) level 9
From a command line, use the Work with PTF Groups (WRKPTFGRP) command
WRKPTFGRP PTFGRP(SF99707) PTFGRPLVL(*INSTALLED)
Also, you need to have 5770-SS1 Option #39 International Components for Unicode insallted. You can use the Display Software Resources (DSPSFWRSC) to check for that.
If that's not installed, you'd see a message:
SQL0204 - QQQSVREG in QSYS type *SRVPGM not found.
Related
I want to run the following query in by db2:
CALL spDrpObj('DE','T') ;
CREATE TABLE QTEMP.DE
(
Ano int
);
CREATE OR REPLACE VARIABLE g int;
set g=1;
Begin
WHILE(g<=100) DO
INSERT INTO QTEMP.DE
SELECT g
SET g=g+1;
END WHILE;
But it's showing me error like:-
SQL State: 42601 Vendor Code: -104 Message: [SQL0104] Token G was not valid. Valid tokens: , FROM INTO. Cause . . . . . : A syntax error was detected at token G. Token G is not a valid token. A partial list of valid tokens is , FROM INTO. This list assumes that the statement is correct up to the token. The error may be earlier in the statement, but the syntax of the statement appears to be valid up to this point. Recovery . . . : Do one or more of the following and try the request again: -- Verify the SQL statement in the area of the token G. Correct the statement. The error could be a missing comma or quotation mark, it could be a misspelled word, or it could be related to the order of clauses. -- If the error token is , correct the SQL statement because it does not end with a valid clause.
I am using C++ Builder 10.2.3 (Rad Studio Tokyo 10.2.3) with Interbase 2017
I need to create users at runtime for my users registration.
If I create the Query at runtime, in that case there is no parameter, it works. But this creates problems with MBCS characters I will explain later.
If I create the Query at design-time with parameters and try to set the parameters at runtime. I am getting the error message below:
[Application: ]
[Error] -104 335544569 Dynamic SQL Error
SQL error code = -104
Token unknown - line 2, char 14
?
The query I am using is below:
CREATE USER myuser
SET PASSWORD :mypass,
FIRST NAME :myfirstname,
LAST NAME :myname;
I replace the first line of the Query at runtime, so there is no character. And after all, Interbase cannot handle MBCS characters in USERNAME.
I need to use a Query with parameters because my application handles multi-bytes characters (MBCS), like Chinese and Japanese. And this is the only option to be sure of a proper conversion to UTF8 in Interbase. Because if the conversion of MBCS characters is not done, I cannot backup and restore my database. When I try to restore with MBCS characters in First and last name, I am getting an error message that Interbase cannot transliterate between character sets.
Base on the error message, it appears to me that it does not recognize the Query parameters.
I tried with both "TIBQuery" and "TIBSQL". Same issue. Impossible to use also Store procedures. Does not recognize the create word.
So, how to fix that ?
I have a simple select query which is inside an openquery
SELECT
MyColumn,
RIGHT(MyColumn,2)
FROM MyTable
however this gives error
Cause . . . . . : A syntax error was detected at token ,2. Token ,2
is not a valid token. A partial list of valid tokens is ) ,.
In case someone has this issue.
RIGHT(MyColumn,2) gives token error
RIGHT(MyColumn, 2) is correct
Outcome of the actual query
SELECT * FROM OPENQUERY(linkServer, 'SELECT RIGHT(MyColumn, 2) FROM MyTable')
I am trying to call a stored procedure with Time variable as in parameter. But whenever i try to call the procedure i m getting error as:
db2 'call PASS_FAIL_CHECKDATE('2014-01-21','13:42:25','CSS1',Null,'4500096651','10',Null)'
SQL0104N An unexpected token ":42" was found following "CKDATE(2014-01-21,
13". Expected tokens may include: "+". SQLSTATE=42601
My Procedures input parameter are :
PASS_fail_checkdate (in post_date date,in post_time time,in destplant varchar(4), in destloc varchar(4), in transnum varchar(10), in translineitemnum varchar(6), in inboundconsignment varchar(35))
I am not sure if my declaration for time variable is correct in procedure or if i am calling the time variable correctly in the procedure.
Please give me suggestions on the same.
As already offered, in words, try the following example as a revision to what was noted in the OP as tried already but failing; i.e. change to use double-quote vs the apostrophe, specified as the delimiter for the DB2 SQL statement string:
db2 "call PASS_FAIL_CHECKDATE('2014-01-21','13:42:25','CSS1',Null,'4500096651','10',Null)"
<cfquery name="LOCAL.qrySelEvents" datasource="#variables.datasourceSettings.getDatasourceName()#" result="LOCAL.qryData" >
SELECT evt_id,
acnt_dba_name,
form_id,
'#application.portals.data[request.applicationName].profileRootPath#form/index.cfm'
|| CHAR(63)
|| 'PKformID= '
|| #preserveSingleQuotes(LOCAL.formIdSql)# AS primaryFormURL,
FROM events
</cfquery>
I have to concat #application.portals.data[request.applicationName].profileRootPath#form/index.cfm with char(32) and PKformID= ' || #preserveSingleQuotes(LOCAL.formIdSql)#. I have used the || operator of postgres. But it is giving me an error:
ERROR: syntax error at or near "||"
Can you please help me in this?
The last line of your select clause has a comma at the end.
OK, as well as the error message, if you have ROBUST EXCEPTION HANDLING switched on (it's in CFAdmin), you should get back the SQL that CF was passing to the server. This should show you where the syntax error is in your SQL. You should also always post this info in your question, so even if you can't see the problem, someone else might be able to.
Now I suspect it's because this:
#preserveSingleQuotes(LOCAL.formIdSql)#
needs to be treated as a string (which it is), in which case you'll need to quote it for the DB to see it as a string. IE:
'#preserveSingleQuotes(LOCAL.formIdSql)#'
Given there is no DB-centric references in that whole value:
`'#application.portals.data[request.applicationName].profileRootPath#form/index.cfm' || CHAR(63) || 'PKformID= ' || '#preserveSingleQuotes(LOCAL.formIdSql)#'`
I question why you need to include it in your SELECT query. You're basically just passing the value to the SQL server, and just getting it back again afterwards. So I suspect something is amiss here. What are you actually trying to do here?
Ya finally got the answer of this , CHAR(63) is creating problem in this as in Sql-server CHAR is a function which gives Character from ASCII and in postgresql CHR() function is available in order to give character from ASCII. So , new Query is :
<cfquery name="LOCAL.qrySelEvents" datasource="#variables.datasourceSettings.getDatasourceName()#" result="LOCAL.qryData" >
SELECT evt_id,
acnt_dba_name,
form_id,
'#application.portals.data[request.applicationName].profileRootPath#form/index.cfm'
|| CHR(63)
|| 'PKformID= '
|| #preserveSingleQuotes(LOCAL.formIdSql)# AS primaryFormURL
FROM events
</cfquery>
Thanks for all your support.