Search Postgresql Archives

Need help with INOUT mis-understanding

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?


---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux