Author |
Message
|
Sneh4nsu |
Posted: Fri Aug 11, 2017 3:10 am Post subject: ESQL Select query |
|
|
Novice
Joined: 11 Aug 2017 Posts: 12
|
Code: |
SET env.HdrCmntDel[] = PASSTHRU('SELECT COMMENT_TYPE_CD FROM Database.INVOICE.INV_COMMENT
WHERE CREATE_TS < ?
AND (LAST_UPDATE_TS IS NULL OR LAST_UPDATE_TS < ?)
AND INV_HDR_SK = ?;',
Curr,
Curr,
inv_hdr_row.INV_HDR_SK); |
Why it is throwing an exception 'ORA-00933: SQL command not properly ended'? |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Aug 11, 2017 4:16 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Why is that wrapped in [ ] ?
PASSTHRU statements aren't parsed or handled by ESQL at all. They are simpled ... passed thru to the database directly.
And since you're.getting an Oracle Error, then this shows that. Also it shows you where to look for error information.
You should use some kind of Oracle SQL testing tool to make sure your statement works in SQL, and then move it to IIB. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Aug 11, 2017 4:46 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
mqjeff wrote: |
Why is that wrapped in [ ] ?
|
I think he meant to put code tags... I fixed it that way.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Sneh4nsu |
Posted: Fri Aug 11, 2017 4:57 am Post subject: |
|
|
Novice
Joined: 11 Aug 2017 Posts: 12
|
Code: |
SELECT COMMENT_TYPE_CD FROM INVOICE.INV_COMMENT
WHERE CREATE_TS < CURRENT_TIMESTAMP
AND (LAST_UPDATE_TS IS NULL OR LAST_UPDATE_TS < CURRENT_TIMESTAMP)
AND INV_HDR_SK = 428; |
i have run this code on sql developer and its working fine. i am asking whether the select statement inside passthru is correct or not?? |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Aug 11, 2017 5:06 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Sneh4nsu wrote: |
Code: |
SELECT COMMENT_TYPE_CD FROM INVOICE.INV_COMMENT
WHERE CREATE_TS < CURRENT_TIMESTAMP
AND (LAST_UPDATE_TS IS NULL OR LAST_UPDATE_TS < CURRENT_TIMESTAMP)
AND INV_HDR_SK = 428; |
i have run this code on sql developer and its working fine. i am asking whether the select statement inside passthru is correct or not?? |
Here is the crux. In order for your passthrough statement to be what you specified above you are missing a close parenthesis that got somehow misplaced at the end of your ESQL statement ...
So your piece of code should look like
Code: |
AND INV_HDR_SK = ?;'), |
Notice your missing parenthesis before the comma...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Sneh4nsu |
Posted: Fri Aug 11, 2017 5:40 am Post subject: |
|
|
Novice
Joined: 11 Aug 2017 Posts: 12
|
Code: |
inv_hdr_row.INV_HDR_SK); |
This is basically the end of the select statement and i am supposed to close the parenthesis only after giving the values corresponding to the respective columns. |
|
Back to top |
|
 |
mgk |
Posted: Fri Aug 11, 2017 6:15 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
The point about Passthru is that you should put the same query into Passthru as you put into sql developer (or any other db tool), apart from the changing of values into parameter markers ('?'). In your case there is a difference which is the use of "Database." in the FROM clause. This should never be used in a passthru query, only in native ESQL. So remove "Database." and try again.
Kind regards, _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Aug 11, 2017 9:13 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Sneh4nsu wrote: |
Code: |
inv_hdr_row.INV_HDR_SK); |
This is basically the end of the select statement and i am supposed to close the parenthesis only after giving the values corresponding to the respective columns. |
Wouldn't your passthrough query require a values clause instead of simply putting the substituted args at the end of the select?
Like
Code: |
select xzy from abc where a=? and b=? and c=? VALUES (a,b,c); |
 _________________ MQ & Broker admin |
|
Back to top |
|
 |
Sneh4nsu |
Posted: Mon Aug 14, 2017 2:50 am Post subject: |
|
|
Novice
Joined: 11 Aug 2017 Posts: 12
|
mgk wrote: |
The point about Passthru is that you should put the same query into Passthru as you put into sql developer (or any other db tool), apart from the changing of values into parameter markers ('?'). In your case there is a difference which is the use of "Database." in the FROM clause. This should never be used in a passthru query, only in native ESQL. So remove "Database." and try again.
Kind regards, |
Thanks buddy, it worked!!  |
|
Back to top |
|
 |
|