PL/SQL Procedure issue.

Hi ,
Could any one of you guyz help me out in solving the below scenario?
I have written a procedure that contains only one select statement(No Inserts /Updates) for generating a report and calling that procedure from java using callable statement.
Problem:
The procedure executes in a quicker time when I request for one user .
But when I execute the same procedure for two different users using two sessions, it is taking more time to get executed and the performance is degrading when the number of users are increased.
Please find the execution times for different number of users requesting the procedure.
Users accesed execution time for procedure
1     80 seconds
2     171 seconds
3     More than 600 seconds
Please explain how oracle handles internally for processing the multiple sessions.

To add to what Justin said.
Oracle is designed at its very core to run multi copies of the same SQL and PL/SQL code. It does it very well. It can scale this very well. ...but only if designed and coded correctly.
Shooting from the hip, the symptoms you describe here are typical of code that enforces some form of serialisation. This means that system wide, only a single copy of that code can be executed at a time. For example, the code wants a gap free numbering sequence. So it locks the table against any changes. Finds the max sequence number used in the table. Increments it by one. Inserts a new row with that new sequence. Commits.
During this time, the very same piece of code executed by another user will wait for its turn to lock the entire table in order to perform these same steps. If there are 10 users, 9 other will queue one after the other behind user 1.
Serialisation is The Performance Killer on any multi-user and multi-processing system. And one thing that PL/SQL developers seem to forget is that they are writing code that can (and usually are) executed in parallel (by different sessions and users).
Know what you write and the impact of what you write on not just on other code, but on your very code that you are writing - as there can be more than one copy of your code running.

Similar Messages

  • XML Data from PL/SQL procedure -- special character issue (eBS)

    Hi All,
    I am developing a report, where the XML data is created by a PL/SQL procedure. I chose this approach over a data template, since there is a lot of processing involved in producing the actual data, and it cannot be done by select-statements alone. The report is run as a regular concurrent request.
    So far so good. There is a problem though. Every time the data contains special characters (ä, ö, umlauts), the concurrent request is completed with a warning, the log confirms that "One or more post-processing actions failed.", also there is no output file. The XML structure is valid as such. The report runs smoothly and produces the output when the XML data does not contain special characters.
    I am producing the XML lines by using the standard FND_FILE.PUT_LINE procedure: Fnd_File.put_line(Fnd_File.output, '<?xml version="1.0" encoding="UTF-8"?>'); This seems like a character encoding issue, but declaring the UTF-8 encoding in this way does not solve the problem.
    Any ideas what can be done to fix this? I have been searching Metalink but cannot find an answer. Many thanks for your kind help.
    Best Regards, Matilda

    Hi Rajesh,
    One idea I have, is that it might be possible to modify the PL/SQL code into a "before report" type trigger, attached to a data template. The code would process the data and write the lines into a temporary table, from which the data template could retrieve them in a simple select-query. However, it would be neat to be able to solve this without adding an extra layer of processing, since BI Publisher supposedly supports PL/SQL procedures as the data source.
    The data in this case is all correct, special characters are an intrinsic feature of the Finnish language. :)
    Best Regards, Matilda

  • PL-SQL procedure to fix Recycle Algorithm issues with Advanced Outbound

    Dear all,
    A customer is using Oracle Advanced Outbound 11.5.9. and we have an issue with recycle Algorithm.
    The issue is that for some cases we get outcome 32, 37 which is cache expired in table iec_g_return_entries and not the original outcome that agent has entered.
    Fortunately the original outcome exists in table jtf_ih_interactions so we have created a workaround in PL-SQL to update table iec_g_return_entries from jtf_ih_interactions using some common outcomes.
    Now after a long time the issue still exists and the customer want this workaround to be optimized, so that it takes all the values from recycle algorithm tables and not just the common outcomes and conditions.
    As I can see, there are so many condition in the algorithms and it is quite hard to catch all the conditions and create an PL-SQL procedure to update the iec_g_return_tables.
    Has anyone done something similar?
    Thanks a lot,
    Christos

    Dear all,
    A customer is using Oracle Advanced Outbound 11.5.9. and we have an issue with recycle Algorithm.
    The issue is that for some cases we get outcome 32, 37 which is cache expired in table iec_g_return_entries and not the original outcome that agent has entered.
    Fortunately the original outcome exists in table jtf_ih_interactions so we have created a workaround in PL-SQL to update table iec_g_return_entries from jtf_ih_interactions using some common outcomes.
    Now after a long time the issue still exists and the customer want this workaround to be optimized, so that it takes all the values from recycle algorithm tables and not just the common outcomes and conditions.
    As I can see, there are so many condition in the algorithms and it is quite hard to catch all the conditions and create an PL-SQL procedure to update the iec_g_return_tables.
    Has anyone done something similar?
    Thanks a lot,
    Christos

  • Obtaining HTML page by issuing a call from a PL/SQL procedure

    Is there any possibility to obtain HTMLDB -> HTML page from a user defined PL/SQL procedure ?
    For example I build an procedure which calls directly
    flows_010500.wwv_flow.show(null,p_flow_step_id=>'2',p_flow_id=>'104')
    and i try to read the result from htp.showpage, but I get a html response page with a security error.
    Maybe is necessary to initialize other parameters?
    Any help?

    Scott, I have got two pages in an application one is login page the other is welcome page. my login page will be process by store proceduer to validate the user based on users table that I have created on my schema. If the user login with username and password, if they exist on this table I will like to send them to welcome page. but I get http://htmldb.oracle.com/pls/otn/wwv_flow.accept.
    The page cannot be found
    The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.
    Please try the following:
    If you typed the page address in the Address bar, make sure that it is spelled correctly.
    Open the htmldb.oracle.com home page, and then look for links to the information you want.
    Click the Back button to try another link.
    Click Search to look for information on the Internet.
    HTTP 404 - File not found
    Internet Explorer
    the procedure is below:
    CREATE OR REPLACE PROCEDURE obj_pls_login_chk(p_UserName IN varchar2
    ,p_Password IN varchar2
    ,Login IN varchar2 ) IS
    l_usr_id number;
    l_url varchar2(2000);
    BEGIN
    l_url := 'http://htmldb.oracle.com/pls/otn/f?';
    select user_id into l_usr_id
    from s_cdm_users
    where upper(username) = upper(p_UserName)
    and upper(Password) = upper(p_Password);
    if l_usr_id is not null then
    l_url := l_url||'p=29921:2:4413779570974471450';
    --wwv_flow.show(null,p_flow_step_id=>'29921',p_flow_id=>'29921:2');
    --htp.print(p_UserName);
    end if;
    EXCEPTION
    when others then
    return;
    END

  • Execute CDC mappings from a PL/SQL procedure

    Hi,
    I´m using OWB 11.2.0.2 for Linux. I´ve created some CDC mappings to update cubes with changes coming from other tables and cubes (from the tables that implement those cubes with the relational option). The issues are:
    - The CDC mappings run successfully from the OWB (Project Navigator - Start), but I cannot execute them from a procedure in PL/SQL with the following code:
    PROCEDURE "PROC_RUNCDCMAPPINGS" IS
    --inicializar variables aquí
    RetVal NUMBER;
    P_ENV WB_RT_MAPAUDIT.WB_RT_NAME_VALUES;
    -- ventana principal
    BEGIN
    RetVal:= BARIK.CDC_LOAD_CUBO_RECARGA.MAIN(P_ENV);
    RetVal:= BARIK.CDC_LOAD_CUBO_TOR.MAIN(P_ENV);
    RetVal:= BARIK.CDC_LOAD_CUBO_TOAE.MAIN(P_ENV);
    RetVal:= BARIK.CDC_LOAD_CUBO_VIAJES.MAIN(P_ENV);
    RetVal:= BARIK.CDC_LOAD_CUBO_TICKETINCIDENCIA.MAIN(P_ENV);
    RetVal:= BARIK.CDC_LOAD_CUBO_LIQMONEDERO.MAIN(P_ENV);
    RetVal:= BARIK.CDC_LOAD_CUBOS_LIQTEMPORALES.MAIN(P_ENV);
    COMMIT;
    END;
    It doesn´t report any error (the value for RetVal after execution is 0), but the cubes are not loaded with changes, and the changes stored in the J$_%tables are not consumed.
    Some of the options that may impact in the mappings are:
    - All the CDC are of Simple type
    - There are more than one subscriber to consume the changes, as for some tables, its changes must feed more than one CDC.
    - All the mappings include only one execution unit per mapping.
    - The integration/load template is the default: DEFAULT_ORACLE_TARGET_CT
    Other question is: As I explained, I need more than one subscriber because same updates must be consumed by different CDC mappings, to load different cubes, but I´ve not been able to assign the subscribers to only the tables associated with them, so all the subscribers are subscribed to all the changes in all the CDC tables, but as many of those subscribers never consume the changes of same tables, in the J$_% tables remains the not consumed records, and I haven´t found the way to purge those tables (other than the delete from J$_), nor to assign the tables with the subscribers (so the subscribers are only subscribed to their interested changes, that will be consumed, so the tables will be emptied after the consumption).
    Any help with these problems will be greatly appreciated.
    Tell me if more info is needed to clarify the situation.
    Best regards,
    Ana

    Hi David,
    Thank you for your reply.
    These mappings are the mappings needed to update the cubes with the changes detected by the CDC system, they are located under the Mapping Templates folder and I´m using code templates for the control of the loading and the integration (the DEFAULT_ORACLE_TARGET_CT) mapping.
    What I need is to execute these mappings within a PL/SQL procedure that will be invoked from different tools.
    I´ve done it for regular mappings (not CDC mappings), and it works. The code is the same as for the CDC ones:
    PROCEDURE "PROC_RUNLOADMAPPINGS" IS
    --inicializar variables aquí
    RetVal NUMBER;
    P_ENV WB_RT_MAPAUDIT.WB_RT_NAME_VALUES;
    -- ventana principal
    BEGIN
    RetVal:= BARIK.LOAD_CUBO_RECARGA.MAIN(P_ENV);
    RetVal:= BARIK.LOAD_CUBO_TOR.MAIN(P_ENV);
    RetVal:= BARIK.LOAD_CUBO_TOAE.MAIN(P_ENV);
    RetVal:= BARIK.LOAD_CUBO_VIAJES.MAIN(P_ENV);
    RetVal:= BARIK.LOAD_CUBO_TICKETINCIDENCIA.MAIN(P_ENV);
    COMMIT;
    END;
    -- End of PROC_RUNLOADMAPPINGS;
    ,and when I run it, the mappings are executed, but with the CDC ones it doesn´t (even when no error is reported).
    I know that they are deployed in the selected agent (in my case the Default_Agent), but when I start them from the OWB, the mapping packages are created in the DB schema, so, I thought that maybe I could invoke them....so what you tell me is that the only way to invoke them is from SQL*Plus? not from a regular PL/SQL procedure?
    Thank you very much,
    Ana

  • PL/SQL procedure is 10x slower when running from weblogic

    Hi everyone,
    we've developed a PL/SQL procedure performing reporting - the original solution was written in Java but due to performance problems we've decided to switch this particular piece to PL/SQL. Everything works fine as long as we execute the procedure from SQL Developer - the batch processing 20000 items finishes in about 80 seconds, which is a serious improvement compared to the previous solution.
    But once we call the very same procedure (on exactly the same data) from weblogic, the performance seriously drops - instead of 80 seconds it suddenly runs for about 23 minutes, which is 10x slower. And we don't know why this happens :-(
    We've profiled the procedure (in both environments) using DBMS_PROFILER, and we've found that if the procedure is executed from Weblogic, one of the SQL statements runs noticeably slower and consumes about 800 seconds (90% of the total run time) instead of 0.9 second (2% of the total run time), but we're not sure why - in both cases this query is executed 32742-times, giving 24ms vs. 0.03ms in average.
    The SQL is
    SELECT personId INTO v_personId FROM (            
            SELECT personId FROM PersonRelations
            WHERE extPersonId LIKE v_person_prefix || '%'
    ) WHERE rownum = 1;Basically it returns an ID of the person according to some external ID (or the prefix of the ID). I do understand why this query might be a performance problem (LIKE operator etc.), but I don't understand why this runs quite fast when executed from SQL Developer and 10x slower when executed from Weblogic (exactly the same data, etc.).
    Ve're using Oracle 10gR2 with Weblogic 10, running on a separate machine - there are no other intensive tasks, so there's nothing that could interfere with the oracle process. According to the 'top' command, the wait time is below 0.5%, so there should be no serious I/O problems. We've even checked JDBC connection pool settings in Weblogic, but I doubt this issue is related to JDBC (and everything looks fine anyway). The statistics are fresh and the results are quite consistent.
    Edited by: user6510516 on 17.7.2009 13:46

    The setup is quite simple - the database is running on a dedicated database server (development only). Generally there are no 'intensive' tasks running on this machine, especially not when the procedure I'm talking about was executed. The application server (weblogic 10) is running on different machine so it does not interfere with the database (in this case it was my own workstation).
    No, the procedure is not called 20000x - we have a table with batch of records we need to process, with a given flag (say processed=0). The procedure reads them using a cursor and processes the records one-by-one. By 'processing' I mean computing some sums, updating other table, etc. and finally switching the record to processed=1. I.e. the procedure looks like this:
    CREATE PROCEDURE process_records IS
        v_record records_to_process%ROWTYPE;
    BEGIN
         OPEN records_to_process;
         LOOP
              FETCH records_to_process INTO v_record;
              EXIT WHEN records_to_process%NOTFOUND;
              -- process the record (update table A, insert a record into B, delete from C, query table D ....)
              -- and finally mark the row as 'processed=1'
         END LOOP;
         CLOSE records_to_process;
    END process_records;The procedure is actually part of a package and the cursor 'records_to_process' is defined in the body. One of the queries executed in the procedure is the SELECT mentioned above (the one that jumps from 2% to 90%).
    So the only thing we actually do in Weblogic is
    CallableStatement cstmt = connection.prepareCall("{call ProcessPkg.process_records}");
    cstmt.execute();and that's it - there is only one call to the JDBC, so the network overhead shouldn't be a problem.
    There are 20000 rows we use for testing - we just update them to 'processed=0' (and clear some of the other tables). So actually each run uses exactly the same data, same code paths and produces the very same results. Yet when executed from SQL developer it takes 80 seconds and when executed from Weblogic it takes 800 seconds :-(
    The only difference I've just noticed is that when using SQL Developer, we're using PL/SQL notation, i.e. "BEGIN ProcessPkg.process_records; END;" instead of "{call }" but I guess that's irrelevant. And yet another difference - weblogic uses JDBC from 10gR2, while the SQL Developer is bundled with JDBC from 11g.

  • DBI Reports Using PL/SQL Procedure

    Hi all,
    Is there anyone who worked on Creating a DBI report using a PL/SQL Procedure.
    I want to customize a Report that is using Data Source as of type PL/SQL Procedure.
    Please Reply to me If anyone has any Idea on this..
    Thanks in Advance..

    Hi Blushadow
    Now if i want to update say only 10 records at a time what should i put into my Proc?
    Please go thru my Proc below..
    CREATE OR REPLACE PROCEDURE PRTS.UPDT_ISSUE_USR_ROLE
    As
    Cursor cur_user_role Is
    Select a.org_id,a.user_id
    from prts_user a,issue_user_role b
    where a.user_id=b.user_id;
    upd_rec cur_user_role%rowtype;
    v_rows_processed Number:=0;
    Begin
    Open cur_user_role;
    Loop
    Fetch cur_user_role into upd_rec;
    If cur_user_role%NOTFOUND
    Then
    Exit;
    Else
    update Issue_user_role
    set User_org_nm=(Select full_org_nm from VW_Org where org_id=upd_rec.org_id)
    Where Issue_User_Role.rowid in
    (select issue_user_role.rowid
    FROM issue_user_role,issue,issue_workflow,Issue_step_dtl_wrkflw
    Where Issue_User_Role.Issue_Id=Issue.Issue_id
    And Issue_User_Role.Issue_id=issue_workflow.issue_id
    And Issue_User_Role.Workflow_compnt_id=Issue_Workflow.CURR_STEP_WORKFLOW_COMPNT_ID
    And Issue_User_Role.Workflow_compnt_id=Issue_Step_Dtl_wrkflw.Workflow_compnt_id
    And Issue_User_Role.Issue_id=Issue_Step_Dtl_wrkflw.Issue_Id
    And Issue.Issue_id=Issue_workflow.Issue_Id
    And Issue.Issue_id=Issue_Step_Dtl_Wrkflw.Issue_id
    And Issue_workflow.Issue_id=Issue_Step_Dtl_Wrkflw.Issue_id
    And Issue_Workflow.CURR_STEP_WORKFLOW_COMPNT_ID=Issue_Step_Dtl_wrkflw.Workflow_compnt_id
    And issue_workflow.primry_workflow_flag='Y'
    And issue_user_role.user_id = upd_rec.user_id
    And issue.issue_status_id in (1636,50738,275,50737,2090)
    And issue_step_dtl_wrkflw.Issue_step_status_id in (61248,61249,61250));
    v_rows_processed :=v_rows_processed + SQL%ROWCOUNT;
    If Mod (v_rows_processed,v_rows_processed)=10
    then
    COMMIT;
    End if;END IF;
    End Loop;
    Commit;
    dbms_output.enable(1000000);
    dbms_output.put_line('There were '||v_rows_processed||' rows updated');
    Close cur_user_role;
    End;
    I would appreciate if you can let me know any other alternative way to meet this requirment.
    Cheers
    Vineet

  • Deploy warnings using a PL/SQL procedure (from a Public Transform Package)

    OWB Version: 10.2
    I am receiving the following warnings when I attempt to deploy a map that contains a reference to a custom pl/sql procedure that is setup in a public transformation package:
    Warning
    ORA-06550: line 115, column 32:
    PLS-00112: end-of-line in quoted identifier
    ORA-06550: line 115, column 9:
    PLS-00103: Encountered the symbol "." when expecting one of the following:
    := . ( @ % ; not null range default character
    I reviewed the OWB generated code and I discovered the OWB is a adding two double quotes in front of any reference to the package name. For example.....
    BEGIN
    COMMIT;
    sql_stmt := 'ALTER SESSION DISABLE PARALLEL DML';
    EXECUTE IMMEDIATE sql_stmt;
    IF NOT ""ZZTEST"."INIT_SF_USER_CLAS_St" THEN
    * note the "" in front of ZZTEST, which is the package name.
    Has anyone else encountered this issue? I can manually correct the generated the code, but it would be overridden every the time the map is deployed. I encounter the same issue if I import a custom pl/sql procedure from the database into OWB using the Metadata Import Wizard and use the imported procedure in a map. However, I can setup an standalone procedure or function as a public transformation and the map deploys successfully. Please advise.
    Regards,
    Matt

    You have to create a job to start your procedure.
    Example :
    * http://psoug.org/reference/OLD/dbms_job.html
    Then create a procedure to start your job, call it from your dashboard and you're done.
    Success
    Nico

  • How to pass values to select clause in PL/SQL procedure

    Am relatively new to PL/SQL programming and ran into the following issue...
    Table
    EMP_MASTER
    ID VARCHAR2(10);
    FIRSTNAME VARCHAR2(20);
    DATA FOR EMP_MASTER
    '1','SCOTT'
    '2','TIGER'
    I ran the following SQL Query
    SELECT COUNT(*) FROM EMP_MASTER WHERE FIRSTNAME IN ('SCOTT','TIGER');
    This select Query is working fine and we get the count = 2 as
    expected. Now I want a procedure for the same fn()
    CREATE OR REPLACE PROCEDURE TEST_EMP_MASTER(NAMELIST IN VARCHAR2)
    IS
    CNT NUMBER := 0;
    BEGIN
    SELECT COUNT(*) INTO CNT FROM EMP_MASTER WHERE FIRSTNAME IN (NAMELIST);
    DBMS_OUTPUT.PUT_LINE('Output-->NAMELIST:'||NAMELIST||':cnt:'||cnt);
    END;
    Now when I test the procedure by passing just one value its working
    fine. But when I want to pass multiple values, it doesnt work!
    set serveroutput on;
    i.e exec TEST_EMP_MASTER('SCOTT'); Works and the output is
    Output--->NAMELIST:SCOTT:cnt:1
    but don't get the expected output for exec TEST_EMP_MASTER('SCOTT,TIGER');
    I understand that the IN modifier in the WHERE clause expects the
    values as 'Value1','value2'....I tried different combination by the
    passing the values with quotes '''value1'',''value2'''.....but no
    success

    Select  e.*
    From EMP_MASTER e;
            ID     FIRSTNAME
    1     1     SCOTT
    2     2     TIGER
    3     3     CAT
    4     4     MOUSE
    SQL> create or replace procedure count_emp_master (p_namelist VARCHAR2)
      2  AS
      3     v_namelist   VARCHAR2 (1000) := p_namelist;
      4     v_name Varchar2(100);
      5     v_count Number := 0;
      6     p_count_emp  Number := 0;
      7  BEGIN
      8     v_namelist := ',' || v_namelist || ',';
      9 
    10     FOR cur IN 1 .. LENGTH (v_namelist) - LENGTH (REPLACE (v_namelist, ',', '')) - 1
    11     LOOP
    12        v_name := (SUBSTR (v_namelist,
    13                          INSTR (v_namelist, ',', 1, cur) + 1,
    14                          INSTR (v_namelist, ',', 1, cur + 1)
    15                          - INSTR (v_namelist, ',', 1, cur) - 1
    16                         ));
    17     Select Count(1)
    18     Into v_count
    19     From emp_master
    20     Where FIRSTNAME =  v_name;
    21 
    22     p_count_emp := p_count_emp + v_count;;
    23 
    24     END LOOP;
    25 
    26     dbms_output.put_line ('namelist --> '||p_namelist ||'p_count_emp -->'||p_count_emp);
    27  END count_emp_master;
    28  /
    Procedure created
    SQL> exec count_EMP_MASTER('SCOTT');
    namelist --> SCOTTp_count_emp -->1
    PL/SQL procedure successfully completed
    SQL> exec count_EMP_MASTER('SCOTT,TIGER');
    namelist --> SCOTT,TIGERp_count_emp -->2
    PL/SQL procedure successfully completed
    SQL> exec count_EMP_MASTER('SCOTT,TIGER,CAT');
    namelist --> SCOTT,TIGER,CATp_count_emp -->3
    PL/SQL procedure successfully completed
    SQL> exec count_EMP_MASTER('SCOTT,TIGER,CAT,MOUSE');
    namelist --> SCOTT,TIGER,CAT,MOUSEp_count_emp -->4
    PL/SQL procedure successfully completed
    SQL> Message was edited by:
    Nicloei W

  • How to enable MSDOS program to be called from Oracle PL/SQL procedure ( Web Service )?

    Hello,
    Dealing with the time demanding procedure where power user is interactively execute sequence
    of steps of procedure:
    1. pl/sql procedure for preparing data in some table
    2. java program that read data from the table and creating input txt file for MSDOS program
    3. MSDOS program is autonomous component that reads input txt file and make
        output txtfile.
        MSDOS program is closed component, can not be modified
    4. java program that insert txtfile into Oracle table.
    5. Steps 1 to 4 are executed in interations driven with select on some table.
    Trying to prepare re-design the procedure  and not sure about which technologies to use ?
    The goal is that whole procedure would be implemented in pl/sql procedure and this way could be executed
    so as from power user from command line as from controlled application on any type of the client.
    So if that MSDOS program would be transformed as Web Service offered on  some MSWin server in the intranet.
    Then PL/SQL procedure would communicate ( call this web service ) and do all the job and at the end
    send status of completion and report through e-mail to the issuer of the procedure?
    Not sure what technologies should I use on Oracle RDBMS server on Linux to communicate with MSWin Web service which is running MSDOS program ?

    > Hi TOM,
    This is not asktom.oracle.com.
    > Can Possible to do in Oacle Pl/Sql...?
    Yes it can be done. Simply consult the applicable manuals that contains all of the details on how to do it. The manuals are:
    - Oracle® Database Application Developer's Guide - Large Objects (refer to Chapter 6 section on Using PL/SQL (DBMS_LOB Package) to Work with LOBs)
    - Oracle® Database PL/SQL Packages and Types Reference (refer to the chapter on DBMS_LOB)

  • Alert javascript in PL/SQL procedure

    Hello,
    On clicking on a button to execute an sql command, If I test a value=0, so I would like to show a message like alert("Impossible to do that !");
    Is it possible ?
    Here is my very simple PL/SQL procedure :
    declare
    nbwo number(10);
    begin
    select count(*) into nbwo from [email protected] where lticketid=:P63_lticketid;
    if nbwo > 0 then
    update [email protected] set etat=1 where lticketid=:P63_lticketid;
    commit;
    else
    "Show a javascript alert"
    end if;
    end;
    Thanks for help,
    Fred

    Fred,
    If you are rendering a page you can make a plsql process generate html that the browser can display. htp.p(' html here');
    declare
    nbwo number(10);
    begin
    select count(*) into nbwo from [email protected] where lticketid=:P63_lticketid;
    if nbwo > 0 then
    update [email protected] set etat=1 where lticketid=:P63_lticketid;
    commit;
    else
    htp.p(' html here');
    end if;
    end;
    However I can see you having some issues.
    1: You need to call a page and have this process run while the page renders. It won't work for a submit process. It is still possible.
    2: You need to decide what to do with the page you are rendering. You could render the page as normal and just pop this html code in before the footer.
    Probably the best bet is to do this with an ajax call. eg press button, call jscript function, jscript function calls database to do this work, database call returns a success or fail message. Display results to user.
    I would recommend the ajax call. It works very well for this type of thing.
    Chris

  • Are the Pl/sql procedure and function atomic by themself

    i want to ask a question does oracle pl/sql procedure and function support Atomicity for the database by themself , or they became atomic incase we call them using begin -- end;

    You appear to be discussing transaction scope which is completely independent of PL/SQL blocks like procedures or how you call procedures. It's all in where commits (or rollbacks) are issued.
    If you have a procedure like this
    CREATE PROCEDURE p1
    AS
    BEGIN
      INSERT INTO some_table( key, value ) VALUES( 1, 'Foo' );
      INSERT INTO some_table( key, value ) VALUES( 1, 'Bar' );
    END;where the first statement succeeds and the second statement fails as a result of a duplicate key, there will still be a Foo row in the table but the procedure will have thrown an exception. The caller of the procedure may choose to commit or rollback the change-- that will determine whether the first statement's results are made permanent. If you have a procedure like this,
    CREATE PROCEDURE p1
    AS
    BEGIN
      INSERT INTO some_table( key, value ) VALUES( 1, 'Foo' );
      commit;
      INSERT INTO some_table( key, value ) VALUES( 1, 'Bar' );
    END;the commit will make the first insert permanent regardless of whether the second statement fails no matter what the calling code does (that's one reason that putting commits in stored procedures is generally a bad idea-- the caller is in a much better position to know what other uncommitted work has been done and whether it is safe to commit.
    Justin

  • How to call sql loader ctrl file with in the pl/sql procedure

    Hi Friends,
    I am doing a project related with the transferring data using queues. In the queue , I will get a tab delimited data in the form of CLOB variable/message. I do want to store that dat in the oracle table.
    When updating data into the table ,
    1. Don't want to write that data into a file.( Want to access directly after dequeueing from the specfic queue).
    2. As the data is in tab delimited form, I want to use sql loader concept.
    How do I call the sql loader ctrl file with in my pl/sql procedure. When I searched , most of the forums recommending external procedure or Java program.
    Please Guide me on this issue. my preferrence is pl sql, But don't know about external procedure . If no other way , I will try Java.
    I am using oracle 9.2.0.8.0.
    Thanks in advance,
    Vimal..

    Neither SQL*Loader nor external tables are designed to read data from a CLOB stored in the database. They both work on files stored on the file system. If you don't want the data to be written to a file, you're going to have to roll your own parsing code. This is certainly possible. But it is going to be far less efficient than either SQL*Loader or external tables. And it's likely to involve quite a bit more code.
    The simplest possible thing that could work would be to use something like Tom Kyte's string tokenization package to read a line from the CLOB, break it into the component pieces, and then store the different tokens in a meaningful collection (i.e. an object type or a record type that corresponds to the table definition). Of course, you'll need to handle things like converting strings to numbers or dates, rejecting rows, writing log files, etc.
    Justin

  • PL/SQL speed issues when using a variable

    I have a very strange issue that is causing problems.
    I am running Golden connecting to a 11g database.
    I created a procedure to insert records into a table based on a query. The source query includes variables that I have populated prior to the insert statement. The problem is that if I use the variable for one very specific where statement, the statement goes from running in less than 1 second, to running in 15 minutes. It gets even more strange though. Not only does a 2nd variable not cause any problems, the exact same variable in the same statement works fine.
    This procedure takes 15 minutes to run.
    declare
        v_start_period date;
        v_end_period date;
    begin
        select add_months(trunc(sysdate,'mm'), -1), trunc(sysdate,'mm')
        into v_start_period, v_end_period
        from dual;
        insert into RESULTS_TABLE
                (first_audit_date, last_audit_date,
                data_column1, data_column2, data_column3)
            select
                a.first_audit_date, a.last_audit_date,
                b.data_column1, b.data_column2, b.data_column3
            from
                SOURCE_TABLE_1 b,
                (select marker_id, min(action_time) as first_audit_date, max(action_time) as last_audit_date
                    from SOURCE_TABLE_2
                    where action_time >= v_start_period and action_time < v_end_period
                    group by marker_id) a
            where b.marker_id = a.marker_id
                and exists (select 1 from SOURCE_TABLE_2
                    where marker_id = b.marker_id
                    and action_time >= v_start_period and action_time < v_end_period
                    and action_type = 'XYZ');
        commit;
    end;This procedure runs in less than 1 second, yet returns the exact same results.
    declare
        v_start_period date;
        v_end_period date;
    begin
        select add_months(trunc(sysdate,'mm'), -1), trunc(sysdate,'mm')
        into v_start_period, v_end_period
        from dual;
        insert into RESULTS_TABLE
                (first_audit_date, last_audit_date,
                data_column1, data_column2, data_column3)
            select
                a.first_audit_date, a.last_audit_date,
                b.data_column1, b.data_column2, b.data_column3
            from
                SOURCE_TABLE_1 b,
                (select marker_id, min(action_time) as first_audit_date, max(action_time) as last_audit_date
                    from SOURCE_TABLE_2
                    where action_time >= v_start_period and action_time < trunc(sysdate,'mm')
                    group by marker_id) a
            where b.marker_id = a.marker_id
                and exists (select 1 from SOURCE_TABLE_2
                    where marker_id = b.marker_id
                    and action_time >= v_start_period and action_time < v_end_period
                    and action_type = 'XYZ');
        commit;
    end;The only difference between the two is where I replace the first v_end_period variable with trunc(sysdate,'mm').
    I've been googling for possible solutions and keep running into something called "parameter sniffing". It appears to be a SQL Server issue though, as I cannot find solutions for Oracle. I tried nesting the insert statement inside it's own procedure with new variables populated by the old variables, but nothing changed.
    Edited by: user_7000017 on Jan 8, 2013 9:45 AM
    Edited by: user_7000017 on Jan 8, 2013 9:52 AM Put the code in code tags.

    You are not describing procedures. You are listing anonymous PL/SQL blocks.
    As for the code - this approach to assigning PL/SQL variables are highly questionable. As the functions are native PL/SQL functions too, there is no need to parse and execute a SQL cursor, do context switching, in order to assign values to PL/SQL variables.
    This is wrong:
    select
        add_months(trunc(sysdate,'mm'), -1), trunc(sysdate,'mm')
        into v_start_period, v_end_period
    from dual;This is correct:
    v_start_period := add_months(trunc(sysdate,'mm'), -1);
    v_end_period := trunc(sysdate,'mm');Just as you would not use +"select 1 into plVariable from dual;+", instead of a standard variable assignment statement like +"plVariable := 1;"+.
    As for the performance/execution difference. Does not make sense. I suggest simplifying the code in order to isolate the problem. For example, take that in-line SQL (aliased as a in the main SQL) and create a testcase where it uses the function, versus a PL/SQL bind variable with the same data type and value as that returned by the function. Examine and compare the execution plans.
    Increase complexity (if no error) and repeat. Until the error is isolated.
    The 1st step in any troubleshooting, is IDENTIFYING the problem. Without knowing what the problem is, how can one fix it?

  • Thread safe operations on table in pl/sql procedure?

    I am developing java application which will be running in N localizations simultaneously, each application will have M threads. Every thread takes an unique ID with status NOT_TAKEN from table Queue and changes its status to TAKEN.
    Problem:
    How to prevent thread from situation like this:
    1. Thread A select first ID with status NOT_TAKEN
    2. In the same time thread B select first (so it will be the same ID which selected thread A) ID with status NOT_TAKEN.
    3. Thread A changes status of ID to TAKEN
    4. Thread B changes status of ID to TAKEN
    After this operation thread A and B are using the same ID.
    What I did:
    I have written pl/sql procedure which lock table Queue in exclusive mode, selects first ID, changes its status to TAKEN and unlocks the table. Because it is lock in exclusive mode so only one thread can run this procedure simultaneously.
    Question:
    How optimally should it be solved, because mine solution prevents from doing all other Updates on Queue table while it is locked, like changing status from TAKEN to OPERATION_DONE so it has performance issue.

    As Centinul has said, you need to lock just one row.
    I would just add NOWAIT to the select statement to let the Java thread go and try again, instead of waiting for the other threads.
    Example: (not tested)
    -- Assuming structure of your QueueTable: ( IDCol is PK , StatusCol is VARCHAR2, ... )
    -- or make it part of the package....
    CREATE OF REPLACE
    FUNCTION updateQueue( nQID QueueTable.IDCol%TYPE) RETURN VARCHAR2 AS
       eLocked EXCEPTION;
       PRAGMA EXCEPTION_INIT(eLocked,-54);
       CURSOR curQueueTable IS SELECT 1 CNTR FROM QueueTable WHERE IDCol=nQID AND StatusCol='NOT_TAKEN' FOR UPDATE OF StatusCol NOWAIT;
       recQueueTable curQueueTable%ROWTYPE;
       cRtn VARCHAR2(1);
    BEGIN
       cRtn := 'Y';
       BEGIN
          OPEN curQueueTable;
          FETCH curBuffSummary INTO recQueueTable;
          CLOSE curQueueTable;
          IF recQueueTable.CNTR IS NOT NULL AND recQueueTable.CNTR = 1 THEN
              UPDATE QueueTable SET StatusCol = 'TAKEN' WHERE IDCol=nQID;
          ELSE
              -- Already updated
              cRtn := 'N';
          END IF;
             -- You can control your transaction here as well
             -- COMMIT;
             -- But if realy should be done in the Java thread.
        EXCEPTION
           WHEN eLocked OR STANDARD.TIMEOUT_ON_RESOURCE THEN
           -- Thread could not get exclusice row lock. Ignore error.
             cRtn := 'N';
             NULL;
          WHEN OTHERS THEN
             -- Handle other errors...
             -- NULL; just kidding...
             RAISE;
       END;
       RETURN cRtn;
    END; Edited by: thomaso on Sep 18, 2009 10:30 AM

Maybe you are looking for

  • Problems with Mail and Safari

    Hi, I'm running OS 10.11 and am having some consistent problems with Mail and Safari on my MacPro Dual 2.66. Here they are: Sometimes, for no apparent reason, selecting these applications from the dock no longer opens the application (or a new window

  • Error while running WDJ application using jxl.jar

    Hi Experts, I am using jxl.jar in my webdynpro java application in CE7.2. I added jxl.jar in java build path and place the jar file in lib directory of webdynpro DC. It shows error in development configuration perspective while building, then i creat

  • ADAPTER.HTTP_EXCEPTION, HTTP 500 Internal Server Error, in Receiver soap A

    Greetings All,                      In my scenario i am calling external service of SFDC using receiver soap adapter but i am facing below error in the response. ADAPTER.HTTP_EXCEPTION, HTTP 500 Internal Server Error I am creating the soap structure/

  • Downloading and installing apps takes forever? New iphone 5s

    I've been an android user since the first droids but I decided to give iphone a shot with the 5s, just picked it up yesterday. Aside from getting used to a TINY screen, doing okay with it but I've noticed downloading and installing apps takes a LONG

  • Freight Charges does not correctly show Tax % / calaculate

    Hi When I try to add freight charges to an A/P invoice the tax group shows correctly (V1) but the Tax % shows 0.0 instead of 7.5 on every row/type of freight and therefore the Tax is not calculated automatically. Somebody an idea whats wrong? Thanks