本文介绍了Java与Oracle Merge的准备语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我准备了一个使用Merge的Oracle SQL查询。但是,当我尝试使用Java的Prepared Statements时,我收到以下错误。
I have prepared an SQL Query for Oracle that uses Merge. However, when I try to use Java's Prepared Statements, I get the following error.
java.sql.SQLSyntaxErrorException: ORA-00928: missing SELECT keyword
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:395)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:802)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:436)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:521)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:205)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1008)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1307)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3449)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3550)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1374)
at ke.co.smart.MemberResponse.memberUpdater(MemberResponse.java:267)
at ke.co.smart.MemberResponse.<init>(MemberResponse.java:184)
at ke.co.smart.Switch.serviceProcessor(Switch.java:181)
at ke.co.smart.Switch.run(Switch.java:359)
以下是SQL Stat我已准备好执行。
Below is the SQL Statement that I have prepared for execution.
String sql = "MERGE INTO smart.tmp_switch_membership dest USING (SELECT"
+ membershipNumber + " member," + prevMembershipNumber + "," + schemeCode
+ "," + schemePlan + "," + memberPlan + "," + primaryCareProvider
+ "," + employeeNumber + "," + employerCode + "," + employerDesc
+ "," + brokerCode + "," + brokerDesc + "," + numberOfBeneficiaries
+ " FROM DUAL) src ON src.member = dest.membership_number"
+ "WHEN NOT MATCHED THEN"
+ "INSERT(membership_number, prev_member_number, scheme_code,"
+ "scheme_plan, member_plan, primary_care_prov, correspondence_ind,"
+ "employee_number, employer_code, employer_desc, broker_agent_code,"
+ "broker_agent_desc, beneficiary_count)"
+ "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
PreparedStatement ps = con.prepareStatement(sql);
ps.setString(1, membershipNumber);
ps.setString(2, prevMembershipNumber);
ps.setString(3, schemeCode);
ps.setString(4, schemePlan);
ps.setString(5, memberPlan);
ps.setString(6, primaryCareProvider);
ps.setString(7, employeeNumber);
ps.setString(8, employerCode);
ps.setString(9, employerDesc);
ps.setString(10, brokerCode);
ps.setString(11, brokerDesc);
ps.setInt(12, numberOfBeneficiaries.intValue());
ps.execute();
con.commit();
ps.close();
我们将不胜感激任何帮助。
Any help accorded will be appreciated.
推荐答案
这篇关于Java与Oracle Merge的准备语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!