oracle-apex

Is it possible to output a SELECT statement from a PL/SQL block?

﹥>﹥吖頭↗ 提交于 2019-11-26 16:07:34
How can I get a PL/SQL block to output the results of a SELECT statement the same way as if I had done a plain SELECT ? For example how to do a SELECT like: SELECT foo, bar FROM foobar; Hint : BEGIN SELECT foo, bar FROM foobar; END; doesn't work. It depends on what you need the result for. If you are sure that there's going to be only 1 row, use implicit cursor: DECLARE v_foo foobar.foo%TYPE; v_bar foobar.bar%TYPE; BEGIN SELECT foo,bar FROM foobar INTO v_foo, v_bar; -- Print the foo and bar values dbms_output.put_line('foo=' || v_foo || ', bar=' || v_bar); EXCEPTION WHEN NO_DATA_FOUND THEN --

Is it possible to output a SELECT statement from a PL/SQL block?

做~自己de王妃 提交于 2019-11-26 05:56:10
问题 How can I get a PL/SQL block to output the results of a SELECT statement the same way as if I had done a plain SELECT ? For example how to do a SELECT like: SELECT foo, bar FROM foobar; Hint : BEGIN SELECT foo, bar FROM foobar; END; doesn\'t work. 回答1: It depends on what you need the result for. If you are sure that there's going to be only 1 row, use implicit cursor: DECLARE v_foo foobar.foo%TYPE; v_bar foobar.bar%TYPE; BEGIN SELECT foo,bar FROM foobar INTO v_foo, v_bar; -- Print the foo and