Re: Simple question about running a function.
От | SQL Padawan |
---|---|
Тема | Re: Simple question about running a function. |
Дата | |
Msg-id | I_azqsn6cR13UFT5V7_Q8SYvAMXs71wWZ_GvVQnTEEuNk2ilyPNKUbJsbKAaLXLindkisjBr2-7Ed1kfKsIubulp-HQCNXnRiltQiTS9rXk=@protonmail.com обсуждение исходный текст |
Ответ на | Simple question about running a function. (SQL Padawan <sql_padawan@protonmail.com>) |
Ответы |
Re: Simple question about running a function.
|
Список | pgsql-novice |
What is even more puzzling is that this function works no problem: create or replace function test_fn_3() returns VOID as $$ DECLARE BEGIN FOR r IN 1..10000 LOOP INSERT INTO tab VALUES (100); END LOOP; END; $$ LANGUAGE plpgsql; but this one fails: create or replace function test_fn_4() returns VOID as $$ DECLARE BEGIN FOR r IN 1..10000 LOOP SELECT ('A string'); END LOOP; END; $$ LANGUAGE plpgsql; It's something to do with output - SELECT obviously returns something, whereas INSERT doesn't - but that's not strictly true.It returns success or failure? SELECT test_fn_5() fails: create or replace function test_fn_5() returns VOID as $$ DECLARE BEGIN FOR r IN 1..10000 LOOP INSERT INTO tab VALUES (100) RETURNING *; END LOOP; END; $$ LANGUAGE plpgsql; because of the RETURNING *! So, it's something to do with output/returned data? How do I tell psql/PL/pgSQL that I want to suppress the output for the test? Trying to run DO $$ BEGIN SELECT 'blah'; END; $$; from the command line also fails with the ERROR: query has no destination for result data I'd really like to understand what's going on? SQLP! > SQLP!
В списке pgsql-novice по дате отправления: