Dynamic SQL in SQL/PSM samples
Skočit na navigaci
Skočit na vyhledávání
EXECUTE IMMEDIATE INTO
CREATE OR REPLACE FUNCTION fx() RETURNS int AS $$ BEGIN DECLARE a,b int; EXECUTE IMMEDIATE 'SELECT 10,20' INTO a,b; PRINT a,b; RETURN a+b; END; $$ LANGUAGE plpgpsm;
PREPARE/EXECUTE INTO USING
CREATE OR REPLACE FUNCTION fxx(a int) RETURNS float AS $$ BEGIN DECLARE f float; PREPARE prep(float) from 'select $1'; EXECUTE prep INTO f USING a; RETURN f ; END; $$ LANGUAGE plpgpsm;