MS_SQL Stored Procedure Best Practice Question

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

Post Reply
jpulaski
Participant
Posts: 2
Joined: Wed Oct 19, 2005 2:08 pm

MS_SQL Stored Procedure Best Practice Question

Post by jpulaski »

Greetings,

Question: I'm on Windows, DataStage 7.5, and I would like to execute a SQL-Server stored procedure. I don't need to feed any input data to the stored procedure, but would like to see if it works. I looked at the new Stored Procedure stage, but it doesn't look like it likes SQL-Server (but just DB2, Oracle, and Sybase). So, I'm wondering what is the best way for me to accomplish this.

Detail: I've searched the forum for an answer to my question above and found lots of information, but am still not sure of the best practice. So, any advice would be appreciated.

Thanks,

Jason
Jason L Pulaski
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

isql/osql command line script. By writing a reusable wrapper script now for executing SQL scripts or procedures, you'll enable a long term elegant solution for running scripts quite easily from a Command stage in a Sequencer, or the Command stage in Windoze Server jobs. You'll also be able to use a Batch job to directly call your script and use DS BASIC programming to interact with jobs, log messages, send emails, etc all within DS itself.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
lstsaur
Participant
Posts: 1139
Joined: Thu Oct 21, 2004 9:59 pm

Post by lstsaur »

Hi Jason,
Using either isql or osql will work. However, if your SQL server is not located in the same server as your DataStage server, then you have to install the SQL Analyzer client on the server that the DataStage server resides. Second thing is that you have to hardcode the user ID and the password in your ISQL command script. Both secenarios are not good practice in the production environment. Good luck.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

lstsaur wrote:you have to hardcode the user ID and the password in your ISQL command script
Really? A batch, perl, or java script can't fetch these values from a protected parameter file or environment variable when executing the command line call or even better use trusted connections?
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
lstsaur
Participant
Posts: 1139
Joined: Thu Oct 21, 2004 9:59 pm

Post by lstsaur »

Hi Ken,
A batch script sure can retrive these values from either the job parameters or environment variables. My situation was an encrypted password retrieved from the parameters into the batch file, but the problem was that our job scheduler, Control-M, just wouldn't work with the encrypted password. However, after I hardcoded the password in the ISQL command and the whole thing worked just fine. That's why I said that you have to hardcode the password in the ISQL statement and it's not a good practice in the production environment.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Have you ever tried indirection? In the Unix world, that's a common method for avoiding exposing command line options to the ps command. Your scheduler might indirect in the encrypted parameter from a hidden
file.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
jpulaski
Participant
Posts: 2
Joined: Wed Oct 19, 2005 2:08 pm

Post by jpulaski »

i am using

osql -E /d CashRec /S AAENTSQL01 -Q "qry_electronic_Append_TRD"

where CashRec = the database name
AAENTSQL01 = the servername
qry_electronic_Append_TRD = the stored procedure name

and I am using the -E to use Windows NT authentication, so I believe it will log into the SQL database using the NT ID logged into windows. I am now wodering will this work if NO one is currently logged into the server in which the code resides?
Jason L Pulaski
mrlindsey
Participant
Posts: 4
Joined: Thu Jan 19, 2006 8:47 am
Location: MA, USA
Contact:

Post by mrlindsey »

What if we are running DataStage on Unix and can't call isql or osql from the command line. Is there another way to call a SQLServer stored procedure from a server job?

-Matt Lindsey
jdmiceli
Premium Member
Premium Member
Posts: 309
Joined: Wed Feb 22, 2006 10:03 am
Location: Urbandale, IA

Post by jdmiceli »

In Matt's case I have simply used the Dynamic RDBMS Stage to connect to the SQL Server instance I need, set it for User-Defined SQL and issue an 'exec sp_whatever'. The connection is already created by DS so I don't have to worry about passing authentication to the server.
Bestest!

John Miceli
System Specialist, MCP, MCDBA
Berkley Technology Services


"Good Morning. This is God. I will be handling all your problems today. I will not need your help. So have a great day!"
Post Reply