Calling a MSSQL Stored procedure

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
aluthra48
Participant
Posts: 66
Joined: Thu Mar 05, 2009 9:59 am

Calling a MSSQL Stored procedure

Post by aluthra48 »

I want to execute a stored procedure using the STPPX stage and I'd like some help with the following 2 questions:

The STPPX stage requires an input link. This is fine if the sp requires parameters, as then I can use the input link to provide the parameters to the sp. But what if no parameters are required by the sp? Do I then construct the sp with a dummy parameter, so that I can use the input link, even though the parameter is never used in the sp?

Second: The stored procedure I have constructed deletes/inserts rows. The parallel job returns an abort if there are no rows that end up being deleted or inserted. I have used test data to assure that the job works fine if the there are 1 or more rows that end up being deleted/inserted. How should I set up the STTPX stage to do so.

I have experimented with unchecking the "generate procedure call" in the Stage===>syntax tab, and to provide more syntax as exec spname ( ? )

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

Post by chulett »

The answer to the first question is 'yes'. For the second, not sure what you mean by "to do so? You can't abort on zero rows as nothing would be triggered then. Check 'after job' instead.
-craig

"You can never have too many knives" -- Logan Nine Fingers
aluthra48
Participant
Posts: 66
Joined: Thu Mar 05, 2009 9:59 am

Post by aluthra48 »

What I meant by "to do so" was how do I configure the stppx stage so that the sp does not abort if there are no rows that can be deleted or inserted? I have selected procedure type "Transform" as I am providing parameters to the sp.
Here's the coding for the procedure call syntax: Exec spname ( ? )
and here is how I have specified the procedure name: spname;1
I have unchecked the "generate procedure call" check box.

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

Post by chulett »

What exactly happens right now when "there are no rows that can be deleted or inserted"? What causes the abort?
-craig

"You can never have too many knives" -- Logan Nine Fingers
aluthra48
Participant
Posts: 66
Joined: Thu Mar 05, 2009 9:59 am

Post by aluthra48 »

Actually, with the stppx configured as mentioned above I get a syntax error. I am sorry, I have tried several permutations that I have lost sight of what configuration gave what error message in the logs. The error message is:

APT_CombinedOperatorController,0: Fatal Error: Fatal: [IBM(DataDirect OEM)][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '@P1'.

I then changed the configuration to enable "generate procedure call", and now the error message I get is:

Stp_Set_Active_Tables,0: Failure during execution of operator logic.
APT_CombinedOperatorController,0: Fatal Error: Fatal: CLI_NO_DATA
Sreenivasulu
Premium Member
Premium Member
Posts: 892
Joined: Thu Oct 16, 2003 5:18 am

Post by Sreenivasulu »

HI,

We are done this.
1. Use the row generator stage to generate a 'dummy record'
2. Use the SP stage to call MSSQL Stored procedure
3. Always return '0' since the SP wanta a Zero as the return value

Regards
Sreeni
aluthra48 wrote:Actually, with the stppx configured as mentioned above I get a syntax error. I am sorry, I have tried several permutations that I have lost sight of what configuration gave what error message in the logs. The error message is:

APT_CombinedOperatorController,0: Fatal Error: Fatal: [IBM(DataDirect OEM)][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '@P1'.

I then changed the configuration to enable "generate procedure call", and now the error message I get is:

Stp_Set_Active_Tables,0: Failure during execution of operator logic.
APT_CombinedOperatorController,0: Fatal Error: Fatal: CLI_NO_DATA
aluthra48
Participant
Posts: 66
Joined: Thu Mar 05, 2009 9:59 am

Post by aluthra48 »

Thanks, I will try this.

To make it work, I made the following changes:
1. Changed the stored proc to bypass the insert/delete logic, if there are no rows to insert/delete
2. Create an output parameter in the sp, and write it out to a peek stage from the stppx stage.

While this works, I will try the option you suggested.
Thanks
aluthra48
Participant
Posts: 66
Joined: Thu Mar 05, 2009 9:59 am

Post by aluthra48 »

IBM issued a patch for this
Post Reply