我有一些插入語句,如下面顯示的那樣,我嘗試在一個大塊中運行。有無論如何,我告訴查詢跳過該特定的插入語句,並繼續在其中一個選擇語句的列表返回null?如果沒有發現結果,sql跳過插入語句
insert into V1144engine.T_edges(edge_id, version, node1_id, node2_id, edge_type_id, created_at, weight,deleted_at) VALUES(V1144ENGINE.S_PK_EDGES.NEXTVAL,0,(Select node_id from V1144engine.T_nodes where node_name = 'Writing an Equation of a Perpendicular Line' and rownum=1),(select node_id from V1144engine.T_nodes where node_name = 'slope'and node_type_id =11),5,SYSDATE,5.318,null);
insert into V1144engine.T_edges(edge_id, version, node1_id, node2_id, edge_type_id, created_at, weight,deleted_at) VALUES(V1144ENGINE.S_PK_EDGES.NEXTVAL,0,(Select node_id from V1144engine.T_nodes where node_name = 'Writing an Equation of a Perpendicular Line' and rownum=1),(select node_id from V1144engine.T_nodes where node_name = 'vertic'and node_type_id =11),5,SYSDATE,5,null);
當你說一個大的塊,你的意思只是一堆單一的INSERT語句?如果這是一個PL/SQL過程,你可以使用'IF'語句和光標循環(如果這些將適用/有幫助) – Dan 2012-07-25 19:08:24
是的,我的意思是一堆單插入語句,但它不會作爲PL/SQL過程運行,感謝您的建議,儘管 – 2012-07-25 19:12:38
您使用什麼程序來執行SQL語句?在SQL * Plus? SQL Developer?還有別的嗎?如果你不使用PL/SQL塊,該應用程序將控制一個語句失敗時發生的情況。默認的SQL * Plus和SQL Developer的行爲將會繼續下一個聲明,這聽起來像是你想要的行爲。 – 2012-07-25 19:38:25