You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by rh...@apache.org on 2014/02/10 17:20:10 UTC
svn commit: r1566673 - in /db/derby/code/trunk/java:
engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java
Author: rhillegas
Date: Mon Feb 10 16:20:10 2014
New Revision: 1566673
URL: http://svn.apache.org/r1566673
Log:
DERBY-3155: Add support for ? parameters to MERGE statements; commit derby-3155-24-aa-supportParameters.diff.
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj?rev=1566673&r1=1566672&r2=1566673&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj Mon Feb 10 16:20:10 2014
@@ -3661,6 +3661,8 @@ mergeStatement() throws StandardExceptio
searchCondition = joinCondition()
matchingClauses = matchingClauseList()
{
+ setUpAndLinkParameters();
+
return new MergeNode
(
targetTable,
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java?rev=1566673&r1=1566672&r2=1566673&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java Mon Feb 10 16:20:10 2014
@@ -74,6 +74,7 @@ public class MergeStatementTest extends
private static final String NO_SUBQUERIES_IN_MATCHED_CLAUSE = "42XAO";
private static final String NO_SYNONYMS_IN_MERGE = "42XAP";
private static final String NO_DCL_IN_MERGE = "42XAQ";
+ private static final String PARAMETER_NOT_SET = "07000";
private static final String[] TRIGGER_HISTORY_COLUMNS = new String[] { "ACTION", "ACTION_VALUE" };
@@ -5176,6 +5177,73 @@ public class MergeStatementTest extends
goodStatement( dboConnection, "drop table t1_036" );
}
+ /**
+ * <p>
+ * Verify that you can use ? parameters in MERGE statements.
+ * </p>
+ */
+ public void test_037_parameters()
+ throws Exception
+ {
+ Connection dboConnection = openUserConnection( TEST_DBO );
+
+ //
+ // create schema
+ //
+ goodStatement
+ (
+ dboConnection,
+ "create table t1_037( x int )"
+ );
+ goodStatement
+ (
+ dboConnection,
+ "create table t2_037( x int )"
+ );
+ goodStatement
+ (
+ dboConnection,
+ "insert into t2_037 values ( 100 ), ( 200 )"
+ );
+
+ //
+ // No verify the setting of a ? parameter.
+ //
+ PreparedStatement ps = chattyPrepare
+ (
+ dboConnection,
+ "merge into t1_037 using t2_037 on ? when not matched then insert values ( t2_037.x )"
+ );
+ try {
+ ps.execute();
+ fail( "Expected statement to raise an error because a parameter isn't set." );
+ }
+ catch (SQLException se)
+ {
+ assertEquals( PARAMETER_NOT_SET, se.getSQLState() );
+ }
+
+ ps.setBoolean( 1, true );
+ ps.execute();
+ assertResults
+ (
+ dboConnection,
+ "select * from t1_037 order by x",
+ new String[][]
+ {
+ { "100" },
+ { "200" },
+ },
+ false
+ );
+
+ //
+ // drop schema
+ //
+ goodStatement( dboConnection, "drop table t2_037" );
+ goodStatement( dboConnection, "drop table t1_037" );
+ }
+
///////////////////////////////////////////////////////////////////////////////////
//
// ROUTINES