Now and then, you will use IN or NOT IN SQL criteria to fetch a row from table in peoplecode. This example will use SQLExec technique.
Let say you have a string of values like this: 'A','B','C'. You want to use insert this string as a parameter in the SQLExec.
Bad Example:
Local string &in_values = "'A','B','C'"; Local string &out_val; SQLExec("Select min(field1) from ps_table_1 Where field1 NOT IN (:1)", &in_values, &out_val);
Good Example:
Local string &in_values = "'A','B','C'"; Local string &sql_cmd; Local string &out_val; &sql_cmd = ("Select min(field1) from ps_table_1 Where field1 NOT IN (" &in_values ")"; SQLExec(&sql_cmd, &out_val);
Result: Good
Happy Coding... :)
No comments:
Post a Comment