Lists: | PostgreSQL : PostgreSQL 메일 링리스트 : 2009-08-21 이후 PGSQL 토토 사이트 추천 08:41 |
---|
From: | "" <94487509(at)qq(dot)com> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | BUG #5001: can not prepare for where $1 is null |
Date: | 2009-08-21 08:41:18 |
Message-ID: | 200908210841.n7L8fIQq083062@wwwmaster.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | PostgreSQL : PostgreSQL 메일 링리스트 : 2009-08-21 이후 PGSQL 토토 사이트 추천 08:41 |
The following bug has been logged online:
Bug reference: 5001
Logged by:
Email address: 94487509(at)qq(dot)com
PostgreSQL version: 8.3.3
Operating system: linux
Description: can not prepare for where $1 is null
Details:
why can not prepare like this? thanks!
prepare ssss as select * from test where $1 is null;
ERROR: could not determine data type of parameter $1
From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | 94487509(at)qq(dot)com |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #5001: can not prepare for where $1 is null |
Date: | 2009-08-21 16:52:06 |
Message-ID: | 162867790908210952j6572e589o1e23fa77aa703316@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | Postg토토 핫SQL : Postg토토 핫SQL 메일 링리스트 : 2009-08-21 이후 PGSQL-BUGS 16:52 |
Hello
2009/8/21 <94487509(at)qq(dot)com>:
>
> The following bug has been logged online:
>
> Bug reference: 5001
> Logged by:
> Email address: 94487509(at)qq(dot)com
> PostgreSQL version: 8.3.3
> Operating system: linux
> Description: can not prepare for where $1 is null
> Details:
>
> why can not prepare like this? thanks!
> prepare ssss as select * from test where $1 is null;
> ERROR: could not determine data type of parameter $1
Probably you are thinking, so first parameter is name of column. But
this is wrong idea. You cannot parametrize column or table names. In
this case - first parameter will be constant expression - with null
value it returns all rows, with not null value - it returns no row.
If you wont to do filter query via some name you have to use dynamic sql:
create or replace function ssss(_name varchar)
returns setof test as $$
declare _r record;
begin
for _r in execute 'select * from test where ' || quote_ident(_name)
|| ' is null'
loop
return next r;
end loop;
return;
end;
$$ language plpgsql;
regards
Pavel Stehule
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
>