
Originally Posted by
Mike Reed
The difference between the 2 commands is that the built in sql_look-up only gives the first value it finds and only the first column. The function I built gives all values that fit the filter and allows multiple columns.
sql_lookup(conn,table,filter,result_expression,arguments,flagReturnAllValues)
Not so. If you pass in .t. for flagReturnAllValues, you get more than one result. The catch is that you have to specify a filter that is not empty/null, otherwise you get an error. At least, I get an error. This is potentially something I should report to alpha maybe.
Additionally, you can specify multiple columns for the return_expression with commas. EG:
Code:
result = sql_lookup("::Name::conn","my_table","1=1","FIELD_NAME",0,.t.)
'Multi-column
resultMultiColumn = sql_lookup("::Name::conn","my_table","1=1","FIELD_1, FIELD_2, FIELD_3",0,.t.)
sql_lookup returns a crlf() delimited string of records if you get more than one value back. If you have multiple fields, they are separated by spaces.
Bookmarks