Calling SQL Server Stored Procedure

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
horserider
Participant
Posts: 71
Joined: Mon Jul 09, 2007 1:12 pm

Calling SQL Server Stored Procedure

Post by horserider »

I have a SQL Server Stored Procedure that updates a table. The procedure has to be run for multiple rows and should return nothing.

How can I call SQL Server Stored Procedure and pass multiple rows as input?

Definition of Stored Procedure

USE [IBMDB]
GO
/****** Object: StoredProcedure [dbo].[IBMEDW_Update_Process] ******/
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROCEDURE [dbo].[IBMEDW_Update_Process]

@Interface_System char(3),
@Process_Type char(6),
@Process_Date datetime,
@Process_Flag char(1),
@Variables char(5)

AS

SET NOCOUNT ON

BEGIN

UPDATE DBO.IBM_PROCESS_INT SET
PROCESS_FLAG = @Process_Flag,
PROCESS_DATE = @Process_Date
WHERE INTERFACE_SYSTEM = @Interface_System
AND PROCESS_TYPE = @Process_Type
AND substring(VARIABLES,1,5) = @Variables

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

Post by chulett »

Sorry, can't answer your SQL Server question but I have to ask - why a stored procedure just to do that? Why not do your updates directly in DataStage? :?
-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 »

If you call your stored procedure in an ODBC stage all rows delivered to the stage will be passed as inputs to the stored procedure.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
horserider
Participant
Posts: 71
Joined: Mon Jul 09, 2007 1:12 pm

Post by horserider »

So, if all my parameters are in a Sequential File, I should design my job this way in a SERVER JOB?

(Server Job)

SQL FILE > TRANSFORMER > ODBC Stage

I don't have ODBC STAGE in my Parallel Job pane but I only see ODBC ENTERPRISE. So can I design SERVER job to accomplish this?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Well, the Server ODBC stage has an Update action of 'Call stored procedure' so would work as shown. Does the Enterprise stage? If so, it should work in a similar manner.
-craig

"You can never have too many knives" -- Logan Nine Fingers
shamshad
Premium Member
Premium Member
Posts: 147
Joined: Wed Aug 25, 2004 1:39 pm
Location: Detroit,MI

Post by shamshad »

Use ODBC Stage as you suggested in your email.

Source > ODBC Stage (Server Job)

From Source, pull the column name in the same order as mentioned in the INPUT PARAMETER and via a transformer drag all the columns to an ODBC Stage. In one of the TAB in ODBC Stage Use "Server Procedure", import the definition.. the Stored Procedure SQL will be something like

{CALL STOREDPROC(?,?,?,?,?)} 1 question mark for every imput and output. Since your SP doesn't return any rows there are no output parameters.

This should work using a SERVER JOB.

If you want to make PARALLEL JOB work the same way, see if you have DRS ODBC STAGE (TARGET) and then COPY the EXECUTION SQL from server job and PASTE it in TARGET where the SQL OPERATION should be USER DEFINED.

Good Luck !
horserider
Participant
Posts: 71
Joined: Mon Jul 09, 2007 1:12 pm

Post by horserider »

Shamshad,

Thanks bunch ! It works as you mentioned in SERVER JOB. I am sure it will work in PARALLEL JOB too.

Thanks once gain. I love this Forum.
Post Reply