using shell Script to access Stored Proc
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 40
- Joined: Tue May 18, 2004 10:51 pm
using shell Script to access Stored Proc
I've a Stored Procedure in The Oracle DB which logs the start time, end time, process time and user name, these are send as IN params to stored proc. I need to use this in my Data Stage job and output a Logno. what is the best way to do this. I was thinking about using shell script and calling it in after stage sub-routine of Transformer. could anybody help me on this. like what would be the script if I use shell script.
Help is greatly appreciated.
Thank you
James
Help is greatly appreciated.
Thank you
James
hi James
it sounds like a complicated way of doing things. If you have to use the stored procedure, then I would suggest you gather the required INPUT parameters for the stored proc by using parameters in a job control. This information (like start time, end time, process time) can be obtained by doing oconvs within the job control of the system date - Or DSGetJobInfo might give you this information; you'll have to check. The user name you get deends on whether you need the DB user or the DS user - you'll know what you are after.
You can have a batch file (I see you are on windows) that calls the stored procedure using the INPUT params you provide. How you code that the real fundis of the forum might be able to help.
The question now remains as to what you are doing with the log number. I take it the log number comes from the stored procedure - if you need to output the log number to the DS log, then you might end up having to do an ISQL query on the DB to get the log number provided the stored procedure writes the log number to a table somewhere.
But I think the solution lies in thinking out of the box; I get the feeling you are using DS in a system that has been working for a while, and now you need to conform with existing methods. Nothing wrong with that, its just that sometimes people need to be re-educated into new ways of doing old things.
by the way - I do believe the ODBC stage can execute a stored procedure, but I have not used it as yet and am not sure if paramaters can be parsed through; perhaps you can read up on it and let us all know if you get it working.
good luck
it sounds like a complicated way of doing things. If you have to use the stored procedure, then I would suggest you gather the required INPUT parameters for the stored proc by using parameters in a job control. This information (like start time, end time, process time) can be obtained by doing oconvs within the job control of the system date - Or DSGetJobInfo might give you this information; you'll have to check. The user name you get deends on whether you need the DB user or the DS user - you'll know what you are after.
You can have a batch file (I see you are on windows) that calls the stored procedure using the INPUT params you provide. How you code that the real fundis of the forum might be able to help.
The question now remains as to what you are doing with the log number. I take it the log number comes from the stored procedure - if you need to output the log number to the DS log, then you might end up having to do an ISQL query on the DB to get the log number provided the stored procedure writes the log number to a table somewhere.
But I think the solution lies in thinking out of the box; I get the feeling you are using DS in a system that has been working for a while, and now you need to conform with existing methods. Nothing wrong with that, its just that sometimes people need to be re-educated into new ways of doing old things.
by the way - I do believe the ODBC stage can execute a stored procedure, but I have not used it as yet and am not sure if paramaters can be parsed through; perhaps you can read up on it and let us all know if you get it working.
good luck
dnzl
"what the thinker thinks, the prover proves" - Robert Anton Wilson
"what the thinker thinks, the prover proves" - Robert Anton Wilson
-
- Participant
- Posts: 40
- Joined: Tue May 18, 2004 10:51 pm
Thanks Denzilsyb,
what I'm doing is I INSERT these Input values[start time(DSJobStarttime, end time(SYSDATE), process name and user name(last eidted user) ] into a log TABLE and assign a log number for this record which is the output from the stored proc. when I import this stored proc into Data Stage it gives me error (I beleive Datastage doesn't support out params from a stored proc). and this stored procedure I'll run only once for the job not for every record processed.
please suggest.
James
what I'm doing is I INSERT these Input values[start time(DSJobStarttime, end time(SYSDATE), process name and user name(last eidted user) ] into a log TABLE and assign a log number for this record which is the output from the stored proc. when I import this stored proc into Data Stage it gives me error (I beleive Datastage doesn't support out params from a stored proc). and this stored procedure I'll run only once for the job not for every record processed.
please suggest.
James
-
- Participant
- Posts: 40
- Joined: Tue May 18, 2004 10:51 pm
Sure, simply "call" the procedure in the Before or After SQL tab. Not sure about the use of Job Parameters at the same time, give that a shot and let us know if it works for you or not.Jamesvanam wrote:Actually I was wondering if there is a way to invoke a stored Proc from after SQL tab in the target OCI9stage. I'd be using the IN params from the JOB.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 40
- Joined: Tue May 18, 2004 10:51 pm
-
- Participant
- Posts: 40
- Joined: Tue May 18, 2004 10:51 pm
Thanks craig,
one more small thing I'm trying to figure out. one of the arguments in the stored Proc i'm calling needs current date like SYSDATE ,and the other three arguments i'm using from the columns of the target OCIstage(where i'm writing the stored proc) and a job parameter. basically what I'm trying to do is send the jobstart time , endtime of the job,processname and a last edit user name.
Thank you
one more small thing I'm trying to figure out. one of the arguments in the stored Proc i'm calling needs current date like SYSDATE ,and the other three arguments i'm using from the columns of the target OCIstage(where i'm writing the stored proc) and a job parameter. basically what I'm trying to do is send the jobstart time , endtime of the job,processname and a last edit user name.
Thank you
James
You can download EtlStats which is several jobs which will extract job start and end times plus row counts and push them into a database. You download on Ascential's ADN or my tips page below. Save you lots of time. It will get row counts for all job, all jobs in a sequence, all jobs in a category or one specific job. There is a DSX to import the jobs. There is documentation to show you how it works.
You can download EtlStats which is several jobs which will extract job start and end times plus row counts and push them into a database. You download on Ascential's ADN or my tips page below. Save you lots of time. It will get row counts for all job, all jobs in a sequence, all jobs in a category or one specific job. There is a DSX to import the jobs. There is documentation to show you how it works.
Mamu Kim
-
- Participant
- Posts: 40
- Joined: Tue May 18, 2004 10:51 pm
Me, I'd do one of two things:
* Ditch the "sysdate" parameter and just generate it inside the procedure, unless there are times when something else is passed in other than the current date / time.
* Dump the procedure and do the equivalent in DataStage, which is what Kim suggested. Writing something to capture stats is pretty straight-forward and besides, Kim has done most (if not all) of it for you already.
* Ditch the "sysdate" parameter and just generate it inside the procedure, unless there are times when something else is passed in other than the current date / time.
* Dump the procedure and do the equivalent in DataStage, which is what Kim suggested. Writing something to capture stats is pretty straight-forward and besides, Kim has done most (if not all) of it for you already.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 40
- Joined: Tue May 18, 2004 10:51 pm