Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 362546 - OPEN statement syntax, FOR/USING clauses cannot co-exist
Summary: OPEN statement syntax, FOR/USING clauses cannot co-exist
Status: CLOSED INVALID
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: EDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Justin Spadea CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-01 03:42 EDT by Zhi Zhu CLA
Modified: 2017-02-23 14:17 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zhi Zhu CLA 2011-11-01 03:42:35 EDT
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
Comment 1 Justin Spadea CLA 2011-11-02 09:14:18 EDT
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.
Comment 2 Zhi Zhu CLA 2011-11-02 20:45:23 EDT
I do think they can co-exist, please refer to the example I pasted, which part you think you can remove?
Comment 3 Zhi Zhu CLA 2011-11-02 20:46:13 EDT
please refer to bug 361828
Comment 4 Justin Spadea CLA 2011-11-03 09:39:48 EDT
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.
Comment 5 Joseph Vincens CLA 2011-11-03 10:21:11 EDT
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"
Comment 6 Zhi Zhu CLA 2011-11-03 20:26:28 EDT
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?
Comment 7 Justin Spadea CLA 2011-11-04 10:22:35 EDT
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.
Comment 8 Zhi Zhu CLA 2011-11-08 01:35:57 EST
close it