Dynamic procedure

I have to perform an execution of sql statements in a series when i call a stored procedure. The table name and the insert statements are given in the table. The execution will happen dynamically when i call a stored procedure.
Something like below. I have a table with two columns table name and statement
tahle_name Statement
emp_1 select empno, ename from emp@dblink;
dept_1 select deptno, deptname from dept@dblink
the emp_1 has same structure as emp table, dept_1 has same structure as dept table.
Now i will have a stored procedure which will read this statement column and will make an insert to emp_1 or dept_1 table ( eg, insert into emp_1 as select select empno, ename from emp@dblink).
the input to the stored procedure is just DBLink, this should replace the dblink which is given in the select statement dynamically.
so finally i will have two statement executed since there are two rows in the table, this is just an eg. this will be dynamic i can have any number of rows in the table, ultimatly this should perform an insert to each table for their corresponding sql statements given.
Any idea how can i write a stored procedure?
thanks

CREATE OR REPLACE PROCEDURE sp_load_appolo_data (i_dblink in varchar2, o_error_text out varchar2)
AS
TNAME VARCHAR2(50);
STATEMENT VARCHAR2(4000);
o_error_code varchar2(100);
tableid number(10);
BEGIN
FOR r IN (SELECT REPLACE (sql_statement, 'db_link', i_dblink) AS stmt,
table_name AS table_name, table_id
FROM REFRESH_TABLE_LIST)
LOOP
EXECUTE IMMEDIATE 'DELETE FROM ' || r.table_name ;
TNAME := R.TABLE_NAME;
STATEMENT :=R.STMT;
tableid := r.table_id ;
DBMS_OUTPUT.PUT_LINE('INSERT INTO ' || r.table_name || ' ' || r.stmt);
EXECUTE IMMEDIATE 'INSERT INTO ' || r.table_name || ' ' || r.stmt;
END LOOP;
o_error_text := null;
EXCEPTION WHEN OTHERS THEN
o_error_code := sqlcode;
o_error_text := substr(sqlerrm,1,500);
ROLLBACK;
sp_champ_error_log (o_error_code, o_error_text, TNAME, tableid, o_error_code||'-'||o_error_text,STATEMENT);
COMMIT;
END;
=============This above procedure is not handling the error, when execute immediate is thrown out with error, it has log that in the exeception handler. But it is not doing now.
Moreover the procedure is just breaking.. i dont want to terminate the procedure, it should always give procedure is successlly completed even if any error is throw. Since the error statments are logging to exception handler, the procedure has to be a success...
any suggestion why it is not going to exception when the execute immedite has thrown error??

Similar Messages

  • PL/SQL Dynamic procedure call - arrays

    I'm having a lot trouble dynamically calling procedures that have an array as a parameter value. It looks like it's not possible as I'm getting the deadly 'PLS-00707 unsupported construct or internal error [num]' message.
    Is that true, that I can't pass an array in a dynamic procedure call?
    The example procedure I'm calling is,
    PROCEDURE test(pusr in NUMBER,
    ptble IN VARCHAR2,
    prprt IN VARCHAR2,
    pccyy IN VARCHAR2,
    parea IN VARCHAR2,
    pregn IN VARCHAR2 DEFAULT null,
    poffc IN VARCHAR2 DEFAULT null,
    ptime IN VARCHAR2,
    pmnth IN NUMBER DEFAULT null,
    pqrtr IN NUMBER DEFAULT null,
    prow IN VARCHAR2 DEFAULT null,
    carray IN array_pcat)
    If I call it like this it works fine.
    uwsdm_web.test(pusr=> 100,
    ptble=>'mic',
    prprt=>'MIC3',
    pccyy=>'1999',
    parea=>'Statewide',
    pregn=>'0',
    poffc=>'0',
    ptime=>'Year',
    pmnth=>0,
    pqrtr=>0,
    prow=>'1,2,3,4',
    parray=> carray);
    where carray is the array.
    If I change the carray to a value (numeric or character), I get a "PLS-00306: wrong number or types of arguments in call to 'TEST'" error. Efforts to pass multiple values also failed.
    If I try to dynamically create the query and pass in the variable of carray, I run into similar problems because it's trying to allocate an array to one line of code.
    Any suggestions?
    Thanks.
    Kurt
    null

    Apologizes for disturbing you,
    as soon as I posted my question, I realized that there were some problems with the sintaxis I was using. Thank you very much and please excuse me for that silly question...
    Miguel-Angel

  • Using download_print_document with dynamic procedure

    I am using the version of download_print_document that calls a function (returning clob) for my reports (see below). I need to dynamicaly change the procedure being called in p_report_data line based on what report they run. Is it possible to store that in a DB column and pass that to the API or possibly use dynamic SQL etc?
    apex_util.download_print_document(
    p_file_name => l_form,
    p_content_disposition => 'attachment',
    p_report_data => sis_express_nj02.transcript (:P1,:P2,:P3),
    p_report_layout => l_layout,
    p_report_layout_type => 'rtf',
    p_document_format => 'pdf',
    p_print_server => null);*/

    Hi,
    Try something like:
    FUNCTION transcript (l_user in varchar2,
    l_owner in varchar2,
    l_report_order1 in varchar2,
    l_report_order2 in varchar2,
    l_report_order3 in varchar2,
    l_report_order4 in varchar2,
    l_start_yy in varchar2,
    l_resides_only in varchar2) return CLOB IS
    declare v_clob CLOB;
    l_p_report_data varchar2(30000) := 'sis_express_va23b.transcrip(
      v(''P507_APP_USER''),
    v(''P507_OWNER''),
    v(''P507_REPORT_ORDER''),
    v(''P507_REPORT_ORDER2''),
    v(''P507_REPORT_ORDER3''),
    v(''P507_REPORT_ORDER4''),
    v(''P507_YEAR''),
    v(''P507_RESIDES_ONLY'')
    begin
    execute immediate 'begin '|| ':1 := ' || l_p_report_data ||'; end;' using out v_clob;
    apex_util.download_print_document(
    p_file_name => l_form,
    p_content_disposition => 'attachment',
    p_report_data => v_clob,
    p_report_layout => l_layout,
    p_report_layout_type => 'rtf',
    p_document_format => 'pdf',
    p_print_server => null);
    end;The previous suggestion should work too but I think you don't you don't need *'* around l_p_report_data
    and you need OUT before v_clob parameter
    execute immediate l_p_report_data
    using OUT v_clob,l_user,lowner,l_report_order1,l_report_order2, ...Regards,
    Lev
    Edited by: le on Jan 12, 2011 1:09 PM
    Edited by: le on Jan 12, 2011 1:14 PM
    Edited by: le on Jan 12, 2011 1:17 PM

  • Executing dynamic procedure with record type

    Hi,
    I have a small issue...I'm not attaching any tables / data..etc...I just want to know how to pass the record type to a procedure (which are actually obtained from a table) dynaically..Unable to form the sql statement..
    I get an error saying that "wrong number or types of arguments in call to ||"...
    -- see ** below where I'm getting an error.
    .Need to pass the whole record type "l_shl_order_msg"
    CREATE OR REPLACE PROCEDURE CM_BUILD_MSG_PRC (P_IN_BLD_MSG_CURSOR IN SYS_REFCURSOR,
                                                  P_OUT_BLD_MSG_CURSOR OUT SYS_REFCURSOR)
    IS
    l_shl_order_msg CRAE_INTERFACE.GLB_VAR_PKG.deid_SHELL_order_typ;
    V_MSG_SHELL_NAME VARCHAR2(1000);
    V_MESG_TEXT_SEGMENT VARCHAR2(1000);
    V_TEXT VARCHAR2(1000);
    V_MSG_TEXT VARCHAR2(4000);
    V_MSG_FINAL_TEXT VARCHAR2(4000);
    V_MSG_PROC VARCHAR2(1000);
    V_SQL VARCHAR2(4000);
    V_CNT NUMBER;
    L_STATUS  VARCHAR2(100);
    L_REASON  VARCHAR2(1000);
    BEGIN
    LOOP
          FETCH P_IN_BLD_MSG_CURSOR
            INTO l_shl_order_msg;
          EXIT WHEN P_IN_BLD_MSG_CURSOR%NOTFOUND;
    END LOOP;
    Select mesg_shell_text, mesg_dynamic_var_count
      into V_MSG_TEXT, V_CNT
       from CRAE_MESG_MASTER
        where mesg_shell_name = l_shl_order_msg.SHELL_ID;
      For i in 1..V_CNT
        LOOP
            SELECT MESG_SHELL_NAME, MESG_TEXT_SEGMENT, PROCEDURE_NAME
             INTO V_MSG_SHELL_NAME, V_MESG_TEXT_SEGMENT, V_MSG_PROC
              FROM CRAE_MESG_MASTER_DETAIL
                WHERE I = MESG_SEQ_NUMBER
                 AND  mesg_shell_name = l_shl_order_msg.SHELL_ID;
      V_SQL:= 'BEGIN '||V_MSG_PROC||'(''' || l_shl_order_msg|| ''',' ||
         '''' || V_MSG_SHELL_NAME || ''',' || '''' || V_MESG_TEXT_SEGMENT
         || ''', CRAE_INTERFACE.GLB_VAR_PKG.V_TEXT );'||'END;';
        DBMS_OUTPUT.PUT_LINE(V_SQL);
         EXECUTE IMMEDIATE (V_SQL);
         V_TEXT := CRAE_INTERFACE.GLB_VAR_PKG.V_TEXT;
         IF I = 1
           THEN
         V_MSG_TEXT := REPLACE(V_MSG_TEXT,V_MESG_TEXT_SEGMENT,V_TEXT);
         V_MSG_FINAL_TEXT := V_MSG_TEXT;
         ELSE
           V_MSG_FINAL_TEXT := REPLACE(V_MSG_FINAL_TEXT,V_MESG_TEXT_SEGMENT,V_TEXT);
         END IF;
    END LOOP;
       DBMS_OUTPUT.PUT_LINE(V_MSG_FINAL_TEXT);
    -- L_STATUS := CRAE_INTERFACE.GLB_VAR_PKG.V_STATUS;
    -- L_REASON := CRAE_INTERFACE.GLB_VAR_PKG.V_REASON;
    OPEN  P_OUT_BLD_MSG_CURSOR
    FOR
        SELECT  l_shl_order_msg.MESSAGE_DATE_TIME,
                 l_shl_order_msg.MASKED_ID,
                 l_shl_order_msg.OFFSET_DATE,
                 l_shl_order_msg.PATIENT_ACCOUNT_NUMBER,
                 l_shl_order_msg.ORDER_CONTROL,
                 l_shl_order_msg.PLACER_ORDER_NUMBER,
                 l_shl_order_msg.QUANTITY,
                 l_shl_order_msg.INTERVAL,
                 l_shl_order_msg.DURATION,
                 l_shl_order_msg.START_DATE_TIME,
                 l_shl_order_msg.END_DATE_TIME,
                 l_shl_order_msg.PRIORITY,
                 l_shl_order_msg.ORDERING_DATE,
                 l_shl_order_msg.ENTERED_BY_ID,
                 l_shl_order_msg.ENTERED_BY_FAMILY_NAME,
                 l_shl_order_msg.ENTERED_BY_GIVEN_NAME,
                 l_shl_order_msg.ORDERED_BY_ID,
                 l_shl_order_msg.ORDERED_BY_FAMILY_NAME,
                 l_shl_order_msg.ORDERED_BY_GIVEN_NAME,
                 l_shl_order_msg.REPEAT_PATTERN,
                 l_shl_order_msg.DRUG_CODE,
                 l_shl_order_msg.DRUG_DESCRIPTION,
                 l_shl_order_msg.REQUESTED_GIVE_AMOUNT,
                 l_shl_order_msg.REQUESTED_GIVEN_UNIT,
                 l_shl_order_msg.SIG,
                 l_shl_order_msg.ALLOW_SUBSTITUTION,
                 l_shl_order_msg.REQUESTED_DISPENSE_AMOUNT,
                 l_shl_order_msg.REQUESTED_DISPENSE_UNIT,
                 l_shl_order_msg.REFILLS,
                 l_shl_order_msg.ROUTE,
                 l_shl_order_msg.STATUS,
                 l_shl_order_msg.REASON,
                 V_MSG_FINAL_TEXT,
                 T.COMP_ID,
                 T.PROC_ID,
                 T.Procedure_Desc
              FROM CRAE_MESG_rule_MASTER T
               WHERE MSG_SHELL_NAME = l_shl_order_msg.SHELL_ID;
    --  dbms_output.put_line (l_shl_order_msg.MESSAGE_DATE_TIME);
    END;** I get an error saying that "wrong number or types of arguments in call to ||"...
    Not sure how to pass record type dynamically...

    sb,
    declare
        l_shl_order_msg CRAE_INTERFACE.GLB_VAR_PKG.deid_SHELL_order_typ;
        V_MSG_SHELL_NAME VARCHAR2(1000);
        V_MESG_TEXT_SEGMENT VARCHAR2(1000);
        V_SQL VARCHAR2(4000);
        V_MSG_PROC VARCHAR2(1000);
        begin
        V_SQL := 'BEGIN '||V_MSG_PROC||'(l_shl_order_msg)'||'END;';
           DBMS_OUTPUT.PUT_LINE(V_SQL);
          end;when I execute this...l_shl_order_msg is passed as variable..but instead I want to pass all columns in the recordtype to be passed..
    ex : l_shl_order_msg.id, l_shl_order_msg.name....etc..
    This is what is being passed :
    BEGIN ATTRIBUTE_PRC( l_shl_order_msg ,'CDS_1','text-1', CRAE_INTERFACE.GLB_VAR_PKG..V_TEXT );
    ATTRIBUTE_PRC has already been defines as record type with i/p parameter..
    Edited by: user7431648 on Jul 26, 2012 8:25 AM
    Edited by: user7431648 on Jul 26, 2012 8:27 AM

  • Dynamic procedure to output csv file

    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE     11.1.0.6.0     Production
    TNS for Linux: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production
    I am trying to create a procedure to output a csv file, with the table name as input. I can get the field header out no problem, but am struggling with the data! Have looked at ref cursors, and dbms_sql, but am unsure which, if any, can be used for this?
    This is what I have so far:
    CREATE OR REPLACE PROCEDURE csv_extract_prc (in_table IN VARCHAR2)
    AS
       CURSOR c1
       IS
            SELECT   column_name
              FROM   user_tab_columns
             WHERE   UPPER (table_name) = UPPER (in_table)
          ORDER BY   column_id;
       v_output   VARCHAR2 (4000);
       v_file     UTL_FILE.file_type;
    BEGIN
       v_file :=
          UTL_FILE.fopen (location       => 'DATAPUMP',
                          filename       => in_table || '.csv',
                          open_mode      => 'w',
                          max_linesize   => 32767);
       FOR r1 IN c1
       LOOP
          v_output := v_output || r1.column_name || ';';
       END LOOP;
       UTL_FILE.put_line (v_file, v_output);
       UTL_FILE.fclose (v_file);
    EXCEPTION
       WHEN OTHERS
       THEN
          DBMS_OUTPUT.put_line (SQLERRM);
          UTL_FILE.fclose (v_file);
    END csv_extract_prc;
    CREATE TABLE test_table (field1 VARCHAR2 (10), field2 NUMBER (10));
    exec csv_extract_prc('test_table');Any pointers would be most welcome.

    Or this
    Re: how to make comma seperated file

  • Call dynamic procedure

    Hi gurus,
    I have a question, how call a procedure as in the next example ?
    create or replace package ppp....
    procedure a is
    pr varchar2(20):= 'b';
    begin
    b; -- Ok,
    --but, how call to the procedure b since pr variable???
    end;
    procedure b is
    begin
    dbms_output.put_line('Ok');
    end;
    end;--package
    thank's

    A possible solution:
    http://asktom.oracle.com/pls/ask/f?p=4950:8:10544037679792052173::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:30510198565645

  • Dynamic Sql Using Execute Immediate

    I am trying to construct a dynamic statement that takes in a supplied column name (COL_NAME), then do an Update on the column based on a supplied username. The table myTable has 4 columns and I would like to update a column thats supplied each time.
    NOT DYNAMIC
    PROCEDURE UpdateUser(aauser myTable.USERNAME%Type,COL_NAME varchar2, val varchar2) AS
    BEGIN
    Update myTable
    set userid = '002'
    where username= aauser;
    [b]DYNAMIC
    PROCEDURE UpdateUser(aauser myTable.USERNAME%Type,COL_NAME varchar2, val varchar2) AS
    BEGIN
    EXECUTE IMMEDIATE 'UPDATE myTable
    Set ' ||COL_NAME||' = val
    where myTable.username = aauser';
    END UpdateUser;
    However I get the following error when I execute this statement. Please help me.
    Connecting to the database Local.
    ORA-00904: "aaUser": invalid identifier
    ORA-06512: at "ANOLD.PUB", line 1433
    ORA-06512: at line 10
    Process exited.
    Disconnecting from the database Local.

    TEST@XE SQL> desc mytable
    Name                                                  Null?    Type
    USERNAME                                                       VARCHAR2(30)
    USERID                                                         VARCHAR2(30)
    COL3                                                           NUMBER
    COL4                                                           NUMBER
    TEST@XE SQL> insert into mytable values('TEST','001',1,2);
    1 row created.
    TEST@XE SQL> create or replace PROCEDURE UpdateUser(aauser myTable.USERNAME%Type,COL_NAME varchar2, val varchar2) AS
      2  BEGIN
      3     EXECUTE IMMEDIATE  'UPDATE myTable
      4     Set ' ||COL_NAME||' = ' || chr(39) ||val|| chr(39) ||
      5     ' where myTable.username = ' || chr(39) ||aauser|| chr(39);
      6  END UpdateUser;
    TEST@XE SQL> /
    Procedure created.
    TEST@XE SQL> exec UpdateUser('TEST','userid','002');
    PL/SQL procedure successfully completed.
    TEST@XE SQL> select * from mytable;
    USERNAME                       USERID                                    COL3            COL4
    TEST                           002                                          1               2
    TEST@XE SQL> exec UpdateUser('TEST','col3',111);
    PL/SQL procedure successfully completed.
    TEST@XE SQL> select * from mytable;
    USERNAME                       USERID                                    COL3            COL4
    TEST                           002                                        111               2
    TEST@XE SQL>

  • AT0 : static and dynamic processing

    dear guru ,
    whose are the differences in assembly to order with planned
    order between static and dynamic processing ?
    Thanks.

    Hi,
    Static assembly processing :
    If you create a sales order for a material with the 'assembly processing' technique, the system carries out an availability check for the components needed for the assembly and creates a single procurement element in the background.
    The procurement element is assigned to the sales order directly. The number of the procurement element is determined in the sales order.
    Dynamic assembly Processing :
    If you create a sales order for a material with the 'assembly processing' technique, the system carries out an availability check for the components needed for the assembly. Depending on the results of the availability check, either one or several procurement elements are created. The quantity for a one-time delivery and/or the next possible deadline for a full delivery and/or a delivery proposal with then ext possible deadline are displayed on the availabililty control screen.
    During dynamic assembly processing, you can not change the quantities and deadlines. You can, however, select the 'fix date and quantity' field, if necessary. The 'check scope' and 'other plants' functions are not available here.
    The procurement element numbers are not saved in the sales order. The link between the procurement element and the sales order is created using the number of the individual stage (sales order number/item). For this reason, it is possible to carry out another availability check taking into account incoming stock and additional, manually entered procurement elements.
    In Requirements class definition (OVZG), The assembly type indicator determines:
    - Which procurement element is created
    - Whether a 1:1 link exists between the sales order and the procurement element (static procedure) or whether a loose link exists with the option of splitting dates and quantities (dynamic procedure).
    In the case of static assembly order processing, you make the changes to the production order directly from the sales order.
    In the case of dynamic assembly order processing, you must call the production orders separately.
    Also refer link below for more details:
    http://help.sap.com/saphelp_47x200/helpdata/en/41/191eab45fd11d188ff0000e8322f96/frameset.htm
    Regards,
    Ashok

  • Dynamic perform

    Dear all,
    I wanted to create a dynamic perform. Here I will show u an example
          PERFORM get_correct_umlaut TABLES lt_bkpf.
          PERFORM get_correct_umlaut TABLES lt_bseg.
          PERFORM get_correct_umlaut TABLES lt_vbak.
    form get_correct_umlaut TABLES pt_any_table TYPE ANY TABLE.
    endform.                    " get_correct_umlaut
    I have a syntax error.  What is the right way to define a dynamic PERFORM like this???

    Hi,
    According to what you wrote, I suppose you want to achieve only quasi-dynamic procedure, since you are differentiating the type with case in your Form..
    Thus, I think that following approach will satisfy your requirements:
      DATA: it_mseg TYPE TABLE OF mseg,
            it_mkpf TYPE TABLE OF mkpf.
      SELECT *
        FROM mseg
        INTO TABLE it_mseg
        UP TO 100 ROWS.
      SELECT *
        FROM mkpf
        INTO TABLE it_mkpf
        UP TO 90 ROWS.
      PERFORM do_sth TABLES it_mseg.
      PERFORM do_sth TABLES it_mkpf.
    *&      Form  DO_STH
    FORM do_sth  TABLES   local_itab TYPE table.
      DATA: r_type TYPE REF TO cl_abap_structdescr,
            type_name TYPE string.
      FIELD-SYMBOLS: <mseg> TYPE mseg,
                     <mkpf> TYPE mkpf.
      r_type ?= cl_abap_typedescr=>describe_by_data( local_itab ).
      CALL METHOD r_type->get_relative_name
        RECEIVING  p_relative_name = type_name.
      CASE type_name.
        WHEN 'MKPF'.
          LOOP AT local_itab ASSIGNING <mkpf>.
            IF <mkpf>-budat EQ '20090101'. "just an example
    *         some calculations...          
            ENDIF.
          ENDLOOP.
        WHEN 'MSEG'.
          LOOP AT local_itab ASSIGNING <mseg>.
            IF <mseg>-menge GT '1000'. "just an example
    *         some calculations...          
            ENDIF.
          ENDLOOP.
        WHEN OTHERS.
    * skip
      ENDCASE.
    ENDFORM.                    " DO_STH
    Regards,
    MC
    Edited by: Marcin Cudo on Apr 21, 2010 12:43 PM

  • Cannot Connect to Oracle, PHP cannot load oci dlls

    Hello,
    I have installed wamp on windows server, and oracle 9, When I try to connect to oracle in php I get:
    Fatal error: Call to undefined function oci_connect() in C:\wamp\www\project2\index.php on line 3
    Also when I start wamp, it cannot load the oci dlls found on:
    C:\wamp\bin\php\php5.3.0\ext
    I have configured the php.ini file and commented as much options
    extension_dir = "C:/wamp/bin/php/php5.3.0/ext/"
    extension=php_oci8.dll ; Use with Oracle 10gR2 Instant ...
    extension=php_oci8_11g.dll ; Use with Oracle 11g Instant Client
    extension=php_oracle.dll
    extension=oci8.so
    I am unable to either connect to the database through php, also when I start wamp, i get pop up windows that it cannot load the dynamic procedures related to oracle: php_oce.dll, php_oce8.dll, php_pdo_oci,
    I have even eddited the http.conf file
    Also have done this:
    •Add the following entries to the "C:\Apache\Apache\conf\httpd.conf" file:
    LoadModule php4_module c:\php\sapi\php4apache.dll (approx line 193)
    AddModule mod_php4.c (approx line 241)
    AddType application/x-httpd-php .php (approx line 851)
    I have included the phpinfofile attached as well, part of it below is:
    System Windows NT SELECAO 5.2 build 3790 (Windows Server 2003 Standard Edition Service Pack 2) i586
    Build Date Jun 29 2009 21:23:30
    Compiler MSVC6 (Visual C++ 6.0)
    Architecture x86
    Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--disable-isapi" "--enable-debug-pack" "--with-pdo-oci=D:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8=D:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8-11g=D:\php-sdk\oracle\instantclient11\sdk,shared" "--with-enchant=shared"
    Server API Apache 2.0 Handler
    Virtual Directory Support enabled
    Configuration File (php.ini) Path C:\WINDOWS
    Loaded Configuration File C:\wamp\bin\php\php5.3.0\php.ini
    Configuration
    apache2handler
    Apache Version Apache/2.2.11 (Win32) PHP/5.3.0
    Apache API Version 20051115
    Server Administrator admin@localhost
    Hostname:Port localhost:80
    Max Requests Per Child: 0 - Keep Alive: on - Max Per Connection: 100
    Timeouts Connection: 300 - Keep-Alive: 5
    Virtual Server No
    Server Root C:/wamp/bin/apache/Apache2.2.11
    Loaded Modules core mod_win32 mpm_winnt http_core mod_so mod_actions mod_alias mod_asis mod_auth_basic mod_authn_default mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_dir mod_env mod_include mod_isapi mod_log_config mod_mime mod_negotiation mod_setenvif mod_php5

    I get this error, i decided to change directory for oracle_home
    putenv("ORACLE_HOME=C:/oracle/product/10.2.0/db_1/bin");
    to
    putenv("ORACLE_HOME=C:/oracle/product/10.2.0/db_1");
    it functioned.
    my code
    <?php
    putenv("ORACLE_HOME=C:/oracle/product/10.2.0/db_1");
    putenv("ORACLE_SID=PLSExtProc");
    $user ="name"; // set user
    $senha="password"; // set password
    $banco="(DESCRIPTION=
    (ADDRESS_LIST=
    (ADDRESS=(PROTOCOL=TCP)
    (HOST=127.0.0.1)(PORT=1521)
    (CONNECT_DATA=(SERVICE_NAME=orcl))
    )"; // configuracoes do banco (isso muda um pouco no oracle)
    if ($conexao = OCILogon($user,$senha,$banco))
    echo "Conexão bem sucedida.";
    else
    echo "Erro na conexão com o Oracle.";
    ?>

  • Do the custom rollup member formulas work recursively for parent child dimension?

    Hi
    We have custom rollup set up for Account dimension which is parent child.
    It seems to work fine when the custom member formula refers to a base account member i.e. if the formula for MemberKey4 is (MemberKey1 + MemberKey2) then it shows the sum of the underlying members 1 and 2.
    But if the formula for MemberKey10 is (MemberKey3 + MemberKey4) then it should evaluate the value for MemberKey4 first and then add to it value for MemberKey3 to come up with final number for MemberKey10.
    Do the custom rollup work fine with the recursive calculations? Is this recursion limited to some level?
    Thanks
    Shailesh

    Hi Jorg,
    Thanks for your input.
    Actually the hierarhcy is more determined by the parent child relationship. So we cannot move the members as per the formula. And further the formulas are not always additive, there are divisions and multiplactions happening also.
    Further the calculated members (account members) are used in different places, the usage level of calculated members could be 3 in some cases i.e. MemberKey15 = (calculated using MemberKey10 = (calculated using MemberKey7 = (Calculated using MemberKey4 = (calculated using base members)))). Now inserting the base members in place of a calcuated member becomes more of string manipulation.
    And on the top of above complexity, the formulas are not static and they are more user defined, they may change between time periods, which forces us to write a dynamic procedure to translate the 'business formula' into SSAS formula. We expect the custom rollup to work as expected (i.e. if the formula contains a calculation involving the calculated member, it should resolve that first and so on) and we have written generic procedure to replace the Account Code in the 'business formula' with the accont key value with the account hierarchy char string.
    In the link http://doc.ddart.net/mssql/sql2000/html/olapdmad/agmdxadvanced_6jn7.htm for AS2000, it talks about the calculation pass deapth, it says:
    .......If a cube has custom rollup formulas or custom rollup operators, a second calculation pass is performed to handle the computations needed to calculate these features.......
    Now from the above, it is obvious that the OLAP engine will automatically go into recursion if the formula contains a cacluated member and it knows that the calculated member has to be resolved first before calculating the final formula result. The above article also talks about 'Calculation Pass Number' property in the AdvanceCube Editor (AS2000), which can be set to the value depending on the expected number of passes required in a given scenario. I don't find such an equivalent peoperty for SSAS 2005.
    Would anybody please throw some more ideas / insights on this issue?
    Jorg, thanks  again for your input...
    Shailesh

  • How Indirect Referencing in Oracle PL/SQL

    hi,
    can u please help in write a pl/sql code that support the indirect referencing.
    the example given is the modified version of my actual requirement.
    declare
    x varchar2(10);
    y varchar2(10);
    begin
    x := 'y';
    y := 'abcd';
    end;
    can i print the value of y that 'abcd' by using variable X by some indirect reference.
    thanks

    Hi, Michael thanks for the reply.
    I am trying to replicate the Oracle Forms (D2K) functionality in PL/SQL. In Oracle Forms we have built-ins "NAME_IN" or "COPY. In most of the oracle env we normally have around 200 pl/sql packages/procedure/function. Most of us get the diff. errors from these procedures time to time. The currently i am also facing the same. so i decided the write a generic/dynamic procedure that will return the values of the parameter that is passed in the procedure.
    For this i made some changes in "who_call_me" procedure (originly written in "asktom.oracle.com site") now it will return the comma separated parameter list as out variable. Inside this procedure i am manipulating "dbms_utility.format_call_stack" and get the "package.procdure name". Ones i get the "package and procedure name" the cursor statement on "user_argument" table will give the entire "IN" parameters name.
    The comma separated parameter list I am returning to my main procedure.
    Now I want to print these values.
    See the code given below. I am sorry for that the code is bad shape. but it in working condition.
    Please follow the step given below…
    Step 1) connect to sqlplus user/passwd@conectstring
    Step 2)
    create or replace procedure who_call_me(
    parameter_list out varchar2 )
    as
    owner varchar2(100);
    name1 varchar2(100);
    lineno number;
    caller_t varchar(100);
    type Varchar2_Table IS TABLE OF user_arguments.argument_name%type INDEX BY BINARY_INTEGER;
    all_arguments Varchar2_Table;
    ARGUMENTS dbms_sql.NUMBER_table;
    SQL_STAT VARCHAR2(4000);
    pname VARCHAR2(50);
    call_stack varchar2(4096) default dbms_utility.format_call_stack;
    n number;
    found_stack BOOLEAN default FALSE;
    line1 varchar2(255);
    cnt number := 0;
    begin
    loop
    n := instr( call_stack, chr(10) );
    exit when ( cnt = 2 or n is NULL or n = 0 );
    line1 := substr( call_stack, 1, n-1 );
    call_stack := substr( call_stack, n+1 );
    if ( NOT found_stack ) then
    if ( line1 like '%handle%number%name%' ) then
    found_stack := TRUE;
    end if;
    else
    cnt := cnt + 1;
    if ( cnt = 2 ) then
    line1 := ltrim(substr(line1, instr(line1, ' ' )) );
    lineno := to_number(substr( line1, 1, instr(line1,' ') ));
    line1 := ltrim( substr( line1, instr(line1,' ' ) ) );
    if ( line1 like 'pr%' ) then
    n := length( 'procedure ' );
    elsif ( line1 like 'fun%' ) then
    n := length( 'function ' );
    elsif ( line1 like 'package body%' ) then
    n := length( 'package body ' );
    elsif ( line1 like 'pack%' ) then
    n := length( 'package ' );
    elsif ( line1 like 'anonymous%' ) then
    n := length( 'anonymous block ' );
    else
    n := null;
    end if;
    if ( n is not null ) then
    caller_t := ltrim(rtrim(upper(substr( line1, 1, n-1 ))));
    else
    caller_t := 'TRIGGER';
    end if;
    line1 := substr( line1, nvl(n,1) );
    n := instr( line1, '.' );
    owner := ltrim(rtrim(substr( line1, 1, n-1 )));
    name1 := ltrim(rtrim(substr( line1, n+1 )));
    -- dbms_output.put_line('line '||line1);
    -- dbms_output.put_line('owner '||owner);
    -- dbms_output.put_line('name '||name1);
    end if;
    end if;
    end loop;
    SQL_STAT := ' SELECT TRIM(SUBSTR(TXT,START_POS,END_POS-START_POS)) FROM
    select txt,
    CASE WHEN INSTR(txt,'||''''||'PROCEDURE'||''''||') <> 0 THEN INSTR(txt,'||''''||'PROCEDURE'||''''||')+9
    WHEN INSTR(txt,'||''''||'FUNCTION'||''''||') <> 0 THEN INSTR(txt,'||''''||'FUNCTION'||''''||') +8 END START_POS,
    CASE WHEN INSTR(txt,'||''''||' IS '||''''||') <> 0 THEN INSTR(txt,'||''''||' IS '||''''||')
    WHEN INSTR(txt,'||''''||' AS '||''''||') <> 0 THEN INSTR(txt,'||''''||' AS '||''''||') END END_POS
    FROM
    SELECT TXT FROM
    SELECT UPPER(TEXT) TXT, LINE LINENO, MIN(LINE) OVER() MIN_LINE
    from user_source us
    where us.name = '||''''||name1||''''||'
    and type = '||''''||caller_t||''''||'
    and ( upper(text) like '||''''||'%PROCEDURE%'||''''||' OR upper(text) like '||''''||'%FUNCTION%'||''''||')
    AND LINE <= 16
    ) WHERE LINENO = MIN_LINE
    EXECUTE IMMEDIATE(SQL_STAT) INTO pname;
    IF caller_t = 'PACKAGE BODY' THEN
    name1 := name1||'.'||pname;
    END IF;
    declare
    cursor c1 is select ARGUMENT_NAME
    from user_arguments where
    object_name = name1
    and decode(nvl(PNAME,'*'),'*','*', OBJECT_NAME) = nvl(PNAME,'*')
    AND ARGUMENT_NAME IS NOT NULL
    and in_out = 'IN'
    ORDER BY POSITION ;
    begin
    for i in c1 loop
    if parameter_list is not null then
    parameter_list := parameter_list||',';
    end if;
    parameter_list := parameter_list||i.ARGUMENT_NAME;
    end loop;
    end;
    end;
    step 3
    create or replace procedure my_test(empno varchar2,sal number) is
    x varchar2(4);
    begin
    x := 'abcdef';
    exception when others then
    declare
    my_parameter_list varchar2(4000);
    begin
    who_call_me(my_parameter_list);
    dbms_output.put_line('Parameter List---->'||my_parameter_list);
    end;
    end;
    Step 4)
    Sql> set serveroutput on
    SQL> execute my_test('sam',1000);
    Parameter List---->EMPNO,SAL
    PL/SQL procedure successfully completed.
    SQL>
    If u see the output of the My_Test is "EMPNO,SAL".
    now can u help to print the values that is 'sam',1000.
    Thanks
    Sanjeev Saxena
    My email id - [email protected]
    - [email protected]

  • Reading from .CSV and storing it into a collection

    Hi folks,
    Is there a way to make a dynamic procedure to work with .CSV documents and store it into a collection? For example you have to make a procedure to read from .CSV but users upload 10 different version that have different number of columns.
    Normally I would define a record type to match those columns and store it into a collection. However if I don't know the number of columns I would need to define 10 records in advance which I am trying to avoid.
    Problem is I cant define SQL elements on the fly. Meaning on production I don't have the rights to dynamically create a table to match my columns and then drop the table after I no longer need it so I need to store data into a collection.
    And the last option where I would loop through the document and then do the operations I need is not good since the document is a part of other procedures that write and read from it. The idea is to pick the data, store it into a collection, close the file and then work with it.
    This is what I got so far:
    declare
      -- Variables
      l_file      utl_file.file_type;
      l_line      varchar2(10000);
      l_string    varchar2(32000);
      l_delimiter varchar2(10);
      -- Types
      type r_kolona is record(
        column_1 varchar2(500)
       ,column_2 varchar2(500)
       ,column_3 varchar2(500)
       ,column_4 varchar2(500)
       ,column_5 varchar2(500));
      type t_column_table is table of r_kolona;
      t_column    t_column_table := t_column_table();
    begin
      /*Define the delimiter*/
      l_delimiter := ';';
      /*Open file*/
      l_file      := utl_file.fopen( 'some dir', 'some.csv', 'R');
      /*Takes first row of document as header*/
      utl_file.get_line( l_file, l_line);
      loop
        begin
          utl_file.get_line( l_file, l_line);
          /*Delete newline operator*/
          l_string                         := rtrim( l_line, chr(13)) || l_delimiter;
          /*Extend array and insert parsed values */
          t_column.extend;
          t_column(t_column.last).column_1 := substr( l_string, 1, instr( l_string, l_delimiter, 1, 1) - 1);
          t_column(t_column.last).column_2 := substr( l_string, instr( l_string, l_delimiter, 1, 1) + 1, instr( l_string, l_delimiter, 1, 2) - instr( l_string, l_delimiter, 1, 1) - 1);
          t_column(t_column.last).column_3 := substr( l_string, instr( l_string, l_delimiter, 1, 2) + 1, instr( l_string, l_delimiter, 1, 3) - instr( l_string, l_delimiter, 1, 2) - 1);
          t_column(t_column.last).column_4 := substr( l_string, instr( l_string, l_delimiter, 1, 3) + 1, instr( l_string, l_delimiter, 1, 4) - instr( l_string, l_delimiter, 1, 3) - 1);
          t_column(t_column.last).column_5 := substr( l_string, instr( l_string, l_delimiter, 1, 4) + 1, instr( l_string, l_delimiter, 1, 5) - instr( l_string, l_delimiter, 1, 4) - 1);
        exception
          when no_data_found then
            exit;
        end;
      end loop;
      /*Close file*/
      utl_file.fclose(l_file);
      /*Loop through collection elements*/
      for i in t_column.first .. t_column.last
      loop
        dbms_output.put_line(
             t_column(i).column_1
          || ' '
          || t_column(i).column_2
          || ' '
          || t_column(i).column_3
          || ' '
          || t_column(i).column_4
          || ' '
          || t_column(i).column_5);
      end loop;
    exception
      when others then
        utl_file.fclose(l_file);
    end; Stupid version would be to define a record with 50 elements and hope they dont nuke the excel with more columns :)
    Best regards,
    Igor

    Igor S. wrote:
    Use some to query data and then fix wrong entries on prod (insert, update, delete). Manipulate with some and then make new reports. The first that come to mind but basicly is to write a procedure that can be used for ANY .csv so I dont have to rewrite the code.This is logically wrong and smacks of poor design.
    You're wanting to take CSV files with various unknown formats of data, read that data into some generic structure, and then somehow magically be able to process the unknown data to be able to "fix wrong entries". If everything is unknown... how will you know what needs fixing?
    Good design of any system stipulates the structures that are acceptable, and if that means you know there are just 20 possible CSV formats and you can implement a mechanism to determine which format a particular CSV is in (perhaps something in the filename?) then you will create 20 known targets (record structures/tables or whatever) to receive that data into, using 20 external tables, or procedure or whatever is necessary.
    Doing anything other than that is poor design, leaves the code open to breaking, is non-scalable, hard to debug, and just wrong on so many levels. This isn't how software is engineered.
    For example you have 20 developers that have to work with .CSV files. So when someone has to work with a .CSV he would call a procedure with parameters directory and file name. And as a out parameter would get a collection with .CSV stored inside.As others have mentioned, give the developers an Apex application for their data entry/manipulation, working directly on the database with known structures and validation so they can't create "wrong" data in the first place. They can then export that as .CSV data for other purposes if really required.

  • Need to create file in unix (oracle directory path)

    Is it possible to create a file in oracle directory path (in unix folder).
    I am using a dynamic procedure to create the External Tables, when the given pattern file is present the procedure will create the External table, if the file is not present then it should create an empty file so that the corresponding External table would return zero(0) records. It should not fail.
    It has to be through plsql not using unix script.
    UTL_FILE.FGETATTR(V_DIR_NAME, V_FILE_NAME, V_EXISTS, V_FILE_LENGTH, V_BLOCKSIZE);
    IF v_exists=FALSE THEN
    --------create an empty file
    v_file_name:=empty_file;
    end if;
    --Create table script which will dynamically create the external table
    v_sql := 'CREATE TABLE '||V_RX_NAME||' ( '||RTRIM(v_cols,', ')||' )' ||
    ' ORGANIZATION EXTERNAL '||
    ' ( TYPE ORACLE_LOADER '||
    ' DEFAULT DIRECTORY "'|| v_dir_name || '"'||
    ' ACCESS PARAMETERS '||
    ' ( RECORDS DELIMITED BY NEWLINE '||
    ' LOAD WHEN ( '||RTRIM(v_null_cols,'and ')||')'||
    ' BADFILE '''||rec_mkt_name.SUBJECT_AREA_NAME||'_'||rec_mkt_name.PARAM_NAME||'.BAD''' ||
    ' DISCARDFILE '''||rec_mkt_name.SUBJECT_AREA_NAME||'_'||rec_mkt_name.PARAM_NAME||'.DISCARD''' ||
    ' LOGFILE '''||rec_mkt_name.SUBJECT_AREA_NAME||'_'||rec_mkt_name.PARAM_NAME||'.LOG'''||
    ' FIELDS TERMINATED BY ''~'' OPTIONALLY ENCLOSED BY ''"'' '||
    ' MISSING FIELD VALUES ARE NULL ' ||
    ' ) LOCATION ('''||V_FILE_NAME||''') ) REJECT LIMIT UNLIMITED';
    GV_CURR_STEP := v_sql;
    dbms_output.put_line(V_FILE_NAME) ;
    EXECUTE IMMEDIATE v_sql;
    ...........

    Saubhik wrote:
    Try to use utl_file.fopen with 'W'.Or maybe even with "A", and then close it. If you use "W" it will overwrite the file if it already exists. ;)

  • How to check IN paramers are oracle keywords or not

    Hello
    i am new in oracle word and i want to know, how i will check IN parameters are oracle keywords or not. if client using orale key wors as parameters then i will geneate error and exit from procedure..............
    Regards.
    Edited by: user13478428 on Dec 14, 2010 10:07 AM

    dear sir
    i am new already told. and i had write this dynamic procedure for a very good application.
    i am using on front end dotnet and backend oracle 10g. so i write a dynamic procedure which is using to delete record. but now i want check from frontend, user sen me exact parameters or used oracle keyword like /*, */, //, drop and many more. if user send me such (oracle reserved word) parameters then it will destory my datbase and slowdown my application working.
    so to stop such (oracle reserved word) as parameters , i check these parameters and stop my procedure execution.
    please any help,
    thanks,
    Edited by: user13478428 on Dec 14, 2010 10:07 AM

Maybe you are looking for

  • Windows 7 - "Tick" the box DNS "Register this connection's addresses in DNS

    Hi, i hope i have the right forum, this is DNS issue but on Windows 7 machines. I have been trawling the net looking for a fix. Basically we have some machines that are having DNS issues on various sites. I found one machine "register this connection

  • Webservice storing and JSP reading

    Hi Folks, I have a EJB turned into a webservice and deployed in Weblogic 8.1. Now when this webservice is invoked, I want to show the received message in a browser. What I want to do is write a java class with 'setmessage' and 'getmessage' methods. T

  • Euro Symbol display

    My 10g2 db is using the character set WE8MSWIN1252 and I even set NLS_CHARACTERSET to this value before launching my Windows application that uses the thin java client to connect to my Oracle db. The column is NCHAR and I can see the proper Euro symb

  • I can not  get java to work

    I don't don't know if i did something wrong but i can't get the program to work

  • Ios 5 update problem

    i was trying to update my iPod touch's iOS so i connected it to the computer and clicked 'update' and the download went smoothly up until the end of the download when iTunes was processing the file it showed an error (i don't remember what it was) bu