sc_lookup and what's happen in other macros?

I notice this issue… any suggestion?

this command in version 5 works in version 6 doesn’t works!!!:
$str_where = " WHERE field1=’". [v_test] . "’ "; // test is a global var
sc_lookup(rs, “SELECT field1, field2 FROM code”. $str_where . “ORDER BY field2”);

I must use:
$str_where = " WHERE field1=’" . [v_test] . "’ ";
$str_sql = “SELECT field1, field2 FROM code”. $str_where . “ORDER BY field2”;
sc_lookup(rs, $str_sql);

In version 6 in a macro couldn’t build an sql string dynamically.
That seems to be one step back from 6 to 5 or is a bug.

Re: sc_lookup and what’s happen in other macros?

Don’t know, but I would bet $$$$ there is something like a quote or special char in that variable $str_where, which is messing up in your original. Doing it the second way makes for a more understandable code, as well as easier to test.
Peace

Re: sc_lookup and what’s happen in other macros?

Hi Andrea,

OK, I did my own test and I verified that this causes the macro to not crash BUT not return the correct data. Here is my test:

sc_lookup(my_data, "select id, name, color from status where id = '".$the_status_id."' ");

If I do this it works:

$the_sql = "select id, name, color from status where id = '".$the_status_id."' ";
sc_lookup(my_data, $the_sql);

All I did differently was to place the select string in a string variable the second time.

Did you open a ticket on this? I am not sure they check every forum post for bugs. Please atleast post this link to this post. As a reproducible error.
Peace,
Jamie