Community
Participate
Working Groups
The following OPEN statement has compilation error: open rs from ds for basicRec using(basicRec.rid) with #sql{ select rid, rtrim(orderItem), price from Basic where rid = ? order by rid asc }; The FOR clause is not allowed if the WITH clause is specified
This is working correctly. Check out comment 17 from bug 360021: Open_statement ::= open sql_statement_expr [from data_source_expr] [using_clause] [with_clause | for_clause]; You can have WITH or FOR but not both.
I do think they can co-exist, please refer to the example I pasted, which part you think you can remove?
please refer to bug 361828
Validation is working according to the spec. If you would like the spec to be enhanced to allow both FOR and WITH clauses on an OPEN statement, you should speak with Tim and Joe. Generation would probably also need to be updated, not just validation. If you get agreement that it should be supported, then you can re-open this and I will remove the check.
It doesn't make sense for a FOR and a WITH to coexist, the purpose of the FOR is to generate the default SQL, if there is a with SQL is provided so there is no need for deafult SQL. In an email Tim said "FOR only makes sense when there is no with clause and default SQL needs to be created based on what is in the FOR"
Please refer to the example I pasted, if I deleted 'for basicRec' after pressing CTRL+1; but the using clause if referring to basicRec from FOR clause; what's your opinion for default sql for: open rs from ds for basicRec Should: select rid, rtrim(orderItem), price from Basic where rid = ? order by rid asc be okay? if it is okay, then how do you passing specified value for the WHERE clause?
I'm not sure I follow your question. You can still use the USING clause with the FOR clause. You can also use the USING clause with the WITH clause.
close it