SQL Syntax error [message #2212] |
Wed, 15 July 2009 19:15 |
gpatti
Messages: 283 Registered: August 2008
|
Senior Member |
|
|
Tony,
I've managed to generate a SQL syntax error through use of $selections in a where clause. I think there is a bracket missing in the generated SQL.
The sequence of events is:
1. I am starting with a LIST2 transaction and selecting some rows
2. I call a 'dummy' ADD2 transaction so that I can select some additional criteria before using scriptNext() in _cm_pre_insertRecord to call an output task.
This works fine if I select 0 rows or 1 row (giving me output for all rows matching the additonal criteria or the single row I have selected. However, if I select more than one row I get a SQL syntax error.
The call is scriptNext($next_task, $where) with
$where = "crf_type.crf_type_id = '$crf_type_id' AND $selections";
However this generates the following SQL WHERE clause:
WHERE (exam.exam_id='6646' AND exam.rdcaccount_id='7' ) OR ( exam.exam_id='6647' AND exam.rdcaccount_id='7' )) AND crf_type.crf_type_id='T' )
I think there should be a double opening bracket after the WHERE keyword to match the double closing bracket surrounding the $selections criteria that is grouped with the OR clause.
Let me know if you need further information to assist with this.
Thanks,
Graham
|
|
|