WEB开发网
开发学院数据库DB2 在 DB2 SQL 存储过程中使用 XML 阅读

在 DB2 SQL 存储过程中使用 XML

 2009-11-23 00:00:00 来源:WEB开发网   
核心提示: CREATEPROCEDUREex_proc(INinpdocXML)LANGUAGESQLNOEXTERNALACTIONBEGINIFXMLEXISTS('$d/request[@action="add"]'PASSINGinpdocAS"d&q

CREATE PROCEDURE ex_proc(IN inpdoc XML) 
LANGUAGE SQL 
NO EXTERNAL ACTION 
BEGIN 
 
 IF XMLEXISTS('$d/request[@action="add"]' PASSING inpdoc AS "d") THEN 
  SIGNAL SQLSTATE '75002' SET MESSAGE_TEXT = 'F(x) add'; 
 ELSEIF XMLEXISTS('$d/request[@action="update"]' PASSING inpdoc AS "d") THEN 
  SIGNAL SQLSTATE '75002' SET MESSAGE_TEXT = 'F(x) update'; 
 ELSE 
  SIGNAL SQLSTATE '75002' SET MESSAGE_TEXT = 'F(x) invalid'; 
 END IF; 
 
END 


清单 17. IF/THEN/ELSE,输入值(1)

<request action="add"> 
 <name>Jean Luc Picard</name> 
</request> 
 
Output: 
 SQL0438N Application raised error with diagnostic text: "F(x) add".  
 SQLSTATE=75002 




清单 18. IF/THEN/ELSE,输入值(2)

<request action="update"> 
 <name>Jean Luc Picard</name> 
</request> 
 
Output: 
 SQL0438N Application raised error with diagnostic text: "F(x) update".  
 SQLSTATE=75002 




清单 19. IF/THEN/ELSE,输入值(3)

<request action="delete"> 
 <name>Jean Luc Picard</name> 
</request> 
 
Output: 
 SQL0438N Application raised error with diagnostic text: "F(x) invalid".  
 SQLSTATE=75002 

上一页  4 5 6 7 8 9 10  下一页

Tags:DB SQL 存储

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接