Error during lookup

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

dsdoubt
Participant
Posts: 106
Joined: Sat Jul 15, 2006 12:17 am

Error during lookup

Post by dsdoubt »

HI,
I have a table

CODE VARCHAR2(10) PK NOT NULL,
CODE_DESC VARCHAR2(50)

If I do a userdefined query in a OCI stage and write to a file with the following command
SELECT CODE FROM CODE_LKP
it works.

If I perform the same in a job where this stage acts as a lookup, it gives me the following error.

Code: Select all

ORA-01036: illegal variable name/number
I have marked the CODE column as PK, Not nullable, still Iam getting the above.

Hope you guys can help me.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

It seems that "CODE" is an invalid column name. Does the error persist if you use and different column name?
dsdoubt
Participant
Posts: 106
Joined: Sat Jul 15, 2006 12:17 am

Post by dsdoubt »

I think I need to change the code as
SELECT CODE FROM CODE_LKP WHERE CODE = :1

where :1 is the CODE from the main stream.

Now the fatal error vanishes.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Yes, that is true. I was wondering how "code" could be wrong but didn't notice that you had specified your SELECT explicitly. Usually the query that DS generates by default is good enough. Sorry about misdirecting you.
dsdoubt
Participant
Posts: 106
Joined: Sat Jul 15, 2006 12:17 am

Post by dsdoubt »

Do you mean "Fully Generated SQL Query".
But I couldnt see any SQL, If I select that option. Is it usual?
More over can I select only few columns using this option.
Or do you have any other suggestion?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I'm not sure what your question is, dsdoubt. You need to make sure that the number of columns in the query matches that defined in the stage.
dsdoubt
Participant
Posts: 106
Joined: Sat Jul 15, 2006 12:17 am

Post by dsdoubt »

May I know, what do you mean by "query that DS generates by default"?
Is it by the option "Fully Generated SQL Query" in the Query type on SQL tab?
If that is the case, I should need to click on Build, and select the tables which I should have been imported already. Even then, the select query comes with <instance>.<tablename>, where we might change it frequently.
Sorry, Iam new to this version, so not sure about the option that has been widely used.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Is CODE a reserved word in your database?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

No, it was just the classic problem when people use their own sql instead of letting the stage generate it for them. Column order doesn't match the DML or the number of columns doesn't match the number in the DML or not all values are bound or key fields aren't marked correctly, or...

What Arnd meant is that these stages will generate the SQL for you by default. You have to specifically change it to 'User Defined SQL' and I've never understood people's some fascination with doing everything as user defined. I constantly have to whack folks for doing that for no good reason.

ps. I never use the 'Fully Generated' option, perferring the 'Generate from the Columns' approach. Note that these names changed in the latest releases.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ramdev_srh
Participant
Posts: 16
Joined: Mon Jul 24, 2006 9:27 am

Re: Error during lookup

Post by ramdev_srh »

dsdoubt wrote:HI,
I have a table

CODE VARCHAR2(10) PK NOT NULL,
CODE_DESC VARCHAR2(50)

If I do a userdefined query in a OCI stage and write to a file with the following command
SELECT CODE FROM CODE_LKP
it works.

If I perform the same in a job where this stage acts as a lookup, it gives me the following error.

Code: Select all

ORA-01036: illegal variable name/number
I have marked the CODE column as PK, Not nullable, still Iam getting the above.

Hope you guys can help me.
Hi,
try to cheak the syntax for seting the primary key.
col_name(10) notnull pk.
moreever cheak where code is reserve word in oracle....
dsdoubt
Participant
Posts: 106
Joined: Sat Jul 15, 2006 12:17 am

Post by dsdoubt »

But my worry is, when I use those option, I get <instance>.<tablename> in the generated query (as I mentioned earliar.)
If i move the job from Dev to PROD wont this be affected?

PS: CODE is just an example. sorry for the confusion.
loveojha2
Participant
Posts: 362
Joined: Thu May 26, 2005 12:59 am

Post by loveojha2 »

If i move the job from Dev to PROD wont this be affected?
Surely it will, if the schemas are different.
Use Job parameters for such cases.
Success consists of getting up just one more time than you fall.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Metadata management

Post by ray.wurlod »

#SchemaName#.TableName

Never make the table name a job parameter. Following this advice means that things like lineage analysis and usage analysis will work properly.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Also consider #SchemaName#Tablename where the value of the schema name includes the dot.

Allows you to pass an empty schema name to optionally take advantage of synonyms or local tables.
-craig

"You can never have too many knives" -- Logan Nine Fingers
dsdoubt
Participant
Posts: 106
Joined: Sat Jul 15, 2006 12:17 am

Post by dsdoubt »

For the same reason of using parameter for the SchemaName, i switched to user defiend query.
Is there a way to make datastage to handle by it self?
Post Reply