USER DEFINED SQL FILE WITH DRS STAGE

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

kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

Which argument are you talking about? Can you cut and paste it here? Just changing UNIX to NT should do.
Kris

Where's the "Any" key?-Homer Simpson
vnspn
Participant
Posts: 165
Joined: Mon Feb 12, 2007 11:42 am

Post by vnspn »

I tried changing the first argument from "UNIX" to "NT", and it didn't work. If I Test the routine, it just gets hanged.

I'm talking about the secong argument "InputArg" which you pass to the 'DSExecute'.

Code: Select all

InputArg = "sqlplus":' ':USERNAME:'/':PASSWORD:'@':INSTANCE:' ':'@':PATH 
I think the format of this statement has been framed should be sightly different for executing it on Windows!
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

I ran the routine on Windows originally. I changed it to meet the requirements of the OP. Why don't you try it and let me know if it doesnt work.
Kris

Where's the "Any" key?-Homer Simpson
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

vnspn wrote:I think the format of this statement has been framed should be sightly different for executing it on Windows!
Nope, it's exactly the same.
-craig

"You can never have too many knives" -- Logan Nine Fingers
vnspn
Participant
Posts: 165
Joined: Mon Feb 12, 2007 11:42 am

Post by vnspn »

Ok, I tried executing the same code with changing just the first argument from "UNIX" to "NT".

In the Director log, I get a warning message from the routine as "Error when executing command.". So looking into your code for that loop, it should have had a condition where 'SystemReturnCode' should have been something other than '0'.

Also, in the Director log, I see message returned after successfully getting connected to the database. So, the error is in the SQL statement part of it...
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

Try executing just this statement from your command line.

Code: Select all

sqlplus && USERNAME/PASSWORD @ INSTANCE  @PATH
Kris

Where's the "Any" key?-Homer Simpson
vnspn
Participant
Posts: 165
Joined: Mon Feb 12, 2007 11:42 am

Post by vnspn »

Thanks Krish. I would try that and let you know.

In the mean time, we would want to execute a direct SQL statment in the routine rather executing it from a .sql file. In that case, can I substitute the complete SQL statement at the place where we specify the 'PATH' currently.
vnspn
Participant
Posts: 165
Joined: Mon Feb 12, 2007 11:42 am

Post by vnspn »

The last part in building the 'InputArg' is the argument PATH.

In my case, I do need to substitute a SQL statement instead of a PATH where the SQL is available.

For example, you have provided it as
sqlplus <username>/<password>@<dbname> @ <PATH>

But, I want to execute it as,
sqlplus <username>/<password>@<dbname> @ SELECT COUNT(*) FROM DUAL;

When I try to executing with the above line as the 'InputArg', I get an error message that - SP2-0310: unable to open file "SELECT.sql"

So, instead of considering the last part as an SQL statement, it considers it as the file name that contains the SQL.

Please let me know how to overcome this.

Thanks.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

vnspn wrote:So, instead of considering the last part as an SQL statement, it considers it as the file name that contains the SQL.
Because you told it it was a file through the use of the '@' symbol. Try removing it and see what happens. :?

Not saying it will work, but worth a shot. Still think you are better scripting this in a 'here document' style so that errors can be properly captured. Your way, all you'll know is if you were able to get into sqlplus or not, errors generated by the sql itself won't be reported.
-craig

"You can never have too many knives" -- Logan Nine Fingers
vnspn
Participant
Posts: 165
Joined: Mon Feb 12, 2007 11:42 am

Post by vnspn »

I tried removing the '@' symbol. The command that was passed to 'InputArg' would look like,

Code: Select all

sqlplus <username>/<password>@<dbname> SELECT COUNT(*) FROM DUAL;
I tried printing the output of this in the Director log. It gets connected to the database, but the SQL command is not recognized after that. The output on the log looks like,
SQL*Plus: Release 10.2.0.2.0 - Production

Copyright (c) 1982, 2005, Oracle. All Rights Reserved.

Usage 1: sqlplus -H | -V

-H Displays the SQL*Plus version and the
usage help.
-V Displays the SQL*Plus version.

Usage 2: sqlplus [ [<option>] [<logon>] [<start>] ]

<option> is: [-C <version>] [-L] [-M "<options>"] [-R <level>] [-S]

-C <version> Sets the compatibility of affected commands to the
version specified by <version>. The version has
the form "x.y[.z]". For example, -C 10.2.0
-L Attempts to log on just once, instead of
reprompting on error.
-M "<options>" Sets automatic HTML markup of output. The options
have the form:
HTML [ON|OFF] [HEAD text] [BODY text] [TABLE text]
[ENTMAP {ON|OFF}] [SPOOL {ON|OFF}] [PRE[FORMAT] {ON|OFF}]
-R <level> Sets restricted mode to disable SQL*Plus commands
that interact with the file system. The level can
be 1, 2 or 3. The most restrictive is -R 3 which
disables all user commands interacting with the
file system.
-S Sets silent mode which suppresses the display of
the SQL*Plus banner, prompts, and echoing of
commands.

<logon> is: (<username>[/<password>][@<connect_identifier>] | /)
[AS SYSDBA | AS SYSOPER] | /NOLOG

Specifies the database account username, password and connect
identifier for the database connection. Without a connect
identifier, SQL*Plus connects to the default database.

The AS SYSDBA and AS SYSOPER options are database administration
privileges.

The /NOLOG option starts SQL*Plus without connecting to a
database.

<start> is: @<URL>|<filename>[.<ext>] [<parameter> ...]

Runs the specified SQL*Plus script from a web server (URL) or the
local file system (filename.ext) with specified parameters that
will be assigned to substitution variables in the script.

When SQL*Plus starts, and after CONNECT commands, the site profile
(e.g. $ORACLE_HOME/sqlplus/admin/glogin.sql) and the user profile
(e.g. login.sql in the working directory) are run. The files may
contain SQL*Plus commands.

Refer to the SQL*Plus User's Guide and Reference for more information.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Have you investigated generating a "here script" as I suggested earlier?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vnspn
Participant
Posts: 165
Joined: Mon Feb 12, 2007 11:42 am

Post by vnspn »

Hi Ray,

By "here script", do mean the one below,

Code: Select all

cmd = "sqlplus -s ":userID:"/":passWD:"@":dbName
cmd<-1> = "SELECT COUNT(*) FROM DUAL;"
cmd<-1> = "quit;"

Call DSExecute("NT",cmd,output,rc)
I tried with this and it still didn't work. I printed the output of the command in the Director log. It is as below,
Error 45 initializing SQL*Plus
Internal error
DataStage/SQL: Table "DUAL" does not exist.
Verb "QUIT;" is not in your VOC.
Is there a way we could resolve this?

Thanks.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Ask your DBA what this means: "Error 45 initializing SQL*Plus".
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

No that is not what I meant by a "here script". Read my posts carefully again, and get some advice from someone competent with shell scripts.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply