Skip site navigation (1) Skip section navigation (2)

Re: Using a variable in sql in a function

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Using a variable in sql in a function
Date: 2010-01-05 14:53:50
Message-ID: 20100105145350.GC16421@a-kretschmer.de (view raw or flat)
Thread:
Lists: pgsql-novice
In response to Peter Jackson :
> Hiya list,
> 
> I was wondering if this is possible or not. If yes how?
> 
> I want to use a changing where condition on the query, subject to the 
> value I pass in to the function. I have tried the below but it fails in 
> use. This is with PostgreSql 8.3.1.

You can do that, but you need to build a complete string containing your
full query and execute this string.

http://www.postgresql.org/docs/current/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN


Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431  2EB0 389D 1DC2 3172 0C99

In response to

pgsql-novice by date

Next:From: Greg StarkDate: 2010-01-05 15:05:19
Subject: Re: to find table stats for last update time.
Previous:From: Peter JacksonDate: 2010-01-05 13:56:30
Subject: Using a variable in sql in a function

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group