snippetsqlModerate
How to print to console in SQL?
Viewed 0 times
sqlconsoleprinthow
Problem
I'm using
If I use
If I use
but how do I print when the function is pure
using
I want something like
if it was a plpgsql I would do:
I'm looking for the equivalent in
PostgreSQL And I want to print a message to the console.If I use
plpythonu I use plpy.noticeIf I use
plpgsql I use raise noticebut how do I print when the function is pure
SQL?using
SELECT 'string' isn't helping me as it print the string in a column and if the message is located in the middle of the code it doesn't show it.I want something like
raise notice / plpy.notice for SQL.CREATE OR REPLACE FUNCTION A()
RETURNS VOID AS
$BODY$
how do i print 'hello world' here?
$BODY$
LANGUAGE sql VOLATILEif it was a plpgsql I would do:
CREATE OR REPLACE FUNCTION A()
RETURNS VOID AS
$BODY$
Raise Notice 'hello world'
$BODY$
LANGUAGE plpgsql VOLATILEI'm looking for the equivalent in
LANGUAGE SQLSolution
With
outputs:
psql you could \echo text (or \qecho if using \o), for example executing with psql -f a file with contents:select 'Straight';
\echo BETWEEN
select 'the lines.';outputs:
?column?
----------
Straight
(1 row)
BETWEEN
?column?
------------
the lines.
(1 row)Code Snippets
select 'Straight';
\echo BETWEEN
select 'the lines.';?column?
----------
Straight
(1 row)
BETWEEN
?column?
------------
the lines.
(1 row)Context
StackExchange Database Administrators Q#106144, answer score: 19
Revisions (0)
No revisions yet.