passing strings to functions

Поиск
Список
Период
Сортировка
От Ivan Sergio Borgonovo
Тема passing strings to functions
Дата
Msg-id 20040510125548.62c19786@stige.webthatworks.it
обсуждение исходный текст
Ответы Re: passing strings to functions  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: "Stijn Vanroye"
Дата:
Сообщение: Cancel query based on a timeout
Следующее
От: Tom Lane
Дата:
Сообщение: Re: full tuple count in cursor.