pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedis this possible in plpgsql ?
2+ messages / 2 participants
[nested] [flat]
* is this possible in plpgsql ?
@ 2003-06-19 00:38 Marcin Winkler <qurczak@wolomin.biz>
0 siblings, 1 reply; 2+ messages in thread
From: Marcin Winkler @ 2003-06-19 00:38 UTC (permalink / raw)
To: pgsql-sql
I have 1 function in pg 7.3.2.
txt string have 1,2,3,.. and i would like to be similar like if 3 in
(1,2,3..) then, but IF 3 in (''''||txt||'''') THEN doesn't work.
There is possible to this or not ?
CREATE OR REPLACE FUNCTION rek2(INT8) RETURNS text AS '
DECLARE
i INT8;
BEGIN
txt := '''';
for i in 1 .. 10 loop
txt := txt||i||'','';
END loop;
txt := txt||''0'';
IF 3 in (''''||txt||'''') THEN
raise notice ''yep'';
END IF;
RETURN txt;
END;
' LANGUAGE 'plpgsql';
--
"Nieobecni nie majÄ… racji"
Marcin Winkler
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: is this possible in plpgsql ?
@ 2003-06-19 18:23 Richard Huxton <dev@archonet.com>
parent: Marcin Winkler <qurczak@wolomin.biz>
0 siblings, 0 replies; 2+ messages in thread
From: Richard Huxton @ 2003-06-19 18:23 UTC (permalink / raw)
To: Marcin Winkler <qurczak@wolomin.biz>; pgsql-sql
On Thursday 19 Jun 2003 1:38 am, Marcin Winkler wrote:
> I have 1 function in pg 7.3.2.
>
> txt string have 1,2,3,.. and i would like to be similar like if 3 in
> (1,2,3..) then, but IF 3 in (''''||txt||'''') THEN doesn't work.
> There is possible to this or not ?
> txt := '''';
> for i in 1 .. 10 loop
> txt := txt||i||'','';
> END loop;
> txt := txt||''0'';
> IF 3 in (''''||txt||'''') THEN
> raise notice ''yep'';
Try something like:
query:=''SELECT 3 in ('' || txt || '')''
EXECUTE query;
Then check the result for true/false
--
Richard Huxton
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2003-06-19 18:23 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-06-19 00:38 is this possible in plpgsql ? Marcin Winkler <qurczak@wolomin.biz>
2003-06-19 18:23 ` Richard Huxton <dev@archonet.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox