Re: [SQL] Inserting an IF statement in the middle of a SELECT in pl/pgSQL code

2007-07-18 Thread Jaime Casanova
sorry, i resubmit to the list On 7/18/07, Jaime Casanova <[EMAIL PROTECTED]> wrote: On 7/18/07, Norm Garand <[EMAIL PROTECTED]> wrote: > Thanks Jaime: > > I tried using the CASE function and it still didn't work. > > What I need to do is set a conditional, so that if the parameter is NULL, then

Re: [SQL] Inserting an IF statement in the middle of a SELECT in pl/pgSQL code

2007-07-18 Thread Fernando Hevia
007 23:43 Para: pgsql-sql@postgresql.org Asunto: [SQL] Inserting an IF statement in the middle of a SELECT in pl/pgSQL code Hi: I can't seem to resolve this issue. I have a fair sized SELECT statement that runs properly in a stored procedure using pl/pgSQL, but I have certain parts of the quer

Re: [SQL] Inserting an IF statement in the middle of a SELECT in pl/pgSQL code

2007-07-17 Thread Jaime Casanova
On 7/17/07, Norm Garand <[EMAIL PROTECTED]> wrote: In the WHERE portion of the SELECT statment, I'd like to insert the IF statement shown below. I've tried single and double quotes and the pipeline for concatenation, but nothing seems to work. Any suggestions or resolutions would be greatly app

Re: [SQL] Inserting an IF statement in the middle of a SELECT in pl/pgSQL code

2007-07-17 Thread Rodrigo De León
On 7/17/07, Norm Garand <[EMAIL PROTECTED]> wrote: /--- IF $7 IS NOT NULL THEN AND f.id = pid.specific_location_cid AND f.long_desc = $7 END IF ---/ How about: AND f.ID = pid.specific_location_cid AND f.long_desc = COALESCE ($7, f.long_desc) ---

[SQL] Inserting an IF statement in the middle of a SELECT in pl/pgSQL code

2007-07-17 Thread Norm Garand
Hi: I can't seem to resolve this issue. I have a fair sized SELECT statement that runs properly in a stored procedure using pl/pgSQL, but I have certain parts of the query that can filter by a NULL value, or a character string. What I can't seem to do is insert a conditional IF statement in my c