agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
calling function
3+ messages / 3 participants
[nested] [flat]

* calling function
@ 2004-03-04 06:29 William Anthony Lim <wei.liang@eudoramail.com>
  2004-03-04 06:40 ` Re: calling function Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 3+ messages in thread

From: William Anthony Lim @ 2004-03-04 06:29 UTC (permalink / raw)
  To: pgsql-sql

Hi,
I have a little trouble. I'm newbie in postgresql.

Consider this function example:

create or replace function testcall(int4,varchar,bool,int2) return setof record as '
declare
	r record;
	a int4;
	b varchar;
	c bool;
	d int2;
begin
	a=$1;
	b=$2;
	c=$3;
	d=$4;

	for r in select * from "T_Customer" loop
		return next r;
	end loop;

	return r;
end;'
language 'plpgsql'


when i tried to call it using:
select * from testcall(12,'ABCD',true,20000);

it says:
ERROR:  function testcall(integer, "unknown", boolean, integer) does not exist

then I tried to change to:
select * from testcall(12,varchar'ABCD',true,20000);

it says:
ERROR:  function testcall(integer, character varying, boolean, integer) does not exist

I've tried them using jdbc prepared statement and callable statement (both with/without parameters), but the result is the same.
what should i do?

Thanks

William


Need a new email address that people can remember
Check out the new EudoraMail at
http://www.eudoramail.com



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: calling function
  2004-03-04 06:29 calling function William Anthony Lim <wei.liang@eudoramail.com>
@ 2004-03-04 06:40 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2004-03-04 06:40 UTC (permalink / raw)
  To: wei.liang@eudoramail.com; +Cc: pgsql-sql

"William Anthony Lim" <wei.liang@eudoramail.com> writes:
> create or replace function testcall(int4,varchar,bool,int2) return setof record as '
> ...
> select * from testcall(12,'ABCD',true,20000);
> ERROR:  function testcall(integer, "unknown", boolean, integer) does not exist

An undecorated integer constant is considered int4 (or int8 or numeric
if large enough), and there's no automatic downcast to int2.  You could
write 20000::int2 or some such, but on the whole I'd recommend declaring
the function to take int4 not int2.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* calling function
@ 2020-12-03 03:47 Yambu <hyambu@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Yambu @ 2020-12-03 03:47 UTC (permalink / raw)
  To: pgsql-sql@lists.postgresql.org

Hello

What are the caveats in calling function like this

select * from myfun()

if myfunc() returns a composite type and has inserts inside.

We are experiencing many locks

regards

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2020-12-03 03:47 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-03-04 06:29 calling function William Anthony Lim <wei.liang@eudoramail.com>
2004-03-04 06:40 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-12-03 03:47 calling function Yambu <hyambu@gmail.com>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox