为什么在存储过程中 SQL语句在游标外不能执行 ;应该在什么地方执行 ,求解。
BEGIN
#Routine body goes here...
DECLARE _DeviceId INT;
DECLARE rs_cursor CURSOR FOR SELECT DeviceId FROM gprs_mana.devicemanager WHERE gprs_mana.devicemanager.UserId=ceshishuchu;DELETE FROM gprs_mana.userinfo WHERE gprs_mana.userinfo.UserId=ceshishuchu;open rs_cursor; cursor_loop:loopFETCH rs_cursor into _DeviceId; DELETE FROM gprs_mana.deviceinfo WHERE gprs_mana.deviceinfo.DeviceId=_DeviceId;end loop cursor_loop;close rs_cursor;
DELETE FROM gprs_mana.devicemanager WHERE gprs_mana.devicemanager.UserId=ceshishuchu;ENDceshishuchu 为输入参数 ;还有就是应该如何输出一个返回值 ; 我使用navicat 写的 我要用php来调用 如何在php中接收到存储函数输出的返回值呢?
BEGIN
#Routine body goes here...
DECLARE _DeviceId INT;
DECLARE rs_cursor CURSOR FOR SELECT DeviceId FROM gprs_mana.devicemanager WHERE gprs_mana.devicemanager.UserId=ceshishuchu;DELETE FROM gprs_mana.userinfo WHERE gprs_mana.userinfo.UserId=ceshishuchu;open rs_cursor; cursor_loop:loopFETCH rs_cursor into _DeviceId; DELETE FROM gprs_mana.deviceinfo WHERE gprs_mana.deviceinfo.DeviceId=_DeviceId;end loop cursor_loop;close rs_cursor;
DELETE FROM gprs_mana.devicemanager WHERE gprs_mana.devicemanager.UserId=ceshishuchu;ENDceshishuchu 为输入参数 ;还有就是应该如何输出一个返回值 ; 我使用navicat 写的 我要用php来调用 如何在php中接收到存储函数输出的返回值呢?
参考:
<?
define ( "OLEDB_CONNECTION_STRING ",
"Provider=SQLOLEDB; Data Source=zzb; Initial Catalog=Northwind; User ID=sa; Password= ");
$dbc = new COM( "ADODB.Connection ");
$dbc-> Open(OLEDB_CONNECTION_STRING);
$command = "sp_mystoreprocedure ";
$rs = $dbc-> Execute($command);
...