本帖最后由 junon 于 2010-11-04 15:15:13 编辑

解决方案 »

  1.   

    create procedure XXX 
    BEGIN
      FOR i IN select * from a LOOP
          IF i.年龄>10 AND i.姓名 like'%国%' THEN
            P(i.性别,i.地址);
          END IF;
      END LOOP;
    END;
      

  2.   

    1楼的不行哦。报错Error: PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
           
              ( - + case mod new null <an identifier>
              <a double-quoted delimited-identifier> <a bind variable>
              reverse avg count current max min prior sql stddev sum
              variance execute forall merge <一个 SQL 语句> time timestamp
              interval date
              <a string literal with character set specification>
              <a number> <a single-quoted SQL string> pipe
              <一个带有字符集说明的可带引号的字符串文字>
              <一个可带引号的 SQL 字符串>
           The symb
      

  3.   


    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 
    Connected as scott
    SQL> 
    SQL> drop table tableA;Table droppedSQL> create table tableA(name varchar2(20),age number,address varchar2(20),sex varchar2(10));Table createdSQL> 
    SQL> create or replace procedure XXX(sex out varchar2,address out varchar2)
      2  is
      3  BEGIN
      4    FOR i IN (select * from tableA)  LOOP
      5        IF (i.age>10 AND instr(i.name,'国')>0) THEN
      6          dbms_output.put_line('性别'||i.sex);
      7          sex := i.sex;
      8          dbms_output.put_line('地址'||i.address);
      9          address:=i.address;
     10        END IF;
     11    END LOOP;
     12  END XXX;
     13  /Procedure createdSQL> 
      

  4.   

    create procedure XXX 
    BEGIN
    FOR i IN (select 性别,地址 from a where 年龄>10 AND 姓名 like '国%') 
    LOOP
    P(该行记录的性别,该行记录的地址);
    END LOOP;
    END;
    --过程p 的代码贴出来
      

  5.   

    create procedure XXX 
    as  -少了as 或者is 
    BEGIN
    FOR i IN (select 性别,地址 from a where 年龄>10 AND 姓名 like '国%')  
    LOOP
    P(该行记录的性别,该行记录的地址);
    END LOOP;
    END;