INOUT text[],OUT text parameter handling problem
От | Michael Moore |
---|---|
Тема | INOUT text[],OUT text parameter handling problem |
Дата | |
Msg-id | CACpWLjOioHs+UWJNb4VHii_aEEvjn_2Aun6p3v6BsFVSOTuOdw@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: INOUT text[],OUT text parameter handling problem
|
Список | pgsql-sql |
This function needs to add a string to the array and return that array. Also it needs to return a string.What I want to see in my test script is a TEXT variable that will contain the value of p_result_string_o which was assigned in fbind. Also I want "using_values" to contain the value which was inserted by fbind.
CREATE OR REPLACE FUNCTION fbind(IN p_parm_value_i text,IN p_psudo_datatype_i character varying,OUT p_result_string_o text,INOUT p_bind_values_io text[])RETURNS record AS$BODY$BEGINp_bind_values_io := array_append(p_bind_values_io, p_parm_value_i);CASE p_psudo_datatype_iWHEN 'cvs num' THENp_result_string_o := '= ANY ((''{''||$'||array_length(p_bind_values_io,1)::text||'||''}'')::bigint[] ) ';WHEN 'bigint' THENp_result_string_o := '= TO_NUMBER($'||array_length(p_bind_values_io,1)::text||',''99999999999999999999'') ';ELSEp_result_string_o := 'datatype not implemented';END CASE;RETURN;END;$BODY$LANGUAGE plpgsql;
Here is my test script
DO $$DECLAREusing_values text[] ;p_result_string_o text;BEGINusing_values := array_append(using_values, 'the first entry'::text);p_result_string_o := fbind('1234'::text, 'bigint'::character varying, using_values);raise notice 'p_result_string_o:%', p_result_string_o;raise notice 'using_values:%', using_values;END$$;
Output from my test script:
NOTICE: p_result_string_o:("= TO_NUMBER($2,'99999999999999999999') ","{""the first entry"",1234}")
NOTICE: using_values:{"the first entry"}
The problems are:
- using_values does not show the update that was applied by fbind even though it is defined as INOUT.
- p_result_string_o contains a CSV representation of both the OUT and the INOUT parameters.
What do I have to do to make it so?
TIA
Mike
В списке pgsql-sql по дате отправления: