Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 354589

Summary: Binding LongArrayHolder in SQL NOT IN Clause causes packet errors
Product: z_Archived Reporter: Oli Schmid <oliver.schmid>
Component: ScoutAssignee: Project Inbox <scout.core-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: minor    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Oli Schmid CLA 2011-08-12 04:39:43 EDT
When using a LongArrayHolder as bind in SQL.select the SQL service is generating corrupt SQL.

Reproducible: Always

Steps to Reproduce:
Use the following sample code somewhere on a server side service.

LongArrayHolder uids = new LongArrayHolder();

	SQL.selectInto(
		"SELECT 1 FROM DUAL " +
	  "UNION " +
	  "SELECT 2 FROM DUAL " +
	  "INTO :uids "
	  , new NVPair("uids", uids)
	);
	
	SQL.select(
		"SELECT 'works' FROM DUAL " +
		"WHERE 1 NOT IN (:uids) " +
	  , new NVPair("uids", uids)
	);

When having only one or no value in the LongArrayHolder the SQL call works well.

	LongArrayHolder uids = new LongArrayHolder();
	
	SQL.selectInto(
		"SELECT 1 FROM DUAL " +
	  "INTO :uids "
	  , new NVPair("uids", uids)
	);
	
	SQL.select(
		"SELECT 'works' FROM DUAL " +
		"WHERE 1 NOT IN (:uids) " +
	  , new NVPair("uids", uids)
	);
	
Two working workarounds are the use of folloing statments:

	SQL.select(
		"SELECT 'works' FROM DUAL " +
		"WHERE 1 NOT IN :uids " +
	  , new NVPair("uids", uids)
	);
	
or

	SQL.select(
		"SELECT 'works' FROM DUAL " +
		"WHERE 1 <> :uids " +
	  , new NVPair("uids", uids)
	);	

In terms of SQL the two workarounds are syntactically wrong.
Comment 1 Matthias Zimmermann CLA 2017-06-06 05:51:45 EDT
Closed. The bug is over 5 years old and does no longer seem relevant/important enough. In case you do not agree with closing it, reopen the bug and present your case (again), thanks.