Subject | Re: psql question with trigger |
---|---|
Author | Dixon Epperson |
Post date | 2005-02-03T22:01:44Z |
--- In firebird-support@yahoogroups.com, "Ann W. Harrison"
<aharrison@i...> wrote:
you get the value from the generator to the variable, and how would
you declare the variable??
heres my first draft
SET TERM!!
CREATE PROCEDURE NEWSALESDATA(iFILE CHAR(1), iCOID CHAR(20), iINVOICE
CHAR(20), iINVDATE DATE,
iSTCKNO VARCHAR(20), iQTY INTEGER)
RETURNS (oRECNO INTEGER) AS
BEGIN
GEN_ID(GEN_SD_RECNO, 1) INTO :oRECNO
INSERT INTO SALESDATE (SD_RECNO, SD_FILED, SD_COID, SD_INVOICE,
SD_INVDATE, SD_STCKNO, SD_QTY)
VALUES(:oRECNO, :iFILE, :iCOID, :iINVOICE, :iINVDATE, :iISTCKNO, :iQTY);
END
END!!
SET TERM;
<aharrison@i...> wrote:
> Dixon Epperson wrote:only
> >
> > Is there a way to write the PSQL so that after it inserts the values
> > it selects the new record number (the one in my table, not the one in
> > the system tables) and returns it. I guess I'm asking how to select a
> > field value based on the cursors current position. Is that possible?
>
> You can't do it exactly that way. However, you can do it by getting a
> new record number from a generator in the procedure, setting that value
> into the record, inserting the record, and returning the value. You
> should also change your trigger so it generates a new record number
> if the incoming record number is null.Thanks. But I'm going to need some help on the structure, like how do
>
> Regards,
>
>
> Ann
you get the value from the generator to the variable, and how would
you declare the variable??
heres my first draft
SET TERM!!
CREATE PROCEDURE NEWSALESDATA(iFILE CHAR(1), iCOID CHAR(20), iINVOICE
CHAR(20), iINVDATE DATE,
iSTCKNO VARCHAR(20), iQTY INTEGER)
RETURNS (oRECNO INTEGER) AS
BEGIN
GEN_ID(GEN_SD_RECNO, 1) INTO :oRECNO
INSERT INTO SALESDATE (SD_RECNO, SD_FILED, SD_COID, SD_INVOICE,
SD_INVDATE, SD_STCKNO, SD_QTY)
VALUES(:oRECNO, :iFILE, :iCOID, :iINVOICE, :iINVDATE, :iISTCKNO, :iQTY);
END
END!!
SET TERM;