From: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: can i use a string in where clause such as "id in (str)" |
Date: | 2006-06-12 05:01:53 |
Message-ID: | 20060612050153.GA30300@webserv.wug-glas.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
am 12.06.2006, um 0:05:07 +0300 mailte Yavuz Kavus folgendes:
> hi every body.
> i have a pl/pgsql function (i want to form it to run correctly) :
>
> CREATE OR REPLACE FUNCTION "public"."ftest" () RETURNS boolean AS
> $body$
> declare
> f boolean;
> str varchar(100);
> begin
> str := '1,5,10';
> if exists( select 1 from tb_categories where cat_id in ( str ) )
> ...
>
> how can i achive this, are there any solutions?
Please read our documentation about executing dynamic querys:
http://www.postgresql.org/docs/8.1/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN
Hint: you should build a string with your complete SQL command and
EXECUTE this string.
HTH, Andreas
--
Andreas Kretschmer (Kontakt: siehe Header)
Heynitz: 035242/47215, D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
=== Schollglas Unternehmensgruppe ===
From | Date | Subject | |
---|---|---|---|
Next Message | John Tregea | 2006-06-12 06:18:19 | Help with storing spatial (map coordinates) data? |
Previous Message | Patrick TJ McPhee | 2006-06-12 04:37:36 | Re: are there static variables in pgsql? |