(m_bgbh in varchar2)
AS   
qhsm number(7,2);
hsm number(7,2); 
shsm number(7,2); 
jhsm number(7,2);  
qzsm number(7,2); 
zsm number(7,2); 
zhsm number(7,2);  
heism number(7,2);  
yysd1m number(7,2);  
yysd2m number(7,2);  
v_cwmc varchar2(7);   
v_yxms varchar2(60);  
v_bz varchar2(100);  
v_count number(7,2); 
v_jh varchar2(20);  
v_yylb varchar2(10);  
v_csrq date;  
TI number(7,2);  
v_TI varchar2(10);  
m_ypph number(7,2);  
m_yybh varchar2(20);
CURSOR c1 IS select YPPH,YYBH from BFHSYSZSYS where BGBH=m_bgbh; 
begin
  OPEN c1;   
    LOOP   
      FETCH c1 into m_ypph,m_yybh;
      EXIT WHEN c1%NOTFOUND;
     .........
其它不变

解决方案 »

  1.   

    给你个简单例子看
    DECLARE
      -- Declare variables to hold information about the students
      -- majoring in History.
      v_StudentID   students.id%TYPE;
      v_FirstName   students.first_name%TYPE;
      v_LastName    students.last_name%TYPE;  -- Cursor to retrieve the information about History students
      CURSOR c_HistoryStudents IS
        SELECT id, first_name, last_name
          FROM students
          WHERE major = 'History';
    BEGIN
      -- Open the cursor and initialize the active set
      OPEN c_HistoryStudents;
      LOOP
        -- Retrieve information for the next student
        FETCH c_HistoryStudents INTO v_StudentID, v_FirstName, v_LastName;    -- Exit loop when there are no more rows to fetch
        EXIT WHEN c_HistoryStudents%NOTFOUND;    -- Process the fetched rows.  In this case sign up each
        -- student for History 301 by inserting them into the 
        -- registered_students table. Record the first and last
        -- names in temp_table as well.
        INSERT INTO registered_students (student_id, department, course)
          VALUES (v_StudentID, 'HIS', 301);    INSERT INTO temp_table (num_col, char_col)
          VALUES (v_StudentID, v_FirstName || ' ' || v_LastName);  END LOOP;  -- Free resources used by the cursor
      CLOSE c_HistoryStudents;  -- Commit our work
      COMMIT;
    END;
    /
      

  2.   

    非常感谢各位,不知道各位对:
    if qhsm is null then
            Update BFHSYSZSYS set QHS=0 where BGBH=m_bgbh and YPPH=m_ypph and YYBH=m_yybh;
          end if;
          if hsm is null then
            Update BFHSYSZSYS set HS=0 where BGBH=m_bgbh and YPPH=m_ypph and YYBH=m_yybh;
          end if;
    .....
    这样的语句有没有更简单的方法啊
    为空就赋值为0..
    谢谢....
      

  3.   

    if qhsm is null or hsm is null then
            Update BFHSYSZSYS set QHS=0 where BGBH=m_bgbh and YPPH=m_ypph and YYBH=m_yybh;
          end if;
      

  4.   

    也可用下面打开游标
    DECLARE
      -- Declare variables to hold information about the students
      -- majoring in History.
      v_StudentID   students.id%TYPE;
      v_FirstName   students.first_name%TYPE;
      v_LastName    students.last_name%TYPE;  -- Cursor to retrieve the information about History students
      CURSOR c_HistoryStudents IS
        SELECT id, first_name, last_name
          FROM students
          WHERE major = 'History';
    BEGIN     for c in cHistoryStudents 
         loop 
           -- code ;
         
         end loop;      ...
          ...
    end ;