passing strings to functions - Mailing list pgsql-general

From Ivan Sergio Borgonovo
Subject passing strings to functions
Date
Msg-id 20040510125548.62c19786@stige.webthatworks.it
Whole thread Raw
Responses Re: passing strings to functions
List pgsql-general
I can't understand how to pass strings to functions.

create type tSession
  as
(
    SessionCode char(32),
    SessionID char(32),
    UserIDI integer,
    SessionN integer
);

create or replace function GetSessionCode( char(32), smallint,
boolean, varchar(128) )    returns tSession as
'
declare
  newSession tSession;
...
begin
...
  return newSession;
end;
' language plpgsql;

test1=# select * from
GetSessionCode('12345678901234567890123456789012',1,TRUE,'sadas');

ERROR: function getsessioncode("unknown", integer, boolean,"unknown")
does not exist HINT:  No function matches the given name and argument
types. You may need to add explicit type casts.

Is there a simpler way than casting everytime?

Curiously this work:

create or replace function testa( char(10) )
    returns char(32) as
'
begin
    return md5(''aaaa'');
end;
' language plpgsql;

test1=# select * from testa('dsd');
              testa
----------------------------------
 74b87337454200d4d33f80c4663dc5e5
(1 row)


thx

pgsql-general by date:

Previous
From: "Stijn Vanroye"
Date:
Subject: Cancel query based on a timeout
Next
From: Tom Lane
Date:
Subject: Re: full tuple count in cursor.