Before SQL statement in DB2 Connector not working

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
harikhk
Participant
Posts: 64
Joined: Tue Jun 04, 2013 11:36 am

Before SQL statement in DB2 Connector not working

Post by harikhk »

Hi,

Need to extract data from a view.
Want to create this view using the Before SQL option of DB2Connector stage by reading the create the statement from a file.

The job fails saying The object name(here the view) is undefined.

My understanding with BeforeSQL statement is, the statements defined in the beforesql statement(here creation of the view) would be executed first before processing of any data(here reading the data from the view).

Please help me to understand how this functions.

Running Datastage 8.7 version on unix.
Thanks,
HK
*Go GREEN..Save Earth*
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Your problem is more than likely the 'from a file' part... what syntax are you using for that? Also curious if there any parameters in the file.

Personal opinion - that's not the right place to be doing that.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

The metadata for the select from your view would be checked before execution... at which time your view does not exist.

I agree with Craig... Before SQL is not the place for this view creation.

Is there a reason for creating the view for every job run instead of a one time creation?

If yes, I'd probably create it using the DB2 CLI from an execute command activity in a job sequence.

Mike
harikhk
Participant
Posts: 64
Joined: Tue Jun 04, 2013 11:36 am

Post by harikhk »

Craig,
There are no parameters in the file.

Mike,

I create the view at the run time because there is a subquery within the view creation which has a where clause for range of dynamic dates, which currently I am taking care from a script to change these dates and create the sql statement file. This file I am using in the before Sql part.
I understand from your statement "The metadata for the select from your view would be checked before execution... at which time your view does not exist", this is not the right place.
Thanks,
HK
*Go GREEN..Save Earth*
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You didn't answer the syntax question.

And I don't recall ever seeing a view that needed to be constantly recreated with a dynamic date range, rather you create something more 'generic' and then constrain the data when you select from the view. I understand it's in a subquery but still... hard to say however without seeing the actual view definition and knowing the structures/data. [shrug]

If the view literally does not exist before the first run (i.e. this is only a first run issue) - create it. Then let your job do the "CREATE OR REPLACE" part when the job runs to firm up your date range.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply