PQexecParams question

Started by Grzegorz Jaśkiewiczover 17 years ago6 messagesgeneral
Jump to latest
#1Grzegorz Jaśkiewicz
gryzman@gmail.com

Hey folks,
I have here piece of code, that I wrote some time ago - works fine, but I
was wondering - if it can be improved.
This is used to grab id list, not present on submited list. Query usually
looks like that;
select id from foo where id not in ($1, $2, $3...);

and I was wondering, is it possible to call PQexecParams with query, that
doesn't have a longish list of dollar params (in my case up to 200), but
instead uses some other syntax, such as:
select id from foo where id not in ($1...$200);

If not, to guys hacking libpq and area, would it be possible to request such
a nice and neat feature ?

ta

--
GJ

#2Pavel Stehule
pavel.stehule@gmail.com
In reply to: Grzegorz Jaśkiewicz (#1)
Re: PQexecParams question

2008/10/11 Grzegorz Jaśkiewicz <gryzman@gmail.com>:

Hey folks,
I have here piece of code, that I wrote some time ago - works fine, but I
was wondering - if it can be improved.
This is used to grab id list, not present on submited list. Query usually
looks like that;
select id from foo where id not in ($1, $2, $3...);
and I was wondering, is it possible to call PQexecParams with query, that
doesn't have a longish list of dollar params (in my case up to 200), but
instead uses some other syntax, such as:
select id from foo where id not in ($1...$200);
If not, to guys hacking libpq and area, would it be possible to request such
a nice and neat feature ?

why you don't use array?

regards
Pavel Stehule

Show quoted text

ta

--
GJ

#3Grzegorz Jaśkiewicz
gryzman@gmail.com
In reply to: Pavel Stehule (#2)
Re: PQexecParams question

I don't see that working using arrays here. Can you elaborate please ?

#4Pavel Stehule
pavel.stehule@gmail.com
In reply to: Grzegorz Jaśkiewicz (#3)
Re: PQexecParams question

Hello

2008/10/12 Grzegorz Jaśkiewicz <gryzman@gmail.com>:

I don't see that working using arrays here. Can you elaborate please ?

select * from foo where a = any ($1)

postgres=# select 1 = any(array[1,2,3]);
?column?
----------
t
(1 row)

regards
Pavel Stehule

#5Grzegorz Jaśkiewicz
gryzman@gmail.com
In reply to: Pavel Stehule (#4)
Re: PQexecParams question

that would be a type mismatch, heh.

#6Bruce Momjian
bruce@momjian.us
In reply to: Grzegorz Jaśkiewicz (#5)
Re: PQexecParams question

"Grzegorz Jaśkiewicz" <gryzman@gmail.com> writes:

that would be a type mismatch, heh.

prepare "select * from foo where a = any($1::int[])"

then pass "{1,2,3}"

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Get trained by Bruce Momjian - ask me about EnterpriseDB's PostgreSQL training!