How to execute the packaged procedure

Hello i've written the following package: It's created fine but while running that procedure i'm getting the following error
create or replace package ttt_example as
  TYPE ColumnsInfo IS RECORD (
      columnName VARCHAR2 (30),
      dataType VARCHAR2 (30)
TYPE ColumnsInfoList IS TABLE OF ColumnsInfo; 
FUNCTION getColumns (
      schemaName VARCHAR2,
      tableName VARCHAR2
      RETURN ColumnsInfoList;
PROCEDURE fillTable (
      schemaName VARCHAR2,
      tableName VARCHAR2
end;
create or replace package body ttt_example is
PROCEDURE fillTable (
      schemaName VARCHAR2,
      tableName VARCHAR2
   ) IS
      i NUMBER;
      columnsList ColumnsInfoList;
      columnsStr VARCHAR2 (4000);
      valList VARCHAR2 (4000) := NULL;
      insertTime VARCHAR2 (100);
   BEGIN
      DBMS_OUTPUT.PUT_LINE ('fillTable - BEGIN');
      columnsList := getColumns (schemaName, tableName);
      i := columnsList.FIRST;
      IF i IS NOT NULL THEN
         columnsStr := columnsList (i).columnName;
         i := columnsList.NEXT (i);
      END IF;
      WHILE i IS NOT NULL LOOP
         columnsStr := columnsStr || ', ' || columnsList (i).columnName;
         i := columnsList.NEXT (i);
      END LOOP;
      i := columnsList.FIRST;
      WHILE i IS NOT NULL LOOP
         IF i != columnsList.LAST THEN
            IF columnsList (i).dataType = 'NUMBER' THEN
               valList := valList || i || ', ';
            ELSIF columnsList (i).dataType = 'VARCHAR2' THEN
               valList := valList || '''' || i || '''' || ', ';
            ELSIF columnsList (i).dataType = 'DATE' THEN
               --EXECUTE IMMEDIATE 'SELECT TO_CHAR(SYSTIMESTAMP) FROM dual' INTO insertTime;
               --valList := valList ||''''|| insertTime||''''|| ', ';
               valList := valList || 'SYSDATE, ';
            ELSE
               DBMS_OUTPUT.PUT_LINE ('WRONG DATA TYPE ' || columnsList (i).dataType);
            END IF;
         ELSE
            IF columnsList (i).dataType = 'NUMBER' THEN
               valList := valList || i;
            ELSIF columnsList (i).dataType = 'VARCHAR2' THEN
               valList := valList || '''' || i || '''';
            ELSIF columnsList (i).dataType = 'DATE' THEN
               --EXECUTE IMMEDIATE 'SELECT TO_CHAR(SYSTIMESTAMP) FROM dual' INTO insertTime;
               --valList := valList ||''''|| insertTime||'''';
               valList := valList || 'SYSDATE';
            ELSE
               DBMS_OUTPUT.PUT_LINE ('WRONG DATA TYPE ' || columnsList (i).dataType);
            END IF;
         END IF;
         i := columnsList.NEXT (i);
      END LOOP;
      DBMS_OUTPUT.PUT_LINE ('fillTable - MIDDLE');
      EXECUTE IMMEDIATE 'INSERT INTO ' || tableName || '(' || columnsStr || ') VALUES (' || valList || ')';
      DBMS_OUTPUT.PUT_LINE ('fillTable - END');
   END;
FUNCTION getColumns (
      schemaName VARCHAR2,
      tableName VARCHAR2
      RETURN ColumnsInfoList IS
      columnsList ColumnsInfoList;
   BEGIN
      DBMS_OUTPUT.PUT_LINE ('getColumns - BEGIN');
      EXECUTE IMMEDIATE 'SELECT COLUMN_NAME, DATA_TYPE FROM ALL_TAB_COLUMNS WHERE OWNER = ''' || schemaName || ''' AND TABLE_NAME = ''' || tableName || ''''
      BULK COLLECT INTO columnsList;
      DBMS_OUTPUT.PUT_LINE ('getColumns - END');
      RETURN columnsList;
   EXCEPTION
      WHEN OTHERS THEN
                  RAISE;
   END;
end;
/  While executing that package procedure
SQL> begin
  2  ttt_example.fillTable('TEST','EMPE');
  3  end;
  4  /
begin
ERROR at line 1:
ORA-00928: missing SELECT keyword
ORA-06512: at "ttt.TTT_EXAMPLE", line 60
ORA-06512: at line 2help me in this

I was able to reproduce with NULL for columnstr;
create table t (c1 varchar2(20), c2 varchar2(20));
Table created
create or replace procedure p
  tablename  varchar2,
  columnsstr varchar2,
  vallist    varchar2
) is
begin
  execute immediate 'INSERT INTO ' || tablename || '(' || columnsstr ||
                    ') VALUES (' || vallist || ')';
end;
Procedure created
exec p('t', 'c1,c2', '''a'',''b''');
PL/SQL procedure successfully completed
select * from t;
C1                   C2
a                    b
exec p('t', '', '''a'',''b''');
begin p('t', '', '''a'',''b'''); end;
ORA-00928: missing SELECT keyword
ORA-06512: at "MSCALLION.P", line 8
ORA-06512: at line 2

Similar Messages

  • How to execute the packaged procedure(having out param) in TOAD for Oracle

    Hi.
    Could you help me
    How to execute the packaged procedure having out parameters in TOAD for Oralce..
    Thanks..

    Use anonymous PL/SQL block to execute it.
    Example.
    DECLARE
      <out variable name> <out variable data type>;
    BEGIN
      <package name>.<procedure name>(<out variable name>);
    END;

  • How to execute the package generated from Warehousebuilder ??

    Hi,
    I am very new to OWB, i have created the mapping and i want to write a oracle job to run the mapping, Can i explicitly execute the Package generated by passing the parameters required,
    I have actually created like following,
    DECLARE
    p_status VARCHAR2 (200);
    p_deptno NUMBER;
    p_max_no_of_errors VARCHAR2 (200);
    p_commit_frequency VARCHAR2 (200);
    p_operating_mode VARCHAR2 (200);
    p_bulk_size VARCHAR2 (200);
    p_audit_level VARCHAR2 (200);
    p_purge_group VARCHAR2 (200);
    BEGIN
    p_deptno := 10;
    p_max_no_of_errors := NULL;
    p_commit_frequency := NULL;
    p_operating_mode := NULL;
    p_bulk_size := NULL;
    p_audit_level := NULL;
    p_purge_group := NULL;
    map_filter_parameter.main (p_status => p_status,
    p_deptno => p_deptno,
    p_max_no_of_errors => p_max_no_of_errors,
    p_commit_frequency => p_commit_frequency,
    p_operating_mode => p_operating_mode,
    p_bulk_size => p_bulk_size,
    p_audit_level => p_audit_level,
    p_purge_group => p_purge_group
    DBMS_OUTPUT.put_line ('P_STATUS = ' || p_status);
    END;
    I am actually following error,
    Line: ----
    Connecting to the database bl.
    ORA-20013: The workspace has not been set. Please call wb_workspace_management.set_workspace procedure to set workspace first.
    ORA-06512: at "OWBSYS.WB_WORKSPACE_MANAGEMENT", line 1356
    ORA-06512: at "OWBSYS.WB_WORKSPACE_MANAGEMENT", line 1387
    ORA-06512: at "OWBSYS.WB_RTI_UTIL", line 102
    ORA-06512: at "OWBSYS.WB_RT_MAPAUDIT_UTIL", line 1020
    ORA-06512: at "BL.MAP_FILTER_PARAMETER", line 2798
    ORA-06512: at line 19
    Process exited.
    Disconnecting from the database bl.
    I am not able to connect OWBSYS to see whats going on with OWBSYS.WB_WORKSPACE_MANAGEMENT as well.
    Please suggest
    Regards,
    Ashoka BL

    Hi Nawneet,
    I tried like the following and getting the results,I searched in the forum to do this,
    DECLARE
    p_status VARCHAR2 (200);
    p_deptno NUMBER;
    p_max_no_of_errors VARCHAR2 (200);
    p_commit_frequency VARCHAR2 (200);
    p_operating_mode VARCHAR2 (200);
    p_bulk_size VARCHAR2 (200);
    p_audit_level VARCHAR2 (200);
    p_purge_group VARCHAR2 (200);
    BEGIN
    p_deptno := 20;
    p_max_no_of_errors := NULL;
    p_commit_frequency := NULL;
    p_operating_mode := NULL;
    p_bulk_size := NULL;
    p_audit_level := NULL;
    p_purge_group := NULL;
    owbsys.wb_workspace_management.set_workspace('ASHOK_WORKSPACE','ASHOK_BL');
    map_filter_parameter.main (p_status => p_status,
    p_deptno => p_deptno,
    p_max_no_of_errors => p_max_no_of_errors,
    p_commit_frequency => p_commit_frequency,
    p_operating_mode => p_operating_mode,
    p_bulk_size => p_bulk_size,
    p_audit_level => p_audit_level,
    p_purge_group => p_purge_group
    DBMS_OUTPUT.put_line ('P_STATUS = ' || p_status);
    END;
    Do you please let me know what are these,
    'PLSQLMAP','CUSTOMER_MAP' == WorkSpace_Name and User_Name ??
    Regards,
    Ashoka BL
    Edited by: user7348859 on May 26, 2009 5:07 AM

  • How to see the packaged procedures in form builder?

    Hi Experts,
    I have a oarcle apps form in form builder.
    When i want to see the code behind the trigger when pressed button do ,i see that it calls a packaged procedure like
    oksaudet_header.when_button_pressed(p_item => 'STOP_BUTTON');
    I want to see beyond this ,so how to find out this package procedure oksaudet_header.when_button_pressed?
    if its any pll ,how do i know which pll will have this package?
    Thanks

    Hi,
    You just need to search for component OKSAUDET_HEADER in Forms Builder (use the 'Find' button). It will take you to the package, and above it you will find the attached library that contains it (if it's an attached library).
    Hope it helps.

  • How to execute the package in odi

    hi
    i have a 3 interfaces.i have to put it in package and execute this package.but problem is that it is executing in a infinite loop.
    so how to execute these 3 interfaces serielly in package.(without in a loop)

    If you want to execute your 3 interfaces one by one you just have to define a First Step (Right click "First Step")
    And then to link the first interface with the second one with the Green arrow, and the 2nd one with the third with another green arrow...
    If after that you link the 3rd with the first it will loop...
    So avoid this.
    Regards,
    Brice

  • Can not able to save the data while executing the package/procedure

    Hi,
    I created one package and schedule this in JOB, job is running successfully but data is not inserting in table,
    CREATE OR REPLACE package body LST_RPT as
    procedure gender_proc(gender varchar2) is
    begin
    insert into gender_count
    select * from mag_hotline_gender;
    end;
    end LST_RPT;
    after that I am executing this
    exec MSREUL.MKE_LST_RPT.gender_proc('M');
    but it is not saving the data
    can anybody suggest where I am doiing mistake

    Hi Arun,
    Thanks for the suggestion.
    I checked my table structure, gender_count was GTT(global temporary table), Now I changed the structure package is executing sucessfully and able to commit the data
    exec MKE_LST_RPT.gender_proc('M');
    commit;
    can you plz help on another point I want to schedule this package on job means it runs on every day and commit automatically, I am using TOAD but unable to create job can you plz help on this issue.

  • How to call the stored procedure in side the package... ?

    Hi
    I have one package i am new to PL/SQL. I want to execute the package and procedure.
    CREATE OR REPLACE PACKAGE BODY Employee_pkg
    AS
    PROCEDURE GetEmployeeName(i_empno IN NUMBER,
    o_ename OUT VARCHAR2)
    IS
    BEGIN
    SELECT ename
    INTO o_ename
    FROM emp
    WHERE empno = i_empno;
    END GetEmployeeName;
    END Employee_pkg;
    Please tell me how to execute the package. and inside procedure
    Thanks

    SQL> create package employee_pkg
      2  as
      3    procedure getemployeename(i_empno in number, o_ename out varchar2);
      4  end employee_pkg;
      5  /
    Package is aangemaakt.
    SQL> CREATE OR REPLACE PACKAGE BODY Employee_pkg
      2  AS
      3  PROCEDURE GetEmployeeName(i_empno IN NUMBER,
      4  o_ename OUT VARCHAR2)
      5  IS
      6  BEGIN
      7  SELECT ename
      8  INTO o_ename
      9  FROM emp
    10  WHERE empno = i_empno;
    11  END GetEmployeeName;
    12
    13
    14  END Employee_pkg;
    15  /
    Package-body is aangemaakt.
    SQL> var P_ENAME varchar2(30)
    SQL> set autoprint on
    SQL> exec employee_pkg.getemployeename(7839,:P_ENAME)
    PL/SQL-procedure is geslaagd.
    P_ENAME
    KINGRegards,
    Rob.

  • Error with Project Parameters when executing the package with dtexec command

    Hi,
    We have started migrating our SSIS package from 2005 version to SSIS 2012. In SSIS 2005 we were using XML configuration files and executing the packages with dtexec command from the packages folder (without deploying packages to filesystem).
    Now in SSIS 2012, we have seen Project Parameters and created couple of package parameters and used those parameters in the package. when executing this package from solution explorer it was working fine but when i try to execute the same package from command
    line with Dtexec command, it was showing an error message of 'Not able to map Project Prameters to configurations'.
    Could you please give me an idea of how to execute the packages from command line by using dtexex command. basically i would like use project parameters in 2012 similar to configurations?
    Thanks,
    Venu.

    Refer
    http://msdn.microsoft.com/en-IN/library/hh231187.aspx
    you can pass parameter like this
    /SET \Package.Variables[$Package::ParameterName];<value> /SET \Package.Variables[$Project::ParameterName];<value>
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • How to Execute SSIS package through MySQL Procedure

    Hi Everyone,
    How to Execute SSIS package from MySQL Stored Procedure.
    Please share your suggestions on this.
    Regards,
    Vaishu

    I am not sure whether you have SSIS license version installed in the system where MYSQL is there. In order to run SSIS package we need to have DTEXEC executable file and it comes with SSIS license version.
    An SSIS package can be executed from command prompt as,
    C:\>dtexec /f E:\package.dtsx
    I am not expert in MYSQL however in TSQL we can run dos command or scripting language such as vbscript.
    Similarly you need to check in MYSQL. This is MSSQL Server forum.
    Refer
    http://www.ehow.com/how_8789576_call-ssis-package-vbscript.html
    http://www.mssqltips.com/sqlservertip/1775/different-ways-to-execute-a-sql-server-ssis-package/
    Regards, RSingh

  • How to Execute the procedure?

    Hi,
    How to execute a below procedure with refcursor output parameter,
    in that procedure refcursor declare in package
    create or replace PROCEDURE prc_sam(
    P_LIST OUT pkg_sam.REF_CURSOR_TYPE) IS
    BEGIN
    OPEN P_LIST FOR
    SELECT 1+1 FROM dual;
    EXCEPTION
    WHEN OTHERS THEN
    RAISE_APPLICATION_ERROR(-20001,SQLERRM);
    END prc_sam;
    Regards,
    Fame

    SQL> create or replace PROCEDURE prc_sam(
    2 P_LIST OUT SYS_REFCURSOR) IS
    3 BEGIN
    4
    5 OPEN P_LIST FOR
    6 SELECT 1+1 FROM dual;
    7 EXCEPTION
    8 WHEN OTHERS THEN
    9 RAISE_APPLICATION_ERROR(-20001,SQLERRM);
    10 END prc_sam;
    11 /
    Procedure created.
    SQL> VARIABLE P_CURSOR REFCURSOR;
    SQL> EXEC prc_sam(:P_CURSOR);
    PL/SQL procedure successfully completed.
    SQL> PRINT P_CURSOR;
    1+1
    2
    Intead of SYS_REFCURSOR, you can use ur pkg_sam.REF_CURSOR_TYPE inside a package
    AND
    execute a procedure like EXEC pkg_sam.prc_sam(:P_CURSOR);
    like this, then you will get the result............................
    Thanks,
    Ann

  • How to execute the procedure in sap b1

    Hai to all,
                 I done a procedure in sql server .but i don't know how to execute that  procedure in sap b1?
    can anyone help me immediately.
    Regards,
    Ramya.S

    Dear Ramya.S,
    You could execute the store procedure by using Recordset object in SDK DI code. It is like:
    Dim myRecordSet As SAPbobsCOM.Recordset
    myRecordSet =                                   
    SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecord
    set)
    myRecordSet.Command.Name = "TestStoredProcedure"
    myRecordSet.Command.Parameters.Item("@ItemLike").Value = "IT%"
    myRecordSet.Command.Parameters.Item(2).Value = "C0001"
    myRecordSet.Command.Execute()

  • How to execute the parametered stored procedure in sql *plus ?

    how to execute the parametered stored procedure in sql *plus ?
    my storedprocedure format
    CREATE OR REPLACE PROCEDURE SMS_SELECTMPLOYEE
    (empDOB out date, empEmpName out varchar2)
    thanks & regards
    mk_mur

    Oh, sorry... making many reading-too-fast mistakes today...
    You can't declare date variables in SQL*Plus (seel help var), but you can cast to varchar2:
    TEST> CREATE OR REPLACE PROCEDURE SMS_SELECTMPLOYEE (empDOB out date, empEmpName out varchar2) IS
      2  d date := sysdate;
      3  e varchar2(10) := 'bob';
      4  begin
      5  empdob := d;
      6  empempname := e;
      7  end;
      8  /
    Procedure created.
    TEST> var d varchar2(30)
    TEST> var n varchar2(30)
    TEST> call  SMS_SELECTMPLOYEE(:d,:n);
    Call completed.
    TEST> print d n
    D
    11/07/06
    N
    bobYoann.

  • How to use ADO(Microsoft ActiveX Data Objective 2.8 Library) to execute the store procedure of database in SQL server

    how to use ADO(Microsoft ActiveX Data Objective 2.8 Library) to execute the store procedure of database in SQL server?
    Does any body can tell me about this?
    thanks
    [email protected]

    Hi 
    Did you succeed to execute the procedure?
    How ?
    Thanks
    Shimon Zerbib

  • How to Execute a Remote Procedure in Portal using Database Link

    Hi,
    I followed the instructions to create a Portal form for a remote procedure. But I am encountering the following error. Can someone advise what may be the cause?
    Failed to execute - Missing string(create_package_body) language(us) domain (wwv) sub_domain (wwv_builder) (WWV-04300)
    ORA-04020: deadlock detected while trying to lock object PUBLIC.PORTLET_SCHEMA (WWV-11230)
    Failed to parse as PORTAL - (WWV-08300)
    PURPOSE
    How to execute a remote procedure in Portal using Database Link.
    DESCRIPTION
    This procedure assumes that you have two databases, one of which is remote, and Portal is configured in the other.
    Remote Database A:
    ==================
    1) Create a procedure as follows: Create or Replace PROCEDURE SCOTT.ADD_TWO_VALUES ( v_one IN NUMBER, v_two IN NUMBER, v_result OUT NUMBER) as begin v_result :=v_one+v_two; end; 2) Grant execute privileges to PUBLIC on the procedure.
    Database B (where Portal is configured): ========================================
    1) Create a public database link and choose to connect as a specific user (say SYSTEM). By default, in an Oracle 8i database, the "global_names" parameter in initSID.ora (or init.ora) file is set to "true". This Global Naming parameter enforces that a dblink has the same name as the database it connects to. Therefore, if the remote global database (A) name is "ora8.acme.com" then the database link should also be named as "ora8.acme.com".
    2) Create a synonym for the procedure in Database A. Make sure you fully qualify the procedure name in the remote database (like SCOTT.ADD_TWO_VALUES).
    3) Create a dynamic page to execute the procedure. The ORACLE tags in the dynamic page will look similar to the following: <ORACLE> DECLARE v_total NUMBER; BEGIN ADD_TWO_VALUES(:v_one,:v_two, v_total); htp.p('The total is => '); htp.p('<input type="TEXT" VALUE='||v_total||'>'); htp.para; htp.anchor('http://<machine.domain:port#>/pls/portal30/SCOTT.DYN_ADD_TWO_VALUES.show_parms', 'Re-Execute Procedure'); END; </ORACLE>
    4) Portal does not have an option to create a form based on a synonym. Therefore, if you want to create a form instead of a dynamic page, create a wrapper procedure and then create a form based on this procedure. For example: Create or Replace PROCEDURE PORTAL30.ADD_TWO_VALUES_PR ( v_one IN NUMBER, v_two IN NUMBER, v_total OUT NUMBER) as begin add_two_values(v_one, v_two, v_total); end;
    5) Grant execute privileges to PUBLIC on the procedure.

    hello...
    any input will welcomed... Thanks..

  • How to execute the content of varchar  variable like a simple query

    Hi everyone!
    I did a PL/SQL region in apex, in this region I did the query which is storaged in a variable; it was did it concatenate several times,
    in the procedure I have several sentences.
    I thought that the command 'execute immediate' would get a good result but it do not print the result.
    declare
    variable varchar2(1000);
    begin
    --sentences
    --execute inmmediate( variable );
    --return variable
    end;
    I only want to how to execute the content of varchar variable.
    For example, suppose that the result of this procedure is
    'SELECT SYSDATE FROM DUAL'
    How and what do I must do for this query execute like a normal query that is in apex?
    I expect your prompt reply.
    Thank you for your help.
    Best regards

    Let us say your table containing SQL is
    t_sql_table
    and has two columns
    primary_key
    and
    sql_query.
    You would need to do the following:
    1. Create a Report of type "Function returning SQL Query"
    2. Put the following there:
    DECLARE
       v_query   VARCHAR2 (4000);
    BEGIN
       SELECT sql_query
         INTO v_query
         FROM t_sql_table
        WHERE primary_key = 1;
       RETURN v_query;
    END;Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

Maybe you are looking for

  • Questions in Lync 2013 HADR

    Hi Team, One of the customer raised the query: In our scenario, we want Active/Active High availability between different geolocations with RPO=0 and RTO near zero (seconds). Questions: 1. Isn't this possible with pool pairing and database availabili

  • Create a MSDS for multiple Specifications via New Program

    Hi Friends I want to develope a new program, which will create MSDS (report) for multiple Specifications in Multiple languages and multple Generation variants. I can pull out specifications, Generation Variant and Languages for selection. My issues i

  • Calling Events in ALV

    hi friends, i have developed ALV and blocked ALV report, in that i want to use at line-selection event . if any body knows please let me know. thanks and regards.

  • Burner will only burn DVD RW all of a sudden???

    Sorry in advance about the long message I have a satellite U205 S5002 which i got used 3 months ago when i first got it i installed vista and everything was ok.( hardware-mat**bleep**a dvd-ram uj-842s ATA device) then a week ago, i bought a new pack

  • Trouble connecting Jboss 3.2.4 with Oracle 11g.

    We are facing some trouble connecting 4 JBoss servers to an Oracle 11g server. Oracle server is working as a RAC with two nodes. We have two HP server every one of those have two JBoss application servers version 3.2.4. Each one of those application