pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedFunction Parameter Problem
4+ messages / 3 participants
[nested] [flat]
* Function Parameter Problem
@ 2006-02-18 07:40 fathur rohman <fathur_edp@yahoo.com>
0 siblings, 1 reply; 4+ messages in thread
From: fathur rohman @ 2006-02-18 07:40 UTC (permalink / raw)
To: pgsql-admin
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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Function Parameter Problem
@ 2006-02-18 18:16 Tom Lane <tgl@sss.pgh.pa.us>
parent: fathur rohman <fathur_edp@yahoo.com>
0 siblings, 2 replies; 4+ messages in thread
From: Tom Lane @ 2006-02-18 18:16 UTC (permalink / raw)
To: fathur rohman <fathur_edp@yahoo.com>; +Cc: pgsql-admin
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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Function Parameter Problem
@ 2006-02-20 04:27 fathur rohman <fathur_edp@yahoo.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 4+ messages in thread
From: fathur rohman @ 2006-02-20 04:27 UTC (permalink / raw)
To: pgsql-admin
Thanks Tom
i'll try it.
Send instant messages to your online friends http://uk.messenger.yahoo.com
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Function Parameter Problem
@ 2006-02-20 08:33 Milorad Poluga <milorad.poluga@cores.co.yu>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 4+ messages in thread
From: Milorad Poluga @ 2006-02-20 08:33 UTC (permalink / raw)
To: pgsql-admin
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
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2006-02-20 08:33 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-02-18 07:40 Function Parameter Problem fathur rohman <fathur_edp@yahoo.com>
2006-02-18 18:16 ` Tom Lane <tgl@sss.pgh.pa.us>
2006-02-20 04:27 ` fathur rohman <fathur_edp@yahoo.com>
2006-02-20 08:33 ` Milorad Poluga <milorad.poluga@cores.co.yu>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox