passing strings to functions

From: Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>
To: pgsql-general(at)postgresql(dot)org
Subject: passing strings to functions
Date: 2004-05-10 10:55:48
Message-ID: 20040510125548.62c19786@stige.webthatworks.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-05-10 11:44:10 Re: full tuple count in cursor.
Previous Message Stijn Vanroye 2004-05-10 10:54:36 Cancel query based on a timeout