How to Create Procedure in DB2

 
the first step, you should create a table in db2 database
for example :
             open a sql editor in the db2 envionment .and then
             create table test (name varchar(20),address varchar(200));
 
 
so , you run this sql ,the table will be created by you .
 
the second step : you open a command window with db2cmd command ;
    
     the next screen, you type the following command ,it will help create your procedure .
  
      db2 td@ -vf sql_pre.txt ( Attention,  the text file include your real procedure script ),after the article , I will give you the file .
dont worry about .
 
      when the command return a success message , you can find a new procedrue  which you create just .
 
the third step : call your procedrue ;
     call db2admin.testprc.
     if good luck you will see your result .
 
Append file : 
   create procedure db2admin.testPrc()
   dynamic result sets 1
   p1: begin
   declare stmt varchar(500);
   declare c cursor with return for select * from  db2admin.marklist;   
  
   open c;
 
 
end p1 @
注意2点 
以 @结尾
用 P1 块来描述
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值