SQL> set serveroutput on
SQL> start call1.sql

解决方案 »

  1.   

    但是自己定义的函数调用不了啊
    [oracle@mars2 fun]$ more call1.sql 
    declare
            tot_id integer;
            tot_cnt integer;
            begin
                    -- call fun
                    tot_id := get_id( 30, tot_cnt );
                    DBMS_OUTPUT.PUT_LINE( 'total id is: '||tot_id||' , count is '|| tot_cnt );
            end;
            /
    [oracle@mars2 fun]$ more fun1.sql 
    create function system.get_id(
            least integer,
            total_count integer  )
            return integer
            is
            ret integer;
            begin
            select sum(ID), count(*) into ret, total_count
            from yyq_test
            where ID>least;
            return ret;
    end get_id;
    /
    [oracle@mars2 fun]$ sqlplus system/emsdtsSQL*Plus: Release 10.1.0.2.0 - Production on Sun Aug 1 11:48:32 2004Copyright (c) 1982, 2004, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production
    With the Partitioning, OLAP and Data Mining optionsSQL> star^H^H^H^[[3~
    SP2-0310: unable to open fil.sql"
    SQL> set serveroutput on
    SQL> start fun1.sqlWarning: Function created with compilation errors.SQL> start call1.sql
                    tot_id := get_id( 30, tot_cnt );
                              *
    ERROR at line 6:
    ORA-06550: line 6, column 13:
    PLS-00905: object SYSTEM.GET_ID is invalid
    ORA-06550: line 6, column 3:
    PL/SQL: Statement ignored
    SQL>