plpgsql: calling a function with 2 OUT parameters

后端 未结 2 1487
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-05 06:42

I\'m trying to fetch to values from a plpgsql function with 2 OUT paramenters but I have some problem.

These are the functions:

CREATE OR REPLACE FUNCTION          


        
2条回答
  •  情话喂你
    2021-02-05 07:22

    SELECT * INTO xx, yy FROM get_test();
    

    UPDATE:

    Explanation:

    Modifying the second function:

    CREATE OR REPLACE FUNCTION get_test_read()
    RETURNS VOID AS $$
    DECLARE
       xx text;
       yy text;
    BEGIN
    
       SELECT * INTO xx, yy FROM get_test();
       
       RAISE INFO 'x: <%>', xx;
       RAISE INFO 'y: <%>', yy;
    
    END;
    $$  LANGUAGE plpgsql;  
    

    This is similar to SELECT INTO with TABLE, where only get 2 values:

    SELECT "FIELD1", "FIELD2" INTO variable1, variable2 FROM "TABLE" WHERE ...
    

    Npgsql Basic Usage

    PL/pgSQL Function Parameter Modes: IN, OUT, INOUT

提交回复
热议问题