[prev in list] [next in list] [prev in thread] [next in thread]
List: postgresql-general
Subject: [GENERAL] Help with case in select
From: "Cristian Prieto" <cristian () clickdiario ! com>
Date: 2005-03-31 22:26:08
Message-ID: 002501c53640$a6e2dea0$6e00a8c0 () gt ! ClickDiario ! local
[Download RAW message or body]
Hello, I have the following sp, I need to return a 'Flag' if the ID of the
row is in the prior select, I tryed with the following code:
create or replace function sp_getadvertisers(ag integer) returns record as
$main$
declare
alladv record;
retrec record;
begin
-- Primero buscamos todas las campanas de este advertiser q sean hijos
select into alladv userid from advertiser where agenciaid=ag and adv_parent
is not null;
select into retrec userid, case when userid in alladv then 'P' when
adv_parent is not null then 'S' else null end from advertiser where
agenciaid=ag;
return retrec;
end;
$main$
language plpgsql;
But it returns me:
ERROR: syntax error at or near "$1" at character 38
QUERY: SELECT userid, case when userid in $1 then 'P' when adv_parent is
not null then 'S' else null end from advertiser where agenciaid= $2
CONTEXT: PL/pgSQL function "sp_getadvertisers" line 7 at select into
variables
LINE 1: SELECT userid, case when userid in $1 then 'P' when adv_p...
Any Idea how could I change it to work? ideas???
Thanks a lot...
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic