Creating a package in sql*plus

Dear all;
Do you know what is wrong with this statement
SQL> create or replace pkg_initial_comment as procedure save_initial_comment(p_i
d number, p_first_name varchar2, p_last_name varchar2, p_comment varchar2, p_dat
e date); end save_initial_comment; create or replace package body pkg_initial_co
mment as procedure save_initial (p_id number, p_comments varchar2, p_first_name
varchar2, p_last_name varchar2, p_date date) is begin insert into initial_commen
ts values (1, p_first_name, p_last_name, p_comment, sysdate); end save_initial;
end pkg_initial_comment;
create or replace pkg_initial_comment as procedure save_initial_comment(p_id num
ber, p_first_name varchar2, p_last_name varchar2, p_comment varchar2, p_date dat
e); end save_initial_comment; create or replace package body pkg_initial_comment
as procedure save_initial (p_id number, p_comments varchar2, p_first_name varch
ar2, p_last_name varchar2, p_date date) is begin insert into initial_comments va
lues (1, p_first_name, p_last_name, p_comment, sysdate); end save_initial; end p
kg_initial_commentI keep getting the following error message
ora-00922:
and my table structure is below
create table initial_comment (id number(30),
first_name varchar2(4000), last_name varchar2(4000), create_date date);

yeah I just realized all my problems, it wasnt just the package keyword, it was also the names were wrong in both the specification and body. I am not used to using sql*plus, i use all other client tools which gives an opportunity to see and understand my syntax clearly. sorry about the posting and formatting. thanks for the help

Similar Messages

  • Debugging procedure or packages using sql*plus reg

    Dear all,
    I am new to oracle, can any body provide me some information related to this below issues.
    a) suppose i have created a procedure using sql*plus tool then next day i wanted to debug or modify my stored procedure.
    Then what could approach using sql*plus
    b) same case if we consider for packages then for any specific stored procedure or functions what would be the approach to debug or modify using sql*plus
    yours cordination will be highly appreciate
    Thanks n regards
    Laxman

    Using SQL*Plus you can debug your stored pl/sql code only adding some "prints" in your code:
    SQL> create or replace procedure test is
      2  begin
      3  dbms_output.put_line('starting...');
      4  --do something here
      5  dbms_output.put_line('done step 1');
      6  --do something else here
      7  dbms_output.put_line('end procedure...');
      8  end;
      9  /
    Procedura creata.
    SQL> set serverout on
    SQL> exec test
    starting...
    done step 1
    end procedure...
    Procedura PL/SQL completata correttamente.Or writing logs in a log table:
    SQL> create table logtab(ts timestamp(9),mess varchar2(4000));
    Tabella creata.
    SQL> create or replace procedure test is
      2  begin
      3  insert into logtab values(systimestamp,'starting...');
      4  --do something here
      5  insert into logtab values(systimestamp,'done step 1');
      6  --do something else here
      7  insert into logtab values(systimestamp,'end procedure...');
      8  end;
      9  /
    Procedura creata.
    SQL> exec test
    Procedura PL/SQL completata correttamente.
    SQL> col ts for a40
    SQL> col mess for a40
    SQL> select * from logtab;
    TS                                       MESS
    25-DIC-09 15:33:13,656000000             starting...
    25-DIC-09 15:33:13,656000000             done step 1
    25-DIC-09 15:33:13,656000000             end procedure...Max
    [My Italian Oracle blog|http://oracleitalia.wordpress.com]

  • How to create an object using sql*plus?

    Hi,
    I have tried to create an object , but after pressing enter key I could not get SQL command prompt or errors. How to come out from this? Could you help me to find what's wrong.
    SQL> create type course as object(
    2 course_no number(4),
    3 title varchar(35),
    4 credits number(1));
    5
    6
    7
    8
    Thanks.

    Put a slash "/" at the end of the command:
    CREATE TYPE course AS OBJECT (
       course_no   NUMBER (4),
       title       VARCHAR (35),
       credits     NUMBER (1)
    /

  • Reading package contents in SQL Plus

    Hi,
    I'd asked a similar question last week, but didn't see it responded to with a proper reply.
    Ive created a package in SQL Plus, and much like you use the DESCRIBE command to see info on tables that are created, I'd like to see the contents and script of my package to verify some contents of it.
    How can I do that? Or can I do that?
    I've read this:
    http://download-west.oracle.com/docs/cd/A87860_01/doc/appdev.817/a77069/08_packs.htm#4376
    But it doesn't explain within how to go about doing that if indeed that is possible at all. Would anyone that knows if this can be done please reply with the way to do it?
    Thanks!

    Hi,
    You can query USER_SOURCE (or ALL_SOURCE, at your choice) to get what you need.
    Consider:
    SQL> create or replace package small is
      2    procedure Test;
      3  end;
      4  /
    Package created.
    SQL> create or replace package body small is
      2
      3  procedure Test is
      4  begin
      5    null;
      6  end;
      7
      8  end;
      9  /
    Package body created.We just created simple package, for demonstration purposes. Now, we're about to view its source:
    SQL> column text format a100
    SQL>
    SQL> select line, text
      2    from user_source
      3   where name = 'SMALL'
      4     and type = 'PACKAGE'
      5   order by line;
          LINE TEXT
             1 package small is
             2   procedure Test;
             3 end;
    SQL> select line, text
      2    from user_source
      3   where name = 'SMALL'
      4     and type = 'PACKAGE BODY'
      5   order by line;
          LINE TEXT
             1 package body small is
             2
             3 procedure Test is
             4 begin
             5   null;
             6 end;
             7
             8 end;
    8 rows selected.
    SQL>Alternatively, you can make use of DBMS_METADATA package.
    Regards.

  • Error creating view with CASE -- WHEN statement in SQL*Plus

    I am using Oracle 8i 8.1.7
    I have an Oracle view which uses CASE...WHEN statements.
    The view compiles fine in DBA studio.
    Using TOAD I saved the view as an *.sql file.
    However, when I try to create the view in SQL*Plus I get the following error:
    SP2-0734: unknown command beginning "CASE WHEN ..." - rest of line ignored.
    According to the documentation CASE -- WHEN has been implemented since since Oracle 8i rel. 2 (8.1.6)

    Well I'm using 8.1.6.3 and CASE and DECODE both work for me:
    SQL> create or replace view v_accs as select account_name, txn,
    2 decode(credit, 0, 'DB', 'CR') t_type
    3 from accs;
    View created.
    SQL> select * from v_accs;
    ACCOUNT_NA TXN T_
    APC 1 DB
    ABC 2 DB
    HJJ 3 DB
    HJH 4 CR
    HJK 5 CR
    APC 6 DB
    APC 7 DB
    ABC 8 DB
    ABC 9 DB
    HJJ 10 DB
    HJJ 11 DB
    HJH 12 DB
    HJH 13 DB
    HJK 14 DB
    HJK 15 CR
    15 rows selected.
    SQL> create or replace view v_accs as select account_name, txn,
    2 case when credit = 0 then 'DB' else 'CR'end as t_type
    3* from accs
    View created.
    SQL> select * from v_accs;
    ACCOUNT_NA TXN T_
    APC 1 DB
    ABC 2 DB
    HJJ 3 DB
    HJH 4 CR
    HJK 5 CR
    APC 6 DB
    APC 7 DB
    ABC 8 DB
    ABC 9 DB
    HJJ 10 DB
    HJJ 11 DB
    HJH 12 DB
    HJH 13 DB
    HJK 14 DB
    HJK 15 CR
    15 rows selected.
    SQL>
    rgds, APC

  • Hwo to create a matrix report in sql Plus

    i want to create matrix report in SQL plus for emp table. how is it possible
    requirement is as following
    Deptno -- Clerk -- Salesman--Manager
    10----------2500---3500--------4500
    20----------2400---3400--------4400
    30----------1400---4400--------5400

    Hi,
    Do a search on this site on
    -'pivot'
    and/or:
    -'stragg'
    and/or:
    -'columns to rows'
    to get many example that will give you ideas.
    Also you forgot to mention this:
    What's the value of the job titles?
    Sum of salary of....?
    edit
    Using my data:
    MHO%xe> select deptno, job, sal from emp order by deptno
      2  /
        DEPTNO JOB              SAL
            10 MANAGER         2450
            10 PRESIDENT       5000
            10 CLERK           1300
            20 ANALYST         3000
            20 CLERK            800
            20 CLERK           1100
            20 ANALYST         3000
            20 MANAGER         2975
            30 MANAGER         2850
            30 SALESMAN        1600
            30 CLERK            950
            30 SALESMAN        1250
            30 SALESMAN        1500
            30 SALESMAN        1250
    14 rijen zijn geselecteerd.I would get:
    MHO%xe> select deptno
      2  ,      sum(decode(job,'CLERK',sal,0)) CLERK
      3  ,      sum(decode(job,'SALESMAN',sal,0)) SALESMAN
      4  ,      sum(decode(job,'MANAGER',sal,0)) MANAGER
      5  from   emp
      6  group by deptno
      7  order by deptno
      8  /
        DEPTNO      CLERK   SALESMAN    MANAGER
            10       1300          0       2450
            20       1900          0       2975
            30        950       5600       2850Edited by: hoek on Oct 17, 2009 3:19 PM

  • Create DB through SQL*Plus

    What is the syntax used to create a database within SQL*Plus (my
    assumption as an Oracle newbie is that it can be done)?
    A "Create Database <dbname>" command returns an insufficient
    privileges error (user = system).
    Thank you in advance for your help.

    Hi
    To create database from SQL*Plus you need to use connect as
    sysdba. But not only this. The hole procedure is very dificult.
    You need to set iniSID.ora file, setup environment variables and
    so on. It is easy to use graphical tools.
    But if you want to know more about database administration it is
    good idea to create at least one time database from 'scrap'.
    Read create database topics in Oracle Database Administration
    Guide. If you do it alone it will be great task. Good luck.
    Regards

  • SQL * Plus - forward slash usage

    I have package spec and body in separate files, i have 2 packages, so i have 4 files in total.
    I want to install the 2 packages using "SQL * Plus", but how the install-script should look like. I don't understand how and where to use "sql * plus" command "forward-slash" "/".
    Should it be like this:
    spec_file_1
    body_file_1
    spec_file_1
    body_file_1
    Or how the "/" should be used? Only ones at the end? I don't understand.

    You can write a single file this way:
    create or replace package a is
    end;
    create or replace package body a is
    end;
    create or replace package b is
    end;
    create or replace package body b is
    end;
    /And then run it in sqlplus this way:
    SQL >@a.sqlor multiple files this way:
    create or replace package a is
    end;
    create or replace package body a is
    end;
    create or replace package b is
    end;
    create or replace package body b is
    end;
    /And then run them in sqlplus this way:
    SQL >@a.sql
    SQL >@b.sql
    SQL >@c.sql
    SQL >@d.sqlOr write a file e that runs a,b,c,d this way:
    @a.sql
    @b.sql
    @c.sql
    @d.sqlAnd then run it in sqlplus this way:
    SQL >@e.sqlIn the previous examples the slash is always at the end of each CREATE...END;
    This is not compulsory. In the last example you could remove the slashes from the files a,b,c,d and write the file e this way:
    @a.sql
    @b.sql
    @c.sql
    @d.sql
    /This works anyway.
    Max
    [My Italian Oracle blog|http://oracleitalia.wordpress.com/2010/01/23/la-forza-del-foglio-di-calcolo-in-una-query-la-clausola-model/]
    Edited by: Massimo Ruocchio on Jan 26, 2010 9:20 AM
    typos

  • After I have Created a Package

    I am a newbie to Oracle. I have created a package in a schema that I am owner of and need to execute the contents of this package from within the same schema.Why do I have to create a public synonym for my package and GRANT EXECUTE to the synonym before the procedures and functions etc inside the package can be executed.

    you don't need synonyms.
    you must have execute rights for this package.
    in sql-plus type:
    exec <packagename>.<procedurename>;

  • Instant Client SQL*Plus License Question

    Can anyone shed some light on a license question for me? (I know that most license questions are for Oracle Sales to handle, but this involves a supposedly free product.)
    I want to use SQL*Plus with the Instant Client in a production environment, but I am not sure whether I am entitled to. Does Instant Client "support" SQL*Plus only in the sense that if I already own a license for SQL*Plus I can use it with the Instant Client, or is the Instant Client SQL*Plus package also truly free to deploy and use?
    The download page has links to download a basic Instant Client, plus several optional packages, one of which is SQL*Plus. However, the FAQ does not tell me whether the optional packages (specifically SQL*Plus) is also free to deploy and use in a production environment, and I could not find any other helpful document.
    The FAQ says that "Instant Client is FREE for anyone to use in a development or production environment." It also says immediately following that "Instant Client can be used to run your OCI, OCCI, Pro*C, JDBC, and ODBC applications without installing a full Oracle Client. In addition, Instant Client supports SQL*Plus." [emphasis mine]
    I would appreciate any help on this.
    Thanks in advance,
    Anthony

    Why don't you call Oracle sales? I guess they'll be happy to answer your question.
    Yours,
    Laurenz Albe

  • SQL*Plus report running through concurrent managers

    I Created a report in sql*plus from a view table and running it through the concurrent manager in 11.5.10.2. I'm using 4 paramaters, but I made the awards paramaters as required parameters and the from and to creation dates as not required. However, I noticed when trying to run the report with just the awards numbers no data is populated, but when i run the report with awards and dates then the reports shows data. Is there a way to get this report to run with awards only and make dates as an option from the query below?
    parameters#
    ##1 from award number
    ##2 to award number
    ##3 from creation date
    ##4 to creation date
    set termout off
    set head off
    set pages 0
    set feedback off
    set verify off
    set define #
    col sort_col noprint
    SELECT 'Revenue Report for Date ##3 - ##4, Awards ##1 - ##2', 0 sort_col
    FROM DUAL
    UNION
    SELECT 'AWARD NUMBER^EVENT DATE^DESCRIPTION^REVENUE AMOUNT^CREATION DATE',
    1
    FROM DUAL
    UNION
    SELECT project_number
    || '^'
    || event_date
    || '^'
    || description
    || '^'
    || revenue_amount
    || '^'
    || creation_date,
    2
    FROM apps.pa_events_v
    WHERE project_number BETWEEN NVL ('##1', project_number)
    AND NVL ('##2', project_number)
    AND creation_date BETWEEN TO_DATE (SUBSTR ('##3', 1, 10), 'YYYY/MM/DD')
    AND TO_DATE (SUBSTR ('##4', 1, 10), 'YYYY/MM/DD')
    ORDER BY 2;
    Thanks

    Hi;
    Please see below note which could be helpful for your issue:
    Unconstrained Msonwa64 Memory Based Planner 64 bit AIX Errors Signal 9 [ID 1274606.1]
    JTM Master Program Failing With ORA-1403 on afpgrs [ID 752065.1]
    Regard
    Helios

  • After running sql scripts in SQL plus, where are the results(tables) stored

    Hi ,
    I am using oracleDb10g . i have used SQL plus to create a database. I have run 2 sql scripts and constructed the tables , but i dont know where the data is stored and how to make the data into a database, so that i can use it for connection through some UI.
    for example: schema.sql, data.sql script files.
    SQL> start schema.sql
    SQL> start data.sql
    The tables are created.
    Now how can i group those table into a database and name it.(i mean i can create a database using SQL plus, but how to dump the tables into the database created). Because i want to use this database name for connecting to MS SQL, so i need the name.
    Thanks
    babu.

    when you are in Rome, sing with the romans !
    Oracle is different from SQL Server.
    Time to read some basic books.
    --> http://tahiti.oracle.com

  • Execution of Immediate SQL in compiled package in two versions of SQL*PLUS

    A peculiar problem has risen in our database.
    Execution of Immediate SQL in compiled package in two versions of SQLPLUS gives different results
    We have a compiled package with two procedures that contain immediate SQL statements, and these are:
    +PROC_DELETE_ROWS+
    +     -- This immediate sql deletes unreferenced Document Types from the DOC_REF_TYPE table+
    +     delete from doc_ref_type t where exists (select 1 from PROARC_DOC_REF_TYPE_VW d where d.doc_ref_type = t.doc_ref_type)+
       +     and not exists (select 1 from doc_ref d where d.doc_ref_type = t.doc_ref_type)+
       +     and doc_ref_type not in (select doc_ref_type from eis_doc_ref_type)+
       +     and doc_ref_type not in (select eis_doc_ref_type from eis_doc_ref_type)+
    +PROC_ADD_NEW_ROWS+
    +     -- Drop the temporary table+
    +     drop table TMP_PROARC_DOC_REF_TYPE+
    +     -- Create a temporary table+
    +     create table tmp_PROARC_DOC_REF_TYPE as+
    +     select DOC_REF_TYPE, substr(DOC_REF_TYPE_DESC,1,100) as DOC_REF_TYPE_DESC+
    +     from PROARC_DOC_REF_TYPE_VW+
    +     -- Insert document types that do not exist in the DOC_REF_TYPE table+
    +     insert into doc_ref_type t (DOC_REF_TYPE, DOC_REF_TYPE_DESC)+
            +     select distinct DOC_REF_TYPE, DOC_REF_TYPE_DESC from tmp_PROARC_DOC_REF_TYPE s+
            +     where not exists (select 1 from doc_ref_type t where t.doc_ref_type = s.doc_ref_type)+
    I am using the following test script:
    +Exec mypackage.proc_delete_rows;+
    +Commit;+
    +Select count(*) from DOC_REF_TYPES;+
    +Exec mypackage.proc_add_new_rows;+
    +Commit;+
    +Select count(*) from DOC_REF_TYPES;+We have a Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit
    I am using SQL*Plus: Release 8.1.7.0.0
    The test script is working as expected.
    Count after delete =155
    Count after insert = 511
    but when I use another computer with SQL*Plus: Release 10.x
    The Test script returns the following
    Count after delete =155
    Count after insert =155
    The same is happening when I am running the scripts as a scheduled job.
    QUESTION:
    I believe I have found a fix for the problem though. By changing tmp_PROARC_DOC_REF_TYPE in the insert statement to all upper case, the script is running in both environments apparently. But how is this possible? I am executing a compiled package in the database. The session shell should have no impact on the behaveour of the procedure I am calling. What causes this?
    Edited by: Reon on Jun 16, 2011 4:44 AM

    1) I am using the same user (PANDORA)
    2) (PANDORA) for both
    3) I am actually not handling any errors. Just skipping any error altogether. I'll check to see what exceptions are raised, and come back.
    I have also noticed that SQL/PLUS is not the culprit here. If I use SQLTools 1.5 to run the script, the same thing happens. So it has to do something with the connection or session environment that is inheritet to both clients.
    The CODEZ:_
      procedure add_doc_types IS
      sqlstr     VARCHAR2(2000);
      begin
      BEGIN
           sqlstr := 'drop table TMP_PROARC_DOC_REF_TYPE';
         EXECUTE IMMEDIATE sqlstr;
        EXCEPTION
          WHEN OTHERS THEN
            null;
        END;
      BEGIN
           sqlstr := 'create table tmp_PROARC_DOC_REF_TYPE as select DOC_REF_TYPE, substr(DOC_REF_TYPE_DESC,1,100) as DOC_REF_TYPE_DESC from PROARC_DOC_REF_TYPE_VW';
         EXECUTE IMMEDIATE sqlstr;
        EXCEPTION
          WHEN OTHERS THEN
            null;
        END;
        BEGIN
            sqlstr := 'insert into doc_ref_type t (DOC_REF_TYPE, DOC_REF_TYPE_DESC)
                    select distinct DOC_REF_TYPE, DOC_REF_TYPE_DESC from TMP_PROARC_DOC_REF_TYPE s
                    where not exists (select 1 from doc_ref_type t where t.doc_ref_type = s.doc_ref_type)';
         EXECUTE IMMEDIATE sqlstr;
            sqlstr := 'update doc_ref_type t set DOC_REF_TYPE_DESC = (
                    select DOC_REF_TYPE_DESC from tmp_PROARC_DOC_REF_TYPE s
                    where t.doc_ref_type = s.doc_ref_type)
                    where exists (select 1 from tmp_PROARC_DOC_REF_TYPE s where t.doc_ref_type = s.doc_ref_type)';
         EXECUTE IMMEDIATE sqlstr;
        EXCEPTION
          WHEN OTHERS THEN
            null;
        END;
      end add_doc_types;
      procedure delete_doc_types IS
      sqlstr     VARCHAR2(2000);
       BEGIN
            sqlstr := 'delete from doc_ref_type t where exists (select 1 from PROARC_DOC_REF_TYPE_VW d where d.doc_ref_type = t.doc_ref_type)
            and not exists (select 1 from doc_ref d where d.doc_ref_type = t.doc_ref_type)
            and doc_ref_type not in (select doc_ref_type from eis_doc_ref_type)
            and doc_ref_type not in (select eis_doc_ref_type from eis_doc_ref_type)';
          EXECUTE IMMEDIATE sqlstr;
         EXCEPTION
           WHEN OTHERS THEN
             null;
      end delete_doc_types;Edited by: Reon on Jun 16, 2011 2:01 AM

  • Creating a package. How to include standatd PL/SQL procedure?

    Dear All,
    I need to create a job in oracle schema where in it should to do the following actions.
    1. Refresh the Mat View Refresh group.
    2. Execute a procedure immediately after the above refresh happens.
    Hence I tried to create a package to include both the actions. But unable to create.
    Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.3.0
    Connected as GDB_DEEP
    SQL>
    SQL> CREATE OR REPLACE PACKAGE GDB_GHD_REP AS
      2    PROCEDURE DBMS_Refresh.refresh(refgrp);
      3    PROCEDURE Update_user_details_test();
      4  END;
      5  /
    Warning: Package created with compilation errors
    SQL>
    SQL> CREATE OR REPLACE PACKAGE BODY GLOBALDB_GHD_REP AS
      2    PROCEDURE DBMS_Refresh.refresh('MVRFRSHGRP_GDBGHD');
      3    PROCEDURE Update_user_details_test();
      4  END;
      5  /
    Warning: Package body created with compilation errors
    SQL> I understand that predefined oracle procedures should not be used like this, but Im trying to get a solution.
    Please help me in finding a solution.
    Is it possible to run two procedures one after the other with a single job?
    Regards
    Deep

    Hi, Deep,
    Deep. wrote:
    Dear All,
    I need to create a job in oracle schema where in it should to do the following actions.
    1. Refresh the Mat View Refresh group.
    2. Execute a procedure immediately after the above refresh happens.
    Hence I tried to create a package to include both the actions. But unable to create.
    Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.3.0
    Connected as GDB_DEEP
    SQL>
    SQL> CREATE OR REPLACE PACKAGE GDB_GHD_REP AS
    2    PROCEDURE DBMS_Refresh.refresh(refgrp);
    3    PROCEDURE Update_user_details_test();
    4  END;
    5  /
    Warning: Package created with compilation errors
    SQL>
    SQL> CREATE OR REPLACE PACKAGE BODY GLOBALDB_GHD_REP AS
    2    PROCEDURE DBMS_Refresh.refresh('MVRFRSHGRP_GDBGHD');
    3    PROCEDURE Update_user_details_test();
    4  END;
    5  /
    Warning: Package body created with compilation errors
    SQL> I understand that predefined oracle procedures should not be used like this, but Im trying to get a solution.
    Please help me in finding a solution.
    Is it possible to run two procedures one after the other with a single job?
    Regards
    DeepSure; call them from your own procedure. For example:
    CREATE OR REPLACE PACKAGE globaldb_ghd_rep AS
          PROCEDURE  refresh_and_test (refgrp  IN  VARCHAR2);
          PROCEDURE  update_user_details_test;
        END;
    SHOW ERRORS
    CREATE OR REPLACE PACKAGE BODY globaldb_ghd_rep AS
          PROCEDURE  refresh_and_test (refgrp  IN  VARCHAR2)
          IS
          BEGIN
              DBMS_Refresh.refresh(refgrp);
                 update_user_details_test;
          END  refresh_and_test;
          PROCEDURE  update_user_details_test
          IS
          END  update_user_details_test;
    END  globaldb_ghd_rep
    SHOW ERRORSWhen used immediately after the CREATE commands, the SQL*Plus command SHOW ERRORS displays more complete error messages.

  • Create database table using Forms Developer 6/6i without using SQL*Plus

    hello there,
    I need help in creating tables in Oracle using Forms Developer 6/6i without using SQL*Plus interface.
    your help is appreciated
    email: [email protected]

    please use Forms_ddl package to create a table dynamically
    from the Developer6/6i.
    you can check the success or failure by using the
    form_success builtin.
    if u want to avoid using the Forms_ddl package
    use stored procedure or create a sql querry record group.
    regards
    sriram.

Maybe you are looking for