Обсуждение: Function Parameter Problem

Поиск
Список
Период
Сортировка

Function Parameter Problem

От
fathur rohman
Дата:
Hi Every Body,

i'v finished creating function generate_sjno(str_no
char(12), int_reset int2).
when it called an error message raised, this is the
illustration:

baisdb=> select generate_sjno('20060130',6);
ERROR:  function generate_sjno("unknown", integer)
does not exist
HINT:  No function matches the given name and argument
types. You may need to ad
d explicit type casts.

my questions :

1. is always char become bpchar on function
declaration?
2. is any missing on my function?
3. thanks all.

this my function declaration :

CREATE OR REPLACE FUNCTION generate_sjno(str_no
bpchar, int_reset int2)
  RETURNS bpchar AS
$BODY$
declare
  stran char(12);
  srsj char(4);
begin
     select into stran max(substr(tranno,9,4)) from
tran_hd where substr(tranno,1,int_reset)=str_no;
     if found then

srsj:=lpad(((trim(stran)::int2)+1)::varchar(4),4,'0');
     else
    srsj:='0001';
     end if;
     stran:=substr(str_no,1,8) || srsj;
     return stran;
end;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;


Send instant messages to your online friends http://uk.messenger.yahoo.com

Re: Function Parameter Problem

От
Tom Lane
Дата:
fathur rohman <fathur_edp@yahoo.com> writes:
> i'v finished creating function generate_sjno(str_no
> char(12), int_reset int2).
> when it called an error message raised, this is the
> illustration:

> baisdb=> select generate_sjno('20060130',6);
> ERROR:  function generate_sjno("unknown", integer)
> does not exist

It's not the char argument that's giving you trouble there, it's the int2.
I'd strongly suggest declaring the function to take plain int, else
you're going to be writing a lot of downcasts to int2.  int->int2 is not
an implicit conversion.

            regards, tom lane

Re: Function Parameter Problem

От
fathur rohman
Дата:
Thanks Tom

i'll try it.


Send instant messages to your online friends http://uk.messenger.yahoo.com

Re: Function Parameter Problem

От
Milorad Poluga
Дата:
Thank you all for suggestions and links.
Currently, I am working on  PostgreSQL 8.0.4., so I cannot use justify_*() functions.

Regards,
Milorad Poluga

milorad.poluga@cores.co.yu