[ic] if-sql-param question

jeff at hisgirlfridays.com jeff at hisgirlfridays.com
Mon Jun 13 14:14:29 EDT 2005


On Fri, Jun 10, 2005 at 04:54:47PM -0400, Ethan Rowe wrote:

> >>The issue I am encountering is that sql-param food is not equal to 
> >>'steak', but myscratch is still being set to bad, however, "hello" is 
> >>never output.  This is just plain weird to me and usually when ITL acts 
> >>weird it is because I am doing something syntactically incorrect.

> On the contrary, [if-sql-param <some_column> <some_operator> 
> <some_value>] is valid syntax.  For instance:

Thank you very much for your assistance.  After pruning my code down to 
a test case similar to yours (which worked fine for me, obviously), I 
discovered I was misunderstanding the context of the interpolate=1 
parameter in my query tag.  I was thinking (barely, it would seem) that 
it was necessary to add the parameter in order to get [item-code] to 
interpolate in my sql parameter of the query tag.  However, what I 
suspect was actually happening is it was causing the entire contents of 
the query block to be interpolated ahead of time, which was causing some 
sort of out-of-order interpolation relating to [tmp] tags inside of [if] 
blocks.  Removing the interpolate=1 caused the code to be executed in 
the expected order.

For academic purposes, you can see this firsthand with:

[query
 list=1
 interpolate=1
 sql=|
 SELECT 'one'::TEXT AS pooh
 UNION SELECT 'two'::TEXT AS pooh|]
[sql-param pooh]<br>
[if-sql-param pooh eq one]
        [tmp myscratch]label one[/tmp]
[/if-sql-param]
[if-sql-param pooh eq two]
        [tmp myscratch]label two[/tmp]
[/if-sql-param]
[scratch myscratch]<br>
[/query]

Which outputs:

one
label two
two
label two

I now think I remember reading something when I first started working
with IC about stuff like this happening if one wasn't careful with the
interpolate parameter.

Thanks again,
Jeff


More information about the interchange-users mailing list