Postgresql function with update returns error when upgrading 2 columns

Asked

Viewed 1,065 times

0

I am a beginner in postgresql and I have a question that I cannot solve. I made a simple function in the database that updates a record:

CREATE OR REPLACE FUNCTION public.teste(
    p_rec_id_transacao character varying,
    p_rec_valorA numeric)
RETURNS boolean AS
$BODY$
BEGIN 

     UPDATE financeiro_recebimentos SET rec_valorA=p_rec_valorA

 WHERE rec_id_transacao = P_rec_id_transacao;
 IF FOUND THEN
   RETURN TRUE;
 ELSE
   RETURN FALSE;
 END IF;    
END
$BODY$
LANGUAGE plpgsql

Everything works right, but when I add a new parameter and put in UPDATE returns an error when I call the function, the table is set correctly and worse, when I run with the debug of Pgadmin3 works:

CREATE OR REPLACE FUNCTION public.teste(
    p_rec_id_transacao character varying,
    p_rec_valorA numeric,
    p_rec_valorB numeric)
  RETURNS boolean AS
$BODY$
BEGIN 

   UPDATE financeiro_recebimentos SET rec_valorA=p_rec_valorA, 
                                      rec_valorB=p_rec_valorB

   WHERE rec_id_transacao = P_rec_id_transacao;
   IF FOUND THEN
      RETURN TRUE;
   ELSE
      RETURN FALSE;
   END IF;    
END
  $BODY$
  LANGUAGE plpgsql

When I call the function "SELECT test('DJUNU',1.0,2.0)" returns the error:

HINT: No Function Matches the Given name and argument types. You Might need to add Explicit type Casts.

Whoever has the patience to answer, thank you.

  • correcting:UPDATE financial_receipts SET rec_valorA=p_rec_valorA, rec_valorB=p_rec_valorB

  • you can correct any detail of the question by using the edit option: https://answall.com/posts/220655/edit

1 answer

1

try to do so:

SELECT teste('DJUNU'::varchar,1.0::numeric,2.0::numeric)

the error that is giving, is that sgdb is not finding a function with that name and parameters

  • worked, thanks!

  • do not forget to mark as reply, thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.