Job parameters in user defined SQL

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
chandu123
Premium Member
Premium Member
Posts: 40
Joined: Mon Sep 12, 2016 1:26 pm

Job parameters in user defined SQL

Post by chandu123 »

I am trying to run user defined SQL in ODBC stage. The query is as below:

Code: Select all

Insert into schema.Table_name 
(Column1, 
Column2) 
(Select Clm1, 
Case when #Param2#=0 Then 'Clm2' 
Else 'Test' end as Colm2
From Table2)
Note: Param2 is a job parameter

But I am seeing below error
ODBC function "SQLExecute" reported: SQLSTATE = HY000: Native Error Code = 911: Msg = [Oracle][ODBC][Ora]ORA-00911: invalid character

Any suggestion how to correct this error?
HB
chandu123
Premium Member
Premium Member
Posts: 40
Joined: Mon Sep 12, 2016 1:26 pm

Post by chandu123 »

FYI, I am seeing the generated SQL in the log and it is correct. as below:

Code: Select all

Insert into schema.Table_name (
Column1,
Column2)
(select clm1,
Case when 0=0 Then 'Clm2' 
Else 'Test' End Colm2
From Table2)
But I don't know which is the invalid character :(
HB
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Neither do we... can you post the actual, unedited SQL rather than the redacted version please?
-craig

"You can never have too many knives" -- Logan Nine Fingers
UCDI
Premium Member
Premium Member
Posts: 383
Joined: Mon Mar 21, 2016 2:00 pm

Post by UCDI »

generally you want to run the sql and develop it with access to the database in your favorite sql editor/tool, then do a simple search and replace of the variables with datastage parameters and copy that into the stage.

I have never had the sql not work in datastage when it worked in the sql editor first. This is also a critical debugging technique, to see exactly what you are extracting esp if bad data is crashing your job.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

In my experience, the general answer when Oracle throws that "invalid character" in a tool like this is because you've included a trailing semi-colon. Don't see that here, hence the desire to see the full / actual SQL.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chandu123
Premium Member
Premium Member
Posts: 40
Joined: Mon Sep 12, 2016 1:26 pm

Post by chandu123 »

Than you all for the responses.

I figured out that I was using Write mode as 'Insert' instead of User-defined SQL. Somehow Case statement was causing the issue in 'Insert' write mode. I chenaged it to User-defined SQL and it worked fine. Thanks.!!
HB
Post Reply