set serveroutput on
create or replace procedure tempuser.tempprocedure as
tempdate    tempuser.resttable.currentdate%type;
begin
select    currentdate
into      tempdate
from      testtable
where     recordnumber=88;
dbms_output.put_line(to_char(tempdate))
end;

解决方案 »

  1.   

    出现什么错误呢?
    1.可能select currentdate
    into tempdate
    from testtable
    where recordnumber=88;
    返回的条数大于一条。2.testtable里的currentdate与resttable里currentdate类型不一致
      

  2.   

    dbms_output.put_line(to_char(tempdate))
    漏了结束的分号
    dbms_output.put_line(to_char(tempdate));
      

  3.   

    show errors;看看具体提示什么错误
    估计是dbms_output.put_line(to_char(tempdate));少了分号
    或者查询出来的不只一条记录
      

  4.   

    tempdate tempuser.resttable.currentdate%type;
    我想你的原意应该是
    tempdate tempuser.testtable.currentdate%type;
      

  5.   


       这语句是否是一起执行的?
       如果是,j就这样改:
       set serveroutput on  ==> set serveroutput on;
      dbms_output.put_line(to_char(tempdate))==> dbms_output.put_line(to_char(tempdate));
      

  6.   

    dbms_output.put_line(to_char(tempdate)) 后面没有分号
      

  7.   


    --第一个问题是,你这个查询语句会返回多个值,select currentdate from testtable where recordnumber=88;你加上一个rownum=1就可以了
    select currentdate into tempdate from testtable where recordnumber=88 and rownum=1;
    --第二个问题是你类型匹配的问题, testtable表中的currentdate 是否和 resttable表中currentdate类型一样啊?
    --第三,你的过程中dbms_output.put_line(to_char(tempdate))后面要加分号结束!并且你的tempdate应该是一个日期型的,你直接to_char(tempdate)是有问题的,必须再指定格式!
    如:to_char(tempdate,'yyyy-mm-dd hh24:mi:ss')
      

  8.   

    sql>set serveroutput on
    create or replace procedure tempuser.tempprocedure as
    tempdate tempuser.resttable.currentdate%type;
    begin
    select currentdate
    into tempdate
    from testtable
    where recordnumber=88;
    dbms_output.put_line(to_char(tempdate))--此处没有分号
    end;
      

  9.   

    set serveroutput on;
    create or replace procedure tempuser.tempprocedure as
    tempdate   tempuser.testtable.currentdate%type;
    begin
    select  currentdate
    into    tempdate
    from    testtable
    where   recordnumber=88 and rownum=1;
    dbms_output.put_line(to_char(tempdate,'yyyy-mm-dd hh24:mi:ss'));
    end;全试了都是一样的结果
      

  10.   

    你show error 看下错误具体信息是什么?
      

  11.   

    你show errors 看看具体什么错误
      

  12.   

    单独创建你的这个procedure报错的啊???
      

  13.   

    create or replace procedure tempuser.tempprocedure as
    tempdate resttable.currentdate%type;
    begin
    select currentdate
    into tempdate
    from testtable
    where recordnumber=88;
    dbms_output.put_line(to_char(tempdate));
    end;
      

  14.   

    先执行显示输出语句 
    set serveroutput on
    执行成功在执行创建的过程语句
    create or replace procedure tempprocedure as
    tempdate testtable.currentdate%type;
    begin
    select currentdate into tempdate from testtable where  recordnumber=88 and rownum=1;
    dbms_output.put_line(tempdate);
    end;
      

  15.   


    set serveroutput on;
    create or replace procedure tempuser.tempprocedure as
    tempdate testtable.currentdate%type;
    begin
    select currentdate
    into tempdate
    from testtable
    where recordnumber=88;
    dbms_output.put_line(to_char(tempdate));
    end;
    提示   警告: 创建的过程带有编译错误。求各位大侠帮帮忙解决吧..非常感激
      

  16.   

    --你先单独执行下这个语句,看看有多少个结果。如果结果不只一个肯定会报错的。
    select currentdate
    from testtable
    where recordnumber=88;
    --如果你上面的查询结果只有一个的话,你在执行下存储过程
    --set serveroutput on;这个你可以单独先执行
    create or replace procedure tempuser.tempprocedure as
    tempdate testtable.currentdate%type;
    begin
    select currentdate
    into tempdate
    from testtable
    where recordnumber=88;
    dbms_output.put_line(to_char(tempdate));
    end;
    --如果上面的存储过程还报错的话,你就像按照show errors 看看具体报什么错误
    SQL> ed
    已写入 file afiedt.buf  1  create or replace procedure tempprocedure as
      2  tempdate testtable.currentdate%type;
      3  begin
      4  select currentdate
      5  into tempdate
      6  from testtable
      7  where recordnumber=88;
      8  dbms_output.put_line(to_char(tempdate));
      9* end;
    SQL> /警告: 创建的过程带有编译错误。--下面是通过show errors来查看具体错误
    SQL> show errors;
    PROCEDURE TEMPPROCEDURE 出现错误:LINE/COL ERROR
    -------- ----------------------------------------------------
    2/10     PL/SQL: Item ignored
    2/10     PLS-00201: 必须声明标识符 'TESTTABLE.CURRENTDATE'
    4/1      PL/SQL: SQL Statement ignored
    6/6      PL/SQL: ORA-00942: 表或视图不存在
    8/1      PL/SQL: Statement ignored
    8/30     PLS-00320: 此表达式的类型声明不完整或格式不正确
    SQL> 
      

  17.   

    select currentdate
    from testtable
    where recordnumber=88;这个肯定是以条信息的PROCEDURE TEMPPROCEDURE 出现错误:
    这个是什么错误啊?
    没看出来2/10     PLS-00201: 必须声明标识符 'TESTTABLE.CURRENTDATE'
    这个需要什么声明啊?那例子我是从书上直接抄下来的
      

  18.   

    tempdate testtable.currentdate%type;
    这句话的意思是定义变量 tempdate 类型是表testtable中currentdate字段的类型
    报这个错误的原因可能是你没有建testtable表 或者是你的testtable表中没有currentdate这个字段
      

  19.   


    非常感谢  是应为currentdate这个字段些错了 多了一个e