各位大侠,在定义存储过程的时候,如何定义表变量,以及如何为表变量进行赋值,最好有例子,谢谢!

解决方案 »

  1.   

    数值对象里有table型数组以前写过这样的blog文,你参考先。
    http://blog.csdn.net/inthirties/archive/2009/08/02/4400905.aspx
      

  2.   

    create or replace procedure Scorestage(
    Eunpassnum  out number,   //变量定义
    Eoversixty  out number,
    Eoversenventy  out number,
    Eovereighty  out number,
    Eoverninety out number,
    punpassnum out number,
    poversixty  out number,
    poversenventy  out number,
    povereighty  out number,
    poverninety out number,
    munpassnum out number,
    moversixty  out number,
    moversenventy  out number,
    movereighty out number,
    moverninety out number,
    bunpassnum out number,
    boversixty  out number,
    boversenventy out number,
    bovereighty  out number,
    boverninety out number)
    as
    HEnglish number;
    Hplitics number;
    Hmath number;
    Hbasicmajor number;
    cursor Firststu_cursor is
    select English,plitics,math,basicmajor from 初试考生;
    begin
    Eunpassnum:=0; 
      Eoversixty:=0; 
      Eoversenventy:=0; 
      Eovereighty:=0; 
      Eoverninety:=0; 
      punpassnum:=0; 
      poversixty:=0; 
      poversenventy:=0; 
      povereighty:=0; 
      poverninety:=0; 
      munpassnum:=0;
      moversixty:=0; 
      moversenventy:=0; 
      movereighty:=0; 
     moverninety:=0; 
      bunpassnum:=0; 
      boversixty:=0; 
      boversenventy:=0; 
      bovereighty:=0; 
      boverninety:=0; 
    open Firststu_cursor;
    loop
    fetch Firststu_cursor into HEnglish,Hplitics,Hmath,Hbasicmajor;
    exit when Firststu_cursor%notfound;
    if HEnglish<60 then
    Eunpassnum:=Eunpassnum+1;
    end if;
    if HEnglish>60 then
    Eoversixty:=Eoversixty+1;
    end if;
    if HEnglish>70 then
    Eoversenventy:=Eoversenventy+1;
    end if;
    if HEnglish>80 then  
    Eovereighty:=Eovereighty+1;
    end if;
    if HEnglish>90 then 
    Eoverninety:=Eoverninety+1;
    end if;
    if Hplitics<60 then
    punpassnum:=punpassnum+1;
    end if;
    if Hplitics>60 then
    poversixty:=poversixty+1;
    end if;
    if Hplitics>70 then
    poversenventy:=poversenventy+1;
    end if;
    if Hplitics>80 then  
    povereighty:=povereighty+1;
    end if;
    if Hplitics>90 then 
    poverninety:=poverninety+1;
    end if;
    if Hmath<60 then
    munpassnum:=munpassnum+1;
    end if;
    if Hmath>60 then
    moversixty:=moversixty+1;
    end if;
    if Hmath>70 then
    moversenventy:=moversenventy+1;
    end if;
    if Hmath>80 then  
    movereighty:=movereighty+1;
    end if;
    if Hmath>90 then 
    moverninety:=moverninety+1;
    end if;
    if Hbasicmajor<60 then
    bunpassnum:=bunpassnum+1;
    end if;
    if Hbasicmajor>60 then
    boversixty:=boversixty+1;
    end if;
    if Hbasicmajor>70 then
    boversenventy:=boversenventy+1;
    end if;
    if Hbasicmajor>80 then  
    bovereighty:=bovereighty+1;
    end if;
    if Hbasicmajor>90 then 
    moverninety:=moverninety+1;
    end if;
    end loop;
    close Firststu_cursor;
    end scorestage;