By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,987 Members | 997 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,987 IT Pros & Developers. It's quick & easy.

output parameters in functions

P: 4
Can someone tell me what's wrong with this syntax?


CREATE OR REPLACE FUNCTION Foo(bigint, out int, out boolean )
RETURNS record AS
$BODY$
begin
$2 := 0;
$3 := false;
end
$BODY$
LANGUAGE 'plpgsql';


CREATE OR REPLACE FUNCTION bar( bigint )
RETURNS int AS
$BODY$
declare aa int;
bb boolean;
begin
aa := 1;
bb := false;
select Foo( $1, out aa, out bb );
return aa;
end
$BODY$
LANGUAGE 'plpgsql';



ERROR: syntax error at or near "$2"
SQL state: 42601
Context: SQL statement in PL/PgSQL function "bar" near line 6
Jul 9 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 534
Expand|Select|Wrap|Line Numbers
  1. CREATE OR REPLACE FUNCTION Foo(bigint, out int, out boolean )
  2. ... ... ...
  3.  
  4. CREATE OR REPLACE FUNCTION bar( bigint )
  5. ... ... ...
  6.     select Foo( $1, out aa, out bb );
  7. ... ... ...
  8.  
ERROR: syntax error at or near "$2"
I don't think you can pass the OUT parameters when calling a function.
Try this:
Expand|Select|Wrap|Line Numbers
  1. select Foo ($1);
  2.  
Jul 9 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.