Need help with INOUT mis-understanding

From: "Troy" <troy(at)hendrix(dot)biz>
To: pgsql-general(at)postgresql(dot)org
Subject: Need help with INOUT mis-understanding
Date: 2005-10-25 18:19:40
Message-ID: 1130264380.751219.116260@z14g2000cwz.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Yes, I'm a Newbie but I really like it so far except a few
misunderstandings I have, like INOUT. (I am using 8.1 beta 3 on both
WIN and FC w/ pgadmin III.)

I cannot use multiple in/out/inouts within functions to return results.
How can I use INOUTS the right way? Here I thought I'd get an updated
value from "func2" within "func1":

-- FUNC1
CREATE OR REPLACE FUNCTION func1(INOUT var_1 int4) AS
'
DECLARE
var_X RECORD;
var_Y int4;
BEGIN
var_Y := var_1;
RAISE NOTICE ''var_1 starts as %'',var_1;
var_X := func2(var_1,var_Y);
RAISE NOTICE ''var_X Now is %'',var_X;
RAISE NOTICE ''var_1 Now is %'',var_1;
END --test__inout
'
LANGUAGE 'plpgsql' VOLATILE;

---FUNC2
CREATE OR REPLACE FUNCTION func2(INOUT var_1 int4,
INOUT var_Y int4) AS
'
BEGIN
var_1 = var_1 + var_1;
RAISE NOTICE ''var_1 in func2 is %'',var_1;
END --func2
'
LANGUAGE 'plpgsql' VOLATILE;

-----RESULTS:
NOTICE: var_1 starts as 5
NOTICE: var_1 in func2 is 10
CONTEXT: PL/pgSQL function "func1" line 7 at assignment
NOTICE: var_X Now is (10,5)
NOTICE: var_1 Now is 5

Total query runtime: 30 ms.
Data retrieval runtime: 0 ms.
1 rows retrieved.

(Shouldn't var_1 = 10 Now?)
ANY ADVICE? Where can I find out how to handle them correctly?

I have tried using Return and such but I don't get it. (Been reading
all the online and support help I can find.) Does PL/PGSQL handle
INOUTS the same as ORACLE PL/SQL?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Cosmopo 2005-10-25 18:25:22 Looking for a command to list schemas
Previous Message Andreas Seltenreich 2005-10-25 18:15:58 Re: STL problem in stored procedures