Jump to content
Fórum Script Brasil
  • 0

Function retorno de chave primária no insert


mendoncasm

Question

Bom dia á todos !

Galera preciso da ajuda de vocês. Criei uma function para inserir dados, até aí tudo ok, porém, preciso que esta function me retorne o valor da chave primária inserida. Segue a function:

CREATE OR REPLACE FUNCTION sp_ins_cotacao(character, character, character, character, character, character, character, character)

RETURNS integer AS

$$

DECLARE

OPCAO ALIAS FOR $1;

DTCAD ALIAS FOR $2;

DTRESP ALIAS FOR $3;

DATAF ALIAS FOR $4;

PROXIM ALIAS FOR $5;

MERCAD ALIAS FOR $6;

TPPROD ALIAS FOR $7;

CODEMP ALIAS FOR $8;

NCOTA ZZ6010%ROWTYPE;

BEGIN

IF opcao = 'I' THEN

INSERT INTO ZZ6010 (ZZ6_DTCAD, ZZ6_DTRESP, ZZ6_DATAF, ZZ6_PROXIM, ZZ6_MERCAD, ZZ6_TPPROD,

ZZ6_CODEMP) values (DTCAD, DTRESP, DATAF, PROXIM, MERCAD, TPPROD, CODEMP);

END IF;

RETURN NCOTA.ZZ6_NCOTA;

END;

$$

LANGUAGE plpgsql

Esta Function esta inserindo dados normalmente, só não está retornando o valor. A chave primária é um sequence.

Agradeço a quem puder me ajudar !

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...