[prev in list] [next in list] [prev in thread] [next in thread]
List: postgresql-general
Subject: Re: echo work alike in SQL
From: Pavel Stehule <pavel.stehule () gmail ! com>
Date: 2019-08-31 16:35:05
Message-ID: CAFj8pRB+DY=nqdRDPsdns47kTq+Qt_t0vG=CavovSyGHZqjMEA () mail ! gmail ! com
[Download RAW message or body]
Hi
so 31. 8. 2019 v 17:46 odes=C3=ADlatel stan <stanb@panix.com> napsal:
> Just started using the RAISE functionality to help in debugging.
>
> Tried to add it to an SQL script, only to realize it is a PLPGSQL
> extension.
>
> Is there a way to get a string to appear in the output f an SQL script?
>
> Can I do some sort of select?
>
if you run SQL script from psql, then you can use \echo
https://www.postgresql.org/docs/current/app-psql.html
elsewhere you should to use SELECT
or you can use own function
CREATE OR REPLACE FUNCTION public.debug_text(text)
RETURNS text
LANGUAGE plpgsql
AS $function$
BEGIN
RAISE NOTICE '%', $1;
RETURN $1;
END;
$function$
Regards
Pavel
>
> --
> "They that would give up essential liberty for temporary safety deserve
> neither liberty nor safety."
> -- Benjamin Franklin
>
>
>
[Attachment #3 (text/html)]
<div dir="ltr"><div>Hi<br></div><br><div class="gmail_quote"><div dir="ltr" \
class="gmail_attr">so 31. 8. 2019 v 17:46 odesÃlatel stan <<a \
href="mailto:stanb@panix.com">stanb@panix.com</a>> napsal:<br></div><blockquote \
class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex">Just started using the RAISE functionality to help \
in debugging.<br> <br>
Tried to add it to an SQL script, only to realize it is a PLPGSQL extension.<br>
<br>
Is there a way to get a string to appear in the output f an SQL script?<br>
<br>
Can I do some sort of select?<br></blockquote><div><br></div><div>if you run SQL \
script from psql, then you can use \echo</div><div><br></div><div><a \
href="https://www.postgresql.org/docs/current/app-psql.html">https://www.postgresql.org/docs/current/app-psql.html</a></div><div><br></div><div>elsewhere \
you should to use SELECT</div><div><br></div><div>or you can use own \
function</div><div><br></div><div>CREATE OR REPLACE FUNCTION \
public.debug_text(text)<br> RETURNS text<br> LANGUAGE plpgsql<br>AS \
$function$<br>BEGIN<br> RAISE NOTICE '%', $1;<br> RETURN \
$1;<br>END;<br>$function$</div><div><br></div><div>Regards</div><div><br></div><div>Pavel<br></div><div> \
</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px \
solid rgb(204,204,204);padding-left:1ex"> <br>
-- <br>
"They that would give up essential liberty for temporary safety deserve<br>
neither liberty nor safety."<br>
-- Benjamin \
Franklin<br> <br>
<br>
</blockquote></div></div>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic