Subject SP var question
Author Tim Ledgerwood
How do I set values in output parameters in stored procedures? I am used to
the Sybase

"SELECT VAR1 = 'xyz', VAR2 = 1" etc etc etc.

Here is the SP I am trying to write - I want the output parameters filled
with values before I check the DB for an existing record :

ALTER PROCEDURE "INITBATCH"
RETURNS
(
"BATCHNUM" INTEGER,
"BATCH_OPEN" INTEGER,
"TXN_NUM" INTEGER,
"FM_TXN_NUM" INTEGER,
"NUM_CR" INTEGER,
"NUM_CR_REV" INTEGER,
"NUM_DR" INTEGER,
"NUM_DR_REV" INTEGER,
"NUM_TR" INTEGER,
"NUM_TR_REV" INTEGER,
"NUM_IQ" INTEGER,
"NUM_AU" INTEGER,
"AMT_CR" FLOAT,
"AMT_CR_REV" FLOAT,
"AMT_DR" FLOAT,
"AMT_DR_REV" FLOAT,
"SEQ_NUM" INTEGER
)
AS
BEGIN
:BATCHNUM = 1,
:BATCH_OPEN = 1,
:TXN_NUM = 0,
:FM_TXN_NUM = 0,
:NUM_CR = 0,
:NUM_CR_REV = 0,
:NUM_DR = 0,
:NUM_DR_REV = 0,
:NUM_TR = 0,
:NUM_TR_REV = 0,
:NUM_IQ = 0,
:NUM_AU = 0,
:AMT_CR = 0,
:AMT_CR_REV = 0,
:AMT_DR = 0,
:AMT_DR_REV = 0,
:SEQ_NUM = 0

IF (EXISTS (SELECT BATCHNUM FROM BATCH)) THEN
BEGIN
/*if there are ANY records, select into vars*/
/*check for open batches*/
/*if no open batches*/
/*DO .. BEGIN*/
SUSPEND;
/*END*/
END
ELSE
BEGIN
/*If there are no records, insert default values*/
INSERT INTO BATCH
(
BATCHNUM, BATCH_OPEN, TXN_NUM, FM_TXN_NUM, NUM_CR, NUM_CR_REV,
NUM_DR, NUM_DR_REV, NUM_TR, NUM_TR_REV, NUM_IQ, NUM_AU, AMT_CR,
AMT_CR_REV, AMT_DR, AMT_DR_REV, SEQ_NUM
)
VALUES
(
:BATCHNUM, :BATCH_OPEN, :TXN_NUM, :FM_TXN_NUM, :NUM_CR, :NUM_CR_REV,
:NUM_DR, :NUM_DR_REV, :NUM_TR, :NUM_TR_REV, :NUM_IQ, :NUM_AU,
:AMT_CR,
:AMT_CR_REV, :AMT_DR, :AMT_DR_REV, :SEQ_NUM
);
END
END
^


[Non-text portions of this message have been removed]