Pro*C操作存储过程

 EXEC SQL BEGIN DECLARE SECTION;
  unsigned int nUserID, friendID;
  int    gid, nStartPos, nReqCount;
  VARCHAR db_link_name[32];
  SQL_CURSOR cur_friendlist;
  int   retcode;
EXEC SQL END DECLARE SECTION;

1.  
EXEC SQL ALLOCATE :cur_friendlist;

EXEC SQL AT :db_link_name EXECUTE
        begin
            Mini_User_Pkg.GetFriendsList(:nUserID,:nStartPos,:nReqCount,:cur_friendlist,:retcode);
        end;
END-EXEC;
EXEC SQL FETCH :cur_friendlist INTO :nFriendsid;
EXEC SQL CLOSE :cur_friendlist;
EXEC SQL FREE  :cur_friendlist;
对应的存储过程
  procedure GetFriendsList
  (
       t_userid in Blog_Userfriends.userid%type,
       t_startpos in integer,
       t_reqcount in integer,
       curfriends out T_CURSOR,
       returncode out integer
  )
  is
     t_endpos integer;
     begin
          returncode := 0;
          t_endpos := t_startpos + t_reqcount;
          OPEN curfriends FOR
          SELECT BLOGGERID,GROUPID
        FROM
           ( select rownum as RdNo, BLOGGERID,GROUPID FROM BLOG_USERFRIENDS WHERE USERID=t_userid and rownum <= t_endpos)
        WHERE RdNo > t_startpos and RdNo <= t_endpos;
          EXCEPTION
          when OTHERS then
          begin
              returncode := 1;
              raise;
              return;
          end;
    
     end GetFriendsList;
2.
EXEC SQL AT :db_link_name
   CALL  Mini_User_Pkg.GetUserPwd(:userid,:var_emailaddress,:returncode);

对应的存储过程 :
  procedure GetUserPwd
  (
    t_username in Blog_Userinfo.Username%type,         --用户名
    t_userId out Blog_Userinfo.userId%type,            --用户ID
    t_userpwd out Blog_Userinfo.Servicepasswd%type,     -- 密码
    ReturnCode out integer                            --返回参数,错误代码 0=正常
  )
  is  
    begin
         ReturnCode := 0;
         select userid, servicepasswd into t_userId, t_userpwd
         from blog_userinfo
         where username = t_username;
         EXCEPTION
         when NO_DATA_FOUND THEN
         begin
              returncode := 1403;
              return;
         end;
         when OTHERS then
         begin
             ReturnCode := 2;
             return;
         end;
    end GetUserPwd;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值