当前位置: 技术问答>java相关
SQL语句报错,不知如何解决?
来源: 互联网 发布时间:2015-03-06
本文导语: 在WEBLOGIC下,运行SERVLET 报错:ORA-00933:SQL COMMAND NOT PROPERLY ENDED. 代码如下: String sql = "" + "SELECT " + "DEL.NAME DELIVERY" + ",DOC.sequence_number PACKING_SLIP#" + ",CUST_ACCT.CUST_ACCOUNT_ID" + ",HEAD.ORDER_NUMBER ORDER_NUMBER" + ",HEADER.CUST...
在WEBLOGIC下,运行SERVLET 报错:ORA-00933:SQL COMMAND NOT PROPERLY ENDED.
代码如下:
String sql = "" +
"SELECT " +
"DEL.NAME DELIVERY" +
",DOC.sequence_number PACKING_SLIP#" +
",CUST_ACCT.CUST_ACCOUNT_ID" +
",HEAD.ORDER_NUMBER ORDER_NUMBER" +
",HEADER.CUST_PO_NUMBER PO_NUMBER " +
",HEAD.ORDERED_DATE" +
",HEAD.FLOW_STATUS_CODE STATUS" +
",HEAD.TRANSACTIONAL_CURR_CODE CURRENCY" +
",PARTY.PARTY_NAME CUSTOMER_NAME" +
",PARTY.ADDRESS1 ADDRESS" +
",LINE.LINE_NUMBER||'.'||LINE.SHIPMENT_NUMBER LINE_NUMBER" +
",LINE.ORDERED_ITEM " +
",ITEM.DESCRIPTION" +
",LINE.PRICING_QUANTITY" +
",LINE.UNIT_LIST_PRICE" +
",LINE.ORDER_QUANTITY_UOM UOM" +
",LINE.REQUEST_DATE" +
",LINE.ATTRIBUTE1 CUSTOM_NUMBER" +
",LINE.ATTRIBUTE2 SO#" +
",LINE.ATTRIBUTE3 LINE#" +
",LINE.ATTRIBUTE4 PO# " +
"FROM "+
"OE_ORDER_HEADERS_ALL HEAD" +
",OE_ORDER_LINES_ALL LINE" +
",HZ_PARTIES PARTY" +
",HZ_CUST_ACCOUNTS CUST_ACCT" +
",MTL_SYSTEM_ITEMS_B ITEM" +
",wsh_new_deliveries del" +
",wsh_delivery_assignments wda" +
",wsh_delivery_details wdd" +
",wsh_document_instances doc " +
"WHERE " +
"HEAD.HEADER_ID = LINE.HEADER_ID" +
"AND del.delivery_id = wda.delivery_id" +
"AND wda.delivery_detail_id = wdd.delivery_detail_id" +
"AND wdd.source_line_id = LINE.line_id" +
"AND CUST_ACCT.PARTY_ID = PARTY.PARTY_ID" +
"AND CUST_ACCT.CUST_ACCOUNT_ID = HEAD.SOLD_TO_ORG_ID" +
"AND ITEM.INVENTORY_ITEM_ID = LINE.INVENTORY_ITEM_ID" +
"AND doc.entity_id = del.delivery_id";
//"AND doc.entity_name = 'WSH_NEW_DELIVERIES'" +
//"AND doc.document_type = 'PACK_TYPE'" +
//"AND ITEM.ORGANIZATION_ID = '4' ";
try {
Class.forName("weblogic.jdbc.pool.Driver").newInstance();
Connection conn=DriverManager.getConnection("jdbc:weblogic:pool:ERPPROD",null);
Statement stmt=conn.createStatement();
ResultSet RS=stmt.executeQuery(sql);
DATABASE:ORACLE 8.1.6
别的 简单SQL 语句可以执行,这样的长SQL语句却报错,不知为何?
代码如下:
String sql = "" +
"SELECT " +
"DEL.NAME DELIVERY" +
",DOC.sequence_number PACKING_SLIP#" +
",CUST_ACCT.CUST_ACCOUNT_ID" +
",HEAD.ORDER_NUMBER ORDER_NUMBER" +
",HEADER.CUST_PO_NUMBER PO_NUMBER " +
",HEAD.ORDERED_DATE" +
",HEAD.FLOW_STATUS_CODE STATUS" +
",HEAD.TRANSACTIONAL_CURR_CODE CURRENCY" +
",PARTY.PARTY_NAME CUSTOMER_NAME" +
",PARTY.ADDRESS1 ADDRESS" +
",LINE.LINE_NUMBER||'.'||LINE.SHIPMENT_NUMBER LINE_NUMBER" +
",LINE.ORDERED_ITEM " +
",ITEM.DESCRIPTION" +
",LINE.PRICING_QUANTITY" +
",LINE.UNIT_LIST_PRICE" +
",LINE.ORDER_QUANTITY_UOM UOM" +
",LINE.REQUEST_DATE" +
",LINE.ATTRIBUTE1 CUSTOM_NUMBER" +
",LINE.ATTRIBUTE2 SO#" +
",LINE.ATTRIBUTE3 LINE#" +
",LINE.ATTRIBUTE4 PO# " +
"FROM "+
"OE_ORDER_HEADERS_ALL HEAD" +
",OE_ORDER_LINES_ALL LINE" +
",HZ_PARTIES PARTY" +
",HZ_CUST_ACCOUNTS CUST_ACCT" +
",MTL_SYSTEM_ITEMS_B ITEM" +
",wsh_new_deliveries del" +
",wsh_delivery_assignments wda" +
",wsh_delivery_details wdd" +
",wsh_document_instances doc " +
"WHERE " +
"HEAD.HEADER_ID = LINE.HEADER_ID" +
"AND del.delivery_id = wda.delivery_id" +
"AND wda.delivery_detail_id = wdd.delivery_detail_id" +
"AND wdd.source_line_id = LINE.line_id" +
"AND CUST_ACCT.PARTY_ID = PARTY.PARTY_ID" +
"AND CUST_ACCT.CUST_ACCOUNT_ID = HEAD.SOLD_TO_ORG_ID" +
"AND ITEM.INVENTORY_ITEM_ID = LINE.INVENTORY_ITEM_ID" +
"AND doc.entity_id = del.delivery_id";
//"AND doc.entity_name = 'WSH_NEW_DELIVERIES'" +
//"AND doc.document_type = 'PACK_TYPE'" +
//"AND ITEM.ORGANIZATION_ID = '4' ";
try {
Class.forName("weblogic.jdbc.pool.Driver").newInstance();
Connection conn=DriverManager.getConnection("jdbc:weblogic:pool:ERPPROD",null);
Statement stmt=conn.createStatement();
ResultSet RS=stmt.executeQuery(sql);
DATABASE:ORACLE 8.1.6
别的 简单SQL 语句可以执行,这样的长SQL语句却报错,不知为何?
|
AND 前加一个空格
例如 " AND ITEM.INVENTORY_ITEM_ID = LINE.INVENTORY_ITEM_ID" +
例如 " AND ITEM.INVENTORY_ITEM_ID = LINE.INVENTORY_ITEM_ID" +
|
条件之间要有空格!
平常调试时,碰到sql错误,先把该语句输出来,然后到数据库上试一试看看结果对不对,这才是问题的解决之道!
平常调试时,碰到sql错误,先把该语句输出来,然后到数据库上试一试看看结果对不对,这才是问题的解决之道!
|
4242
|
9494
|
好像时空格的事,用print吧sql输出看看,语法对不对