proc giving mysterious results

392 Views Asked by At

So I have a proc that someone else wrote that has code like the following:

if 1 = 0
begin
    select 
        cast(null as int) as case_id,
        cast(null as int) as review_id, 
end
      --then a real select statement happens that matches the same pattern.

Now, HP exstream is somehow reading the top select statement when it executes the stored proc, even though it should never be called. If I add columns to the real result query without adding as empty column to this hidden query, it will not work (in HP exstream, in SQL server, the proc runs as one would expect).

Anyone have any idea on how this could be working? how could HP Exstream be reading this non executing code?

1

There are 1 best solutions below

0
Bob from Accounting On

I don't know what code base this is written in, but I assume it is in the Dialogue script. Since the exstream engine is based in C++, my first question is on the syntax of the IF statement.

IF 1 = 0 in C is not the same as IF 1 == 0. The first one determines the truth of the statement based on the success of changing an instance with the value of 1 into an instance with a value of zero. Hence it will always be true. The latter actually compares the two values, which obviously will always be false.

Without knowing more about the situation I would look at that first.