{"title":"使用 DP 访问存储过程","inframe":false,"hidden":false,"roles":{"dev":1},"pageLink":"","children":[{"configs":{"description":"在WebBuilder中可以很容易地访问存储过程，既可以通过控件也可以通过脚本来访问存储过程并获取结果，下面举例说明：\n一、访问 Oracle 存储过程\n1、创建游标类型：\nCREATE OR REPLACE PACKAGE TYPES AS\nTYPE X_CURSOR IS REF CURSOR;\nEND;\n\n2、创建存储过程：\nCREATE OR REPLACE PROCEDURE USER_PROC\n(\nP_USER OUT TYPES.X_CURSOR,\nP_NAME IN VARCHAR\n)\nAS\nBEGIN\nOPEN P_USER FOR SELECT * FROM WB_USER WHERE USER_NAME = P_NAME;\nEND USER_PROC;\n\n3、添加DataProvider控件，设置sql属性：\n{call USER_PROC({?@-10.result?},'admin')}\nDataProvider默认获取名称为result的输出参数为结果集\n\n二、访问 SQL Server 存储过程\n1、创建存储过程：\ncreate procedure USER_PROC \n@user_name varchar(50)\nas\nbegin\nselect * from WB_USER where USER_NAME = @user_name\nend\n\n2、添加DataProvider控件，设置sql属性：\n{call USER_PROC('admin')}\n\n三、在ServerScript中也可以使用脚本输出结果集：\napp.output('{call USER_PROC(\"admin\")}');//具体使用说明请参考app.output方法文档\n\n四、其他数据库可根据上述示例参考各自使用手册。","itemId":"module"},"children":[{"configs":{"sql":"select '请参考module description属性说明' as \"DESC\" from WB_DUAL","createColumns":"false","itemId":"dataprovider1"},"children":[],"type":"dataprovider","expanded":false}],"type":"module","expanded":true}],"iconCls":""}