0

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?

Limey
  • 2,642
  • 6
  • 37
  • 62
  • First, the code (as you have written it) has a syntax error (the last comma). Second, how do you know it is running? Presumably, the rest of the code could be producing a line with `NULL` values. – Gordon Linoff Nov 04 '14 at 20:32
  • The comma was just a left over (didn't want to make everyone read thru all the records) We know HP is reading it because it will have issues pulling the data from the proc if all the columns that are in the result query are not also in the null one. – Limey Nov 04 '14 at 20:51

1 Answers1

0

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.