在存储过程中select 只能这么写:select field1 into var1 from table1;

解决方案 »

  1.   

    create or replace procedure ps_dyck
    As
      test table_name%rowtype;
    begin
      select * into test from dyck;
    end
      

  2.   

    楼上的这句什么意思:
    test table_name%rowtype;楼主要实现什么功能哪?
      

  3.   

    ORA-01422: 实际返回的行数超出请求的行数 ORA-06512: 在"LOGISTIC.PS_DYCK", line 5 ORA-06512: 在line 1 
    改了存储过程是对了,可运行时又错了?
      

  4.   

    回复人: sammy791010(javabird) ( ) 信誉:100  2003-12-23 18:35:00  得分:0 
     
     
      楼上的这句什么意思:
    test table_name%rowtype;楼主要实现什么功能哪?
     
     
    ------------------------------------------------------------声明test为表记录变量
      

  5.   

    create package test_age 
    as
    type mycursor is ref cursor;
    end;
    /
    create or replace procedure ps_dyck(p_rc out test_age.mycursor)
    As
    begin
     open p_rc for select * from dyck;
    end;
    /以下是测试:
    declare
    变量;
    v_rc test_age.mycursor;
    begin
    ps_dyck(v_rc);
    loop
    fetch v_rc into 变量;
    exit when v_rc%notfound;
    ....
    end loop;
    end;
    /
      

  6.   

    修改一下:
    create or replace procedure ps_dyck
    As
      cursor cur_table_name is
        select * from dyck;
      test cur_table_name%rowtype;
    begin
      open cur_table_name;
      loop
        fetch cur_table_name into test;
        dbms_output.put_line(test.col_name)
        exit when cur_table_name%notfound;
      end loop;
    end ps_dyck;
      

  7.   

    不能隻在存儲過程中寫上 select * from dyck,因為這樣無法返回從dyck中取到的數據,
    樓上各位的方法都可以,你自己試試!!
      

  8.   

    OracleConnection conn= new OracleConnection("User ID=logistic;Data Source=oradb20;Password=logistic");
    conn.Open();
    OracleCommand cmd = new OracleCommand();
    cmd.CommandText = "ps_dyck"; OracleParameter pOutput;
    pOutput = cmd.Parameters.Add("pcur", OracleClient.OracleType.Cursor);
    pOutput.Direction = ParameterDirection.Output; cmd.CommandType = CommandType.StoredProcedure;
    cmd.Connection = conn;

    OracleDataReader dr = cmd.ExecuteReader();

    Table table = new Table(); while(dr.Read())
    { }
    是不是这样来执行存储过程的?我是今天刚刚开始学存储过程的!请指点