call the collection of sql

Hello guys,.

I just wonder can I get the SQL collection via PL/SQL. However, I can't call from pure SQL. In other words,.
create or replace type plch_number is table of number;

create or replace package den 
is

  my_arr plch_number := plch_number();
  procedure doldur(a pls_integer);
  function func2 return plch_number;

end;

create or replace
package body den 
is

procedure doldur(a pls_integer)
is
begin
  my_arr.extend(a);
  for i in 1..a
  loop
    my_arr(i) := i;
  end loop;
end;


function func2 return plch_number 
is
begin
  return my_arr;
end;

end;
I can run the following code without any errors.
set serveroutput on;
declare
  a integer;
begin
  den.doldur(10);
  select count(*) into a from table(den.my_arr);
  dbms_output.put_line(a);
end;


------------------------------------------
anonymous block completed
10
However, when run the code sql. Although it is almost the same code that I have run PL/SQL block, it gives an error, ORA-06553: PLS-221.
select * from table(den.my_arr);
ORA-06553: PLS-221
In addition, I can call the function from the package through SQL without any error. But why I can't invoke collections directly from SQL, why?
select * from table(den.func2);
Thank you.

970992 wrote:
OK, but I just want to know, why? I mean, is there a technical explanation?

Unfortunately, in ORACLE SQL & PL/SQL keep two separate motors. All SQL allows you to call is UDF (user-defined functions). You can't call procedures in SQL and you cannot reference package variables. Everything works and even this is not always possible - for example, you cannot call a UDF with OUT or IN OUT. You cannot call function PL/SQL defined parameter and return value types.

SY.

Tags: Database

Similar Questions

  • call the XMLQuery pl sql function

    Hi all.
    Is anyone know how to call the function sql pl by XMLQuery query?

    For example:

    I pl sql function "test()".

    And the desire to write this way:

    Select XMLQuery (' let $t = test()' returning content);

    How to change to work?

    Thanks for all the answers.
    Kind regards
    Anton.

    following should give you an idea:

    SQL> select xmlquery(('if (2*2 = ' || power(2,2) || ') then 1 else ()') returning content) x from dual
    
    X
    -----
    1
    1 row selected.
    
  • How to call the OFA PL/SQL procedure.

    Hello

    I'll call the pl/sql stored procedure of the OAF page (AM). the procedure is content parameter 3 IN 1 OUT parameter. all the parameters of character type is integer.


    I put the output parameter and it's returning the value, but I don't have how to configure the setting IN because the settings IN, I need to convert the INT data type number in java.

    Please help me.


    int in_parm1 = 0;
    Number in_param;
    Request_id number;
    request_id = new Number (0);
    getDBTransaction () .commit ();
    TXN OADBTransaction = getOADBTransaction();
    int l_user_id = txn.getUserId ();
    int l_resp_id = txn.getResponsibilityId ();
    int l_resp_appl_id = txn.getResponsibilityApplicationId ();
    Number of ln_user_id = new Number (l_user_id);
    Number of ln_resp_id = new Number (l_resp_id);
    Number of ln_resp_appl_id = new Number (l_resp_appl_id);
    CallableStatement cs = txn.createCallableStatement ("start oaf_request(:1,:2,:3,:4); end; ", 1) ;
    Try
    {
    System.out.println ("run ahead");
    cs.registerOutParameter (3, Types.VARCHAR, 0, 100);
    cs.registerOutParameter(1,in_param);
    cs.registerOutParameter(4,Types.NUMERIC);
    DSI Execute();
    in_parm1 = cs.getInt (4);
    request_id = new Number (in_parm1);
    System.out.println ("Request ID" + in_parm1);
    System.out.println ("run after");
    DSI Close();
    System.out.println ("result");
    }
    catch (System.Exception e)
    {

    throw OAException.wrapperException (e);

    }

    I would tell you to go through the "appeal of PL/SQL procedures and functions" Section in the User Guide.
    Example and the details are there reference.

    Thank you

  • To call the function in sql and script call

    Hello

    I'll have a .sql script that returns the name of the partition and I need to run alter table Exchange partition something like this

    get_part. SQL

    COLUMN file_name new_value by sub_script_col

    accept the start_date char prompt arguments ' input start (exact): '

    accept the end_date char prompt "enter end date (exact): '"

    create or replace function get_part_name (p_date in date)

    VARCHAR2 is back

    date d;

    RETP varchar2 (30);

    spirit date: = to_date('4444-01-01','yyyy-mm-dd');

    Str varchar2 (32000);

    cursor c is

    Select high_value, nom_partition p

    of all_tab_partitions

    where table_name = 'TO_TEHBLNC ';

    Start

    for r in c loop

    Str: = r.high_value;

    run immediately 'select'. Str |' double ' in d;

    If p_date < d and d, then the spirit

    RETP: = r.p;

    spirit: = d;

    end if;

    end loop;

    return pter;

    end;

    Select get_part_name ('& 1') twice;

    ACCEPT user_yn PROMPT ' do you want to partion with < partition name > table? (Y, N) : "

    SELECT THE CHECK BOX

    WHEN TOP (LTRIM (' & user_yn')) AS 'y %. "

    THEN "insert_partition".

    ELSE 'do_nothing.

    END AS sub_script_col

    DOUBLE;

    @ &sub_script_col < partition_name >

    sub_script_col. SQL

    ALTER TABLE to_tehblnc

    SWAP PARTITION < name patition >

    WITH TABLE T1

    WITHOUT VALIDATION

    UPDATE GLOBAL INDEXES;

    I need to call once again for the sub_script.sql based on start_date and end_date, for example 1st January 2015 and January 5, 2015 I must first get the parition name and proceed to modify the table with that respective partition name returned by the function, so that it will be 5 times alter the table to swap partition

    I'll have a .sql script that returns the name of the partition and I need to run alter table Exchange partition

    This is just a continuation of your other thread

    For the name of the partition in the partition range table

    As I said it you do not have to know the name of the partition to make an EXCHANGE. I gave you an example in this other thread.

    ACCEPT user_yn PROMPT ' do you want the table to partition with ? (Y, N) : "

    That makes no sense at all. You cannot partition a table that is already partitioned. If there is a name for the partition and then the table is partitioned already - then ask why to partition?

    ALTER TABLE to_tehblnc

    SWAP PARTITION

    WITH TABLE T1

    WITHOUT VALIDATION

    UPDATE GLOBAL INDEXES;

    I need to call once again for the sub_script.sql based on start_date and end_date, for example 1st January 2015 and January 5, 2015 I must first get the parition name and proceed to modify the table with that respective partition name returned by the function, so that it will be 5 times alter the table to swap partition

    No - you don't have. Just use the code example I provided in your other thread. You don't need to know the name of the partition and use dynamic sql statements to make the Exchange.

    Just use PARTITION syntax as shown in the example.

    Do things the EASY way. Your code and the script is totally useless.

  • ORA-900 sql not valid reporting error while calling the optimize_index pl/sql procedure


    Hi Experts,

    I'm on Oracle 11.2.0.3 on Linux and I have installed in my database Oracle text. I want to configure annex dbms_job to optimize my oracle text index. So first, I created a pl/sql procedure to optimize indexes. It gives me error ORA-900, but the sql even if I run in sqlplus works very well! Can you please help me the question is to find:

    Here is the procedure:

    (Either incidentally CTXAPP role has been granted in the schema where these Oracle text indexes are created and where the below procedure to optimize the index is running.)

    CREATE OR REPLACE PROCEDURE optimize_ora_txt_indexes_debug
    IS
       CURSOR cur_context_indexes
       IS
            SELECT index_name
              FROM user_indexes
             WHERE index_type = 'DOMAIN'
        AND ROWNUM<2  
        ORDER BY INDEX_NAME;
       v_user         VARCHAR2 (30);
       v_pod          VARCHAR2 (30);
       v_start_time   TIMESTAMP;
       v_end_time     TIMESTAMP;
       v_elapsed      VARCHAR2 (40);
       v_msg   VARCHAR2 (1000);
       v_error_code      NUMBER;
       v_error_msg   VARCHAR2 (1000);
       v_sql VARCHAR2 (1000);
    BEGIN
    
       FOR c IN cur_context_indexes
       LOOP
          BEGIN
            v_sql:= 'ctx_ddl.optimize_index (idx_name =>'||chr(39)|| c.index_name||chr(39)||', optlevel => '||chr(39)||'FULL'||chr(39)||')';
            dbms_output.put_line(v_sql);
            execute immediate v_sql;
          EXCEPTION
             WHEN OTHERS
             THEN
                v_error_code := SQLCODE;
                v_error_msg := SQLERRM;
                v_msg :=
                      'Error while optimizing the index '
                   || c.index_name
                   || ' '
                   || TO_CHAR (v_error_code)
                   || ' '
                   || v_error_msg;
                DBMS_OUTPUT.put_line (v_msg);
    
          END;
       END LOOP;
    
    EXCEPTION
       WHEN OTHERS
       THEN
          v_error_code := SQLCODE;
          v_error_msg := SQLERRM;
          v_msg :=
                'Error while in the optimize index procedure'
             || ' '
             || TO_CHAR (v_error_code)
             || ' '
             || v_error_msg;
          DBMS_OUTPUT.put_line (v_msg);
    
    END optimize_ora_txt_indexes_debug;
    /
    
     --the procedure compiles successfully. 
     Now when I run it , I get the error:
    SQL>exec optimize_ora_txt_indexes_debug;
    ctx_ddl.optimize_index (idx_name =>'ACCESS_CLNT_IDX04', optlevel => 'FULL')
    Error while optimizing the index ACCESS_CLNT_IDX04 -900 ORA-00900: invalid SQL
    statement
    
    
     --When I run the same command from sqlplus as execute statement , it works fine:
    SQL>exec ctx_ddl.optimize_index (idx_name =>'ACCESS_CLNT_IDX04', optlevel => 'FULL');
    PL/SQL procedure successfully completed.
     
     
    
    
    

    If everything runs from sqlplus, but fails in plsql... I'll be very grateful for pointers solve the problem.

    Thanks,

    OrauserN

    Hello

    It is a problem of pl/sql syntax. A call with EXEC is the same using BEGIN... Code of... END of block;

    SO, you need to include a beginning and an end to your call:

     v_sql:= 'BEGIN ctx_ddl.optimize_index (idx_name =>'||chr(39)|| c.index_name||chr(39)||', optlevel => '||chr(39)||'FULL'||chr(39)||'); END;';
    

    That's all.

    Herald tiomela

    http://htendam.WordPress.com

  • With the help of the collection within sql

    I have a function that returns a list of numbers. for example:
    CREATE TYPE integer_table_type AS TABLE OF INTEGER;
    
    CREATE OR REPLACE FUNCTION test_fnc
       RETURN integer_table_type
    AS
       return_var   integer_table_type;
    BEGIN
       SELECT   *
         BULK   COLLECT
         INTO   return_var
         FROM   (SELECT   1 FROM DUAL
                 UNION
                 SELECT   2 FROM DUAL
                 UNION
                 SELECT   3 FROM DUAL);
    
       RETURN return_var;
    END test_fnc;
    /
    I would use this function in a sql statement, without aid of a subquery, for example:
    WITH t1 AS (SELECT   1 f1 FROM DUAL
                UNION
                SELECT   2 FROM DUAL
                UNION
                SELECT   3 FROM DUAL
                UNION
                SELECT   4 FROM DUAL
                UNION
                SELECT   5 FROM DUAL
                UNION
                SELECT   6 FROM DUAL)
    SELECT   *
      FROM   t1
     WHERE   f1 IN (test_fnc);
    but I can't get it's running by using a subquery for example:
    WITH t1 AS (SELECT   1 f1 FROM DUAL
                UNION
                SELECT   2 FROM DUAL
                UNION
                SELECT   3 FROM DUAL
                UNION
                SELECT   4 FROM DUAL
                UNION
                SELECT   5 FROM DUAL
                UNION
                SELECT   6 FROM DUAL)
    SELECT   *
      FROM   t1
     WHERE   f1 IN (SELECT   * FROM table (test_fnc));
    Is this possible without having to return to the function in a subquery? Thank you.

    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production

    Try

    select *
      from t1
     where f1 member of test_fnc
    
  • Select in the collection?

    There is the following code
    declare
      type r is record( rid rowid, acct_id number );
      type t is table of r;
      v t := t();
    begin
      ...
      execute immediate v_sql bulk collect into v;
      ...
    end;
    run fills immediate collection with some data provided by the v_sql statement: table rowid and acct_id as a number. Is it possible to use this collection in one direction, while it would be possible to write later in this code:
    delete ACCOUNTS@db_link_to_remote_database
    where acct_id in ( *[here comes some magic subquery that supplies acct_id from collection]* )
    If it is possible how this can be done?

    No, you cannot use this exact collection in a SQL statement.

    If you can set the collection in SQL, as rp0428 has already suggested, you can use the collection in a SQL statement.
    If you could define the collection in a PL/SQL package, rather than in an anonymous PL/SQL block, you can write a function table in the pipeline that could be described as SQL. It is not clear to me that one of the restrictions you have is an inability to use named PL/SQL blocks.

    Justin

  • ON the collection of type of the object does not not with GROUP BY

    Hello

    I have an object of type with the collection defined as:
    create or replace type individu_ot as object (
       numero_dossier          number(10),
       code_utilisateur        varchar2(8 char),
       nom                     varchar2(25 char),
       prenom                  varchar2(25 char),
       map member function individu_map return number
    )
    /
    
    create or replace type body individu_ot is 
       map member function individu_map return number 
       is 
       begin
          return SELF.numero_dossier;
       end individu_map;
    end;
    /
    
    create or replace type individu_ntt is table of individu_ot
    /
    When I use simple SQL without no aggregation, the distinct keyword works well and returns me the separate entry of my type of object in the collection:
    SQL> select cast(collect(distinct individu_ot(indivmc.numero_dossier, indivmc.idul, indivmc.nom, indivmc.prenom)) as individu_ntt) as distinct_list
    from   site_section_cours    sisc
              inner join enseignant_section_mc   ensemc
              on sisc.code_session = ensemc.code_session and
                 sisc.numero_reference_section_cours = ensemc.numero_reference_section_cours
              inner join individu_mc indivmc
              on ensemc.numero_dossier_pidm = indivmc.numero_dossier
    where  sisc.seq_site_cours = 6
    
    DISTINCT_LIST(NUMERO_DOSSIER,CODE_UTILISATEUR,NOM,PRENOM)                                                                                                                                                                                             
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    INDIVIDU_NTT(INDIVIDU_OT(15,PROF5,Amidala,Padmé))                                                                                                                                                                                                     
    1 row selected.
    However in SQL with a wide range in group by, the separate no longer works.
    SQL> select *
    from   (
             select sisc.seq_site_cours,
                    cast(collect(distinct individu_ot(indivmc.numero_dossier, indivmc.idul, indivmc.nom, indivmc.prenom)) as individu_ntt) as distinct_list
             from   site_section_cours      sisc
                       inner join enseignant_section_mc   ensemc
                       on sisc.code_session = ensemc.code_session and
                          sisc.numero_reference_section_cours = ensemc.numero_reference_section_cours
                       inner join individu_mc indivmc
                       on ensemc.numero_dossier_pidm = indivmc.numero_dossier
             group by sisc.seq_site_cours
    )
    where seq_site_cours = 6
    
    SEQ_SITE_COURS DISTINCT_LIST(NUMERO_DOSSIER,CODE_UTILISATEUR,NOM,PRENOM)                                                                                                                                                                                             
    -------------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                 6 INDIVIDU_NTT(INDIVIDU_OT(15,PROF5,Amidala,Padmé),INDIVIDU_OT(15,PROF5,Amidala,Padmé),INDIVIDU_OT(15,PROF5,Amidala,Padmé),INDIVIDU_OT(15,PROF5,Amidala,Padmé),INDIVIDU_OT(15,PROF5,Amidala,Padmé))                                                     
    1 row selected.
    There are cases where I need to return collections with more than one, separate entries in it.

    Is there something that I am missing?
    Thank you
    Bruno

    Not a bug, rather an undocumented feature.

    Here are some alternatives that you can test:

    (1) using the operator SET to eliminate duplicates:

    SELECT sisc.seq_site_cours,
           set(
             cast(
               collect(individu_ot(indivmc.numero_dossier, indivmc.idul, indivmc.nom, indivmc.prenom))
               as individu_ntt
             )
           ) as distinct_list
    FROM site_section_cours sisc
         INNER JOIN enseignant_section_mc ensemc
                 ON sisc.code_session = ensemc.code_session
                 AND sisc.numero_reference_section_cours = ensemc.numero_reference_section_cours
         INNER JOIN individu_mc indivmc
                 ON ensemc.numero_dossier_pidm = indivmc.numero_dossier
    GROUP BY sisc.seq_site_cours
    ;
    

    (2) using the MULTISET with a subquery

    SELECT sisc.seq_site_cours,
           CAST(
             MULTISET(
               SELECT distinct
                      indivmc.numero_dossier, indivmc.idul, indivmc.nom, indivmc.prenom
               FROM enseignant_section_mc ensemc
                    INNER JOIN individu_mc indivmc
                            ON ensemc.numero_dossier_pidm = indivmc.numero_dossier
               WHERE sisc.code_session = ensemc.code_session
               AND sisc.numero_reference_section_cours = ensemc.numero_reference_section_cours
             )
             AS individu_ntt
           ) AS distinct_list
    FROM site_section_cours sisc
    ;
    
  • How to call the nested in the SQL table collection

    Please see the example below, how to attach the collection vmi_emp with history_emp table

    CREATE or REPLACE type vmi_emp as an object

    (empno varchar2 (500),)

    Ename varchar2 (500),

    HireDate date,

    SAL number (20));

    CREATE or REPLACE type nested_emp is table of the vmi_emp;

    declare

    v_type nested_emp;

    Start

    Select vmi_emp (empno, ename, hiredate, sal)

    bulk collect into v_type from emp;

    ???????????????? Select * from history_emp a, b vmi_emp where a.empno = b.empno

    end loop;

    end;

    Select * from history_emp has, b table (v_type) where a.empno = b.empno

  • Need to call the PL/SQL Package in the group dynamics of approval class that implements IDynamicApprovalGroup

    Hi all

    This is regarding the approval of invoice AP I need in my project where the user selects the users/people approval when creating the invoice based on logic. There may be any number of users who could be part of the approval group.

    Approval users information is stored in a table with a single Bill.

    When the user initiates invoice approval, approval of the Bill should go to all the people/users selected in the invoice.

    I created the dynamic of approval group which is the result of a java class. This java class implements IDynamicApprovalGroup. (what is the oracle Developer Guide).

    I called PL/SQL to java class package to get all the details of users of custom for the current invoice table.

    I used the DriverManager.getConnection method by hard coding (JDBC URL, Username, Pwd) connection details that works perfectly fine.

    But I don't want to hard-code the connection details because it will change in bodies SIT/UAT/PROD.

    Please ask you to guide me if there is no solution for the information of connection without hard coding it.

    Following code used to get the connection details

    try {}

    Class.forName ("oracle.jdbc.driver.OracleDriver");

    System.out.println ("= class loaded");

    }

    catch (ClassNotFoundException ex) {}

    System.out.println ("= class loading error");

    ex.printStackTrace ();

    }

    Fitting out = null;

    CallableStatement cstmt = null;

    Try

    {

    connection = DriverManager.getConnection ("jdbc:oracle:thin:@xxhostname:1521/SID", "FUSION", "*");

    Connection = GetConnection ();

    System.out.println ("= connection =" + connection);

    prepare the call

    cstmt = connection.prepareCall ("{call XX_AP_INV_DYN_APPROVAL_PKG. {GET_GROUP_PARTICIPANTS (?,?)} ») ;

    cstmt.setString (1, '12345');   ID on invoice

    Exit of the register

    cstmt.registerOutParameter (2, java.sql.Types.VARCHAR);

    Call the stored procedure

    cstmt. Execute();

    System.out.println ("= procedure being executed");

    approvalGroupMembers = cstmt.getString (2).split("#");

    System.out.println ("= output:" + cstmt.getString (2));

    }

    catch (Exception ex) {}

    ex.printStackTrace ();

    }

    Finally

    {

    Try

    {

    If (cstmt! = null)

    close the callable statement

    {

    cstmt. Close();

    cstmt = null;

    }

    System.out.println ("= stmt closed");

    }

    catch (SQLException ex)

    {

    System.out.println ("= stmt close err");

    ex.printStackTrace ();

    }

    Try

    {

    If (connection! = null)

    close the connection

    {

    Connection.Close;

    connection = null;

    }

    System.out.println ("= closed conn");

    }

    catch (SQLException ex)

    {

    System.out.println ("= Close conn err");

    ex.printStackTrace ();

    }

    }

    Thank you

    Dipak.

    HI Dembélé - you should be able to call the provider database from the java class. Documentation is here. However, you need to specify the name of the data provider that is the same in all environments. Do you know what it is? If it's not I'll take a look and get back to you.

    __

    Peter Maurer

    Relationship with the developers of Applications in fusion

    https://blogs.Oracle.com/fadevrel/

  • Call to Web Service of Oracle PL/SQL not to call the Web service in SOA Server

    Hello

    Try to call the Web service to oralce pl/sql function

    created a function

    Unable to invoke the web service from the server of the SOA.

    CREATE or REPLACE FUNCTION HelloWorld_WebServices(S_STRING Varchar2) RETURN VARCHAR2 as

    Server sys.utl_dbws. SERVICE;

    APPEL_ sys.utl_dbws. CALL;

    service_qname sys.utl_dbws. QNAME;

    port_qname sys.utl_dbws. QNAME;

    response sys. XMLTYPE;

    application sys. XMLTYPE;

    BEGIN

    sys.utl_dbws.set_http_proxy ("hostname: Port'");

    service_qname: = sys.utl_dbws.to_qname ("ns1", "process");

    Server: = sys.utl_dbws.create_service (service_qname);

    APPEL_: = sys.utl_dbws.create_call (server);

    sys.utl_dbws.set_target_endpoint_address (APPEL_, ' http:/host name: port/soa-infra/services/OFS/HelloWorld/helloworld_client_ep ');

    sys.utl_dbws.set_property (APPEL_, 'OPERATION_STYLE', 'process');

    asks: = sys. XMLTYPE ("< ns1:process xmlns:ns1 ="http://xmlns.oracle.com/OFSOrderServices/HelloWorld/HelloWorld"> < ns1:input > < / ns1:input > < / ns1:process > '"); 

    answer: = sys.utl_dbws.invoke (APPEL_, request);

    return response.extract('//HelloWorld/child::text() ','http://xmlns.oracle.com/OFSOrderServices/HelloWorld/HelloWorld'). getstringval(); 

    DBMS_OUTPUT. Put_line ("values of the OutputsVariables8");

    -Of return ';

    END;

    Run - the code below:

    Select HelloWorld_WebServices ('Hi') to double;

    Error:

    ORA-29532: Java call terminated by eception Java exception: java.lang.NoClassDefFoundError

    ORA-06512: at "SYS." UTL_DBWS', line 403

    ORA-06512: at "SYS." UTL_DBWS', line 400

    ORA-06512: at the 'APPS '. HELLOWORLD_WEBSERVICES', line 74

    29532 00000 - "Java call terminated by eception Java exception: %s."

    * Cause: A mistake or a Java exception has been reported and could not be

    solved by Java code.

    * Action: Modify Java code, if this behavior is not expected.

    Hello

    Fixed the error

    After loading once again of DBA and network provided access files JAR/JVM firewall

    and the correction on the threshold

    Return response.extract (' / result/child::text () ','xmlns = "http://xmlns.oracle.com/OFSOrderServices/HelloWorld/HelloWorld" '). getstringval();

  • Call the PL/SQL shell script

    Hi all

    I've seen several links and options for calling a PL/SQL shell script. I was wondering if there is something like DBMS_SCHEDULER. CREATE_PROGRAM-> executable that calls an external program in 11 GR 2.

    Here's what I have to. I have 11 GR 2 database with Dataguard. I have START triggering who begins a DBMS_SERVICE when the role becomes PRIMARY. In the same instance, I would stop the VIP on the former primary database and start the VIP on the new primary database.

    Thanks for the advice and assistance.

    Jan S.

    The URL below links to ask Tom. Inside, he talks about creating a Java procedure in your database that allows you to execute commands from the host OS (PL/SQL calls the proc of Java that runs the host command). There are several ways to run the OS commands, but this one is very flexible. I needed to use it for a task that I have who didn't fit one of the other methods very well.

    http://asktom.Oracle.com/pls/Apex/f?p=100:11:0:no:P11_QUESTION_ID:3069633370832

  • Need to call the Shell script that uses SQL loader in APex4.1 / 11g

    Hello!

    I have a requirement in which I need to call a shell script that connects to an external server, FTP to a file and then use sqlloader to load data into our table. We have now the ftp script that accomplishes this task to another program, but is a scheduled task. I wanted to call the script ftp in the APEX. Any suggestions on how this can be done, what is the logic of PL/SQL can we use? I saw online some people using DBMS Scheduler for this?

    Thank you
    Sun

    Hello

    Create some sh script on your computer host oracle where you can join in the external server and run the process.
    something like:

    run_external_sh.sh

    #!/bin/sh
    ssh ext_user@ext_host ./sqlloader/import/import.sh
    

    Then create an external TASK to call it via ORACLE (PL/SQL)

    -Shell Script call.

    BEGIN
      DBMS_SCHEDULER.create_program (
        program_name        => 'external_call_sh',
        program_type        => 'EXECUTABLE',
        program_action      => '/local_host/call_external/sh/run_external_sh.sh',
        number_of_arguments => 0,
        enabled             => TRUE,
        comments            => 'Call external SH script');
    END;
    /
    

    You can now create a regular / or unplanned WORK
    -Job defined by the calendar and an existing program.

    BEGIN
      DBMS_SCHEDULER.create_job (
        job_name      => 'jb_external_call_sh',
        program_name  => 'external_call_sh',
        schedule_name => 'external_call_scheduler', -- created scheduler
        enabled       => TRUE,
        comments      => 'Job defined by an existing external_call_sh program and schedule.');
    END;
    /
    

    You can now call the WORK in the APEX in the process of PL/SQL.

    BEGIN
      -- Run job synchronously.
      DBMS_SCHEDULER.run_job (job_name            => 'jb_external_call_sh');
    END;
    

    Concerning
    J :D

  • Doubt about the passage collection (Pl/SQL table) in a procedure.

    Hi all

    I have developed a package of sample with procedure 1. Here, I spent the output to a table in the collection data and I am passing the array of the collection as a parameter out.
    When I run the proc, it worked for 1 scenario, but did not work for the other. I posted two scenarios after the code.
    pkg spec:
    
    create or replace
    PACKAGE IMP_EXP_BKUP_PKG
    AS
      TYPE test10_tbl2 IS TABLE OF test10.t1%type INDEX BY BINARY_INTEGER;
      v2_test10 test10_tbl2;
      PROCEDURE manpower_list(v1 number, v2 out test10_tbl2);
    END IMP_EXP_BKUP_PKG;
    
    Pkg Body:
    
    create or replace
    PACKAGE BODY IMP_EXP_BKUP_PKG 
    AS 
    PROCEDURE manpower_list(v1 number, v2 out test10_tbl2)  AS
    BEGIN
      SELECT t1 BULK COLLECT INTO v2 FROM test10 WHERE t4 = v1; 
    END;
    END IMP_EXP_BKUP_PKG;
    Scenario 1:
    DECLARE
      v2 imp_exp_bkup_pkg.test10_tbl2;
    BEGIN
      imp_exp_bkup_pkg.manpower_list('10', v2);
      FOR i IN v2.FIRST..v2.LAST
      LOOP
        DBMS_OUTPUT.PUT_LINE(v2(i));
      END LOOP;
    END;
    Worked well.

    Scenario 2:
    DECLARE
      --v2 imp_exp_bkup_pkg.test10_tbl2;
      TYPE typ_tbl2 IS TABLE OF test10.t1%type INDEX BY BINARY_INTEGER;
      v2 typ_tbl2;
    BEGIN
      imp_exp_bkup_pkg.manpower_list('10', v2);
      FOR i IN v2.FIRST..v2.LAST
      LOOP
        DBMS_OUTPUT.PUT_LINE(v2(i));
      END LOOP;
    END;
    
    Error:
    ORA-06550: line 6, column 3:
    PLS-00306: wrong number or types of arguments in call to 'MANPOWER_LIST'
    Is not here.

    I want to just make sure that, are we supposed to use the same type that we have breeding stock in the package for the declaration of the variables?

    SamFisher wrote:

    I want to just make sure that, are we supposed to use the same type that we have breeding stock in the package for the declaration of the variables?

    Yes, you MUST use the same type definition.

    SY.

  • Call the file sql plsql

    Hello
    I'm stuck for several days in this issue. Hope someone help me.

    I'm using Oracle 11.

    I am writing a utility to purge the data from the database based on certain criteria.
    We do not have physical (actual) the partitions present on our system (since we do not use Enterprise edition).
    We have 57 paintings representing 57 partitions. Then, we create a view of all of these 57 tables-

    CREATE or REPLACE VIEW MY_VIEW AS
    Select [column_names] from table1
    UNION ALL
    Select [column_names] in table2
    UNION ALL
    Select [column_names] in table 3
    UNION ALL
    :
    :
    :
    Select [column_names] of table57
    ;

    This superior query is saved in the 'body' of user_views.

    Now when a user wants to delete a partition-
    -I read the body of the request in the .sql file.
    -Edit the .sql file that is, remove the unwanted ' select * from many '
    -Loss of vision.
    -Recreate the view from the edited .sql file.


    The question is in the creation of the view on the fly of the procedure-
    -I'm not EXECUTE IMMEDIATE 'CREATE VIEW... ' and ' DBMS_SQL. PARSE' the request body exceeds 32,767 characters.


    So I chose the option of filing to write. In the file, I write the query VIEW and then I want to create the view from this file.

    Now, I'm not able to call the .sql that contains
    CREATE OR REPLACE VIEW MYVIEW AS
    Select...
    UNION ALL
    Select...
    :
    :
    Select...

    Length of character of this file is about 90000.



    Please guide me in this issue.
    Any new idea to manage very large display in the long term is also welcome...


    Thanks in advance
    Micheline
    ARGE view at run time is also welcome...


    Thanks in advance
    Micheline

    When you use DBMS_SQL, the declaration must not end with a semicolon, or you will get ora - 911.

    ---------
    Sybrand Bakker
    Senior Oracle DBA

Maybe you are looking for

  • AT200 ICS (ice cream sandwich) 4.0 upgrade

    Hello No information on upgrading AT200 to ICS, anyone? Greetings from Munich

  • install the 32-bit NI DAQmx on Windows 10

    Read support on NI.com information reveals that the last version of the NOR-DAQmx drivers do not work with Windows 10 (64-bit). So we have uninstalled - in the hope that we could find an installer for the 32-bit version. Such a thing exists? Is it po

  • work disappered

    I can't update or install anything without an error message. My work disappered. I think I need to reinstall vista, but can't find my cd.  Holding of pls

  • Keep getting error this e feeder has stopped working

    Original title:? e power plate? I get a message that the "e Power Board stopped working. I have a Gateway laptop. My computer also slowed down considerably on the functions of the internet... I type and there to catch me, and I hit only 35 WPM! I'm n

  • p3dpythonw.exe has stopped working

    Thank you for your time. While you connecting to his game (pirates of the Caribbean), my daughter can choose a character to play, but when she chooses 'play' 53% of loading game she gets a message 'p3dpythonw.exe' has stopped working. Windows will se