Read consistency in query with pl/sql functions

Not sure if this is a bug or feature, but a query containing a user-defined pl/sql function does not include tables accessed within the pl/sql function in the read consistent view of data, eg
select myfunc from tableA
myfunc is a stored function that queries tableB and returns a value
If a change to tableB is committed in another session during fetch phase of select statement, then fetched rows reflect the changes. The database does not recognise tables accessed in the plsql function as being part of the query.
This happens in 7.3.4 and 8.1.6. Don't have 9i so can't tell.
Anyone know if this is a bug or feature?
Aside: you can also drop the plsql function whilst the fetch is running. It will kill the fetch. No DDL lock taken on the plsql function whilst select is running! Seems wrong.

I don't know Forms but I know SQL*Plus and Oracle database. Normally PL/SQL running on the database can only access files on the host where the database instance is running even if you start PL/SQL with a SQL*Plus connection from another host.
PL/SQL runs only the database instance not on the client side even if you start the PL/SQL code from a remote connection with SQL*Plus.

Similar Messages

  • Interactive Report with PL/SQL Function Source

    Is it possible to create interactive report with PL/SQL function source returing a query? If not, has anyone done any work to simulate the interactive reporting feature for a normal report using API?

    I haven't tried that before but you could:
    1. create a collection from your result set returned by a dynamic query,
    2. create a view on that collection,
    3. use the view in your interactive report.
    The usability of this proposal depends from a question how "dynamic" your query is - does it always have the same number of columns or not.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • Conditional display of region with PL/SQL function returning SQL query

    Hello,
    ApEx 2.0.
    I use PL/SQL functions that return SQL queries to display the contents of a region.
    How could I conditionally display such region ? If no data is found, the region shouldn't be shown. I tried with "SQL query returns at least one row" but this doesn't seem to work.
    Thanks,
    Matthias

    Hi Matthias,
    Are the regions in question report regions? So your PL/SQL process is returning a SQL query and then populating a report?
    The EXISTS(SQL Query returns at least one row) condition should work, try running the query you are using in the Expression 1 textarea inside SQL*Plus, or SQL developer using the same parameters, and see what gets returned.
    If you are still stuck, can you post the query you are using inside your Expression 1 textarea of the Conditions section and I can take a look at it for you.
    Hope this helps,
    Cj

  • Plugin with PL SQL function returning query

    Hi all,
    I have created plugin using SQL query many times. But can we create a plugin from scratch using PL SQL function returning SQL query? Any ideas or sample.
    Thanks
    Sunil Bhatia

    Hi Scott,
    By this i mean, i have created a region type plugin for integrating jqx Grid into oracle apex. This takes input parameter as SQL statement, and creates jqx grid for me on page. Now my question is, can i do this using PL SQL function returning SQL, because when i try to give return statement, plugin gives error "SQL statement mandatory'. I hope i am clear enough now.
    Thanks
    Sunil Bhatia

  • Parameter passing to custom SQL query using PL/SQL FUNCTION

    Hi
    In order to pass a parameter to the query in custom folder of a business area I created a function and mapped it to the Custome query using Discoverer Desktop. There is no error in mapping as the system does not throw any error. When I am inputting the Parameter for the input values everytime the query doesnot return any rows.
    Can anybody help in this regard

    Hi,
    I need to take the request Id as input from the user and then fetch only the data pertaining to that requet Id. As a lot of complex joins are involved I need to pass request id as parameter to the custome folder.
    The package i greated:
    CREATE OR REPLACE PACKAGE SETPARAM
    AS
    param1 varchar2(25);
    param2 varchar2(25);
    FUNCTION SET_PARAM1(p1 IN varchar2) RETURN NUMBER ;
    FUNCTION GET_PARAM1 RETURN varchar2;
    END SETPARAM;
    CREATE OR REPLACE PACKAGE BODY SETPARAM AS
    FUNCTION SET_PARAM1(p1 IN varchar2) RETURN NUMBER IS
    BEGIN
    fnd_client_info.set_org_context('138');
    param1 := p1;
    dbms_output.put_line(param1);
    RETURN 1;
    END;
    FUNCTION GET_PARAM1 RETURN varchar2 AS
    BEGIN
    RETURN param1;
    END;
    END SETPARAM;
    I registered the set_param1 function as a pl/sql function in discoverer admin.
    This function is called on the condition associated with the parameter in Discoverer Desktop when i run the report.
    In the custom folder query i have this piece in the where clause
    WHERE tnfo.request_id = NVL(APPS.SETPARAM.GET_PARAM1,7383588)
    And everytime i get the data pertaining to request id =7383588,
    Please suggest where i went wrong
    thanks
    Ashwini

  • String Substitutions with PL/SQL Function

    Hello, i user APEX 4.2.1.00.08 in Database 11g
    I new in apex and a try to use String Substitutions.
    When I define a String like CONST with static value like '999' in Edit Applications Definition it's work fine.
    But I need to define the same String 'CONST' but with value to return from PL/SQL function like.. Package.function
    It's Possible ??
    Thanks !!

    No, you'll need to use application items instead - or pass the value as parameter to your function.
    Passing parameters like this makes for good practice anyway, since your modules become more testable outside the apex environment, and more robust.

  • Query with Dynamic SQL

    Hello,
    I would like to create a Dynamic SQL in which change is the name of the table according to the outcome of the first SQL. This is possible?
    'WITH TABLE_X AS(SELECT LEVEL LVL FROM DUAL CONNECT BY LEVEL <= 12)' ||
    'SELECT A.COL1, A.COL2, B.COL1, B.COL7'                              ||
    '  FROM TABLE_A' || TABLE_X.LVL || ' A'                              ||
    '     , TABLE_B' || TABLE_X.LVL || ' B'                              ||
    ' WHERE A.COL1 = B.COL1 AND ...    'tables in database
    TABLE_A1
    TABLE_A2
    TABLE_A12
    TABLE_B1
    TABLE_B2
    TABLE_B12let me know how I can do this
    Regards

    Hi,
    Sorry, I don't see what you're trying to do.
    "Dynamic SQL" is really a mis-nomer. The number of tables and columns in a query, and their names, must be spelled out when the statement is compiled. There is nothing dynamic about it.
    In dynamic SQL, a PL/SQL procedure or another query writes all or part of query just milliseconds before it is compiled, typically using data taken from tables or supplied by a user right then.
    For example, consider this static query:
    SELECT     a.col1, a.col2, b.col1, b.col7
    FROM     table_1     a
    ,     table_2 b
    WHERE     a.col1 = b.col1;Now, say the 1 in "table_1" and the 2 in "table_2" are variables, x and y, that you will want to look up from another table every time you run this query. You can make it dynamic like this:
    sql_txt := 'SELECT  a.col1, a.col2, b.col1, b.col7 '
         || 'FROM    table_' || TO_CHAR (x) || ' a '
         || ',       table_' || TO_CHAR (y) || ' b '
         || 'WHERE   a.col_1 = b.col1';Now let's make it really interesting. Say that instead of 2 tables, and 1 join condition, you''ll have n tables and n-1 join conditions, where n has to be computed at (actually a split second before) run-time. That is, if n=4, you might need to construct a static query with 4 tables and 3 join conditions, like this:
    SELECT     a.col1, a.col2, b.col1, b.col7
    FROM     table_1     a
    ,     table_2 b
    ,     table_12 c
    ,     table_2 d
    WHERE     a.col1 = b.col1
    AND     a.col1 = c.col1
    AND     a.col1 = d.col1;You can do that using dynamic SQL, too.
    Post an example of the static query you need to build, and describe what parts of it are dynamic, and how you get the values for those parts, and someone will help you write the dynamic SQL.

  • Read files in directories with PL/SQL

    Hi
    Is there any way to read files (just the names) in a directory just using PL/SQL? I mean, finding out the files with .dat extension in a given directory, for example.
    Thanks

    I don't know Forms but I know SQL*Plus and Oracle database. Normally PL/SQL running on the database can only access files on the host where the database instance is running even if you start PL/SQL with a SQL*Plus connection from another host.
    PL/SQL runs only the database instance not on the client side even if you start the PL/SQL code from a remote connection with SQL*Plus.

  • Problem with PL/SQL Function Body

    Hi,
    I'm getting the following error, when i run the report.
    I'm trying to fetch a year value from a table based on a parameter value ":P33_YEAR"
    ORA-01403: no data found
    Error ERR-1904 Unable to compute item default: type = Function Body computation_type= DECLARE FY VARCHAR2(6); BEGIN SELECT DISTINCT YEAR1 INTO FY FROM REP WHERE YEAR = TRIM(:P33_YEAR);
    RETURN FY; END;.
    I have written this code in a PL/SQL Function Body for a Hidden item.
    Please let me know whats wrong with this code?
    Thanks
    CK
    Message was edited by:
    user536304

    Your code is in a default value for an item, right?
    You need to make sure :P33_YEAR is not null and handle the error in the PL/SQL if it is.
    How is P33_YEAR populated? do you pass it in? check to see if it is making it there..
    Message was edited by:
    Bill Carlisle

  • The troubles with creating SQL function in Java

    Hi!
    I use Oracle 10g and connect to it from Java application. I need in creating SQL functions from Java code.
    In Java I have:
    Statement stm = null; try{     stm = dbConnection.createStatement();     stm.executeUpdate( query ); }catch(SQLException ex){     throw ex; }finally{     try{ stm.close(); }catch(Exception ex){ stm.close(); } }
    And I'm passing the next SQL function:
    create or replace function get_me return number is
    result number;
    begin
    select 5 into result from dual;
    return result;
    end;
    This code is run successful, but I can't call this funtion, because it has status Invalid
    I'm looked the next error: PLS-00103: Encountered the symbol "" when expecting one of the following: . @ % ; is authid as cluster order using external character deterministic parallel_enable pipelined aggregate
    But I don't understand, What the matter? From Oracle Enterprise Manager I can create this function without problems. So, I wrote the wong Java code. Also, I can't find my error :(
    May be, do u have the some ideas?
    Thank you very much!

    Post the whole pl/sql code please.
    To run PL/SQL from within java you'll need callablestatement.
    [here |http://www.idevelopment.info/data/Programming/java/jdbc/PLSQL_and_JDBC/CallPLSQLFunc.java] an example : http://www.idevelopment.info/data/Programming/java/jdbc/PLSQL_and_JDBC/CallPLSQLFunc.java

  • Populating item with pl/sql function body

    Hi,
    I want to populate a "Display as text (saves state)" item with the difference of 2 other items.
    The source of my item is:
    - Only when current...
    - PL/SQL Function body
    - Source expression:
    DECLARE
    v_diff NUMBER;
    BEGIN
    v_diff := :P1_AUFWAND_TOTAL - :P1_AUFWAND_BERECHNET;
    return v_diff;
    END;
    Now I get this error:
    ORA-06502: PL/SQL: numerischer oder Wertefehler: Fehler beim Konvertieren von Zeichen zu Zahl
         Error      ERR-1904 Unable to compute item default: type = Function Body...
    I tried to track down the problem with to_number conversion:
    v_diff := to_number(':P1_AUFWAND_BERECHNET'); or
    v_diff := to_number(':P1_AUFWAND_BERECHNET', '999G999D00');
    What's wrong here? It feels like I'm making a simple mistake...
    Thanks for any help,
    Roger

    Hi Denes,
    Thanks for your help. You were right, item :p1_aufwand_berechnet was not a number.
    I created the problem myself by setting the format to:
    return TO_CHAR(v_aufwand,'999G999G999G999G990D00');
    Now the dilemma is that I want to calculate the numbers, but at the end I want a nice format to display them. This obviously only works with TO_CHAR, see:
    Re: Number format mask of text item is not applied
    Maybe this is to be solved with a seperate process after the calculation, to set the format?
    Cheers,
    Roger

  • Report with pl-sql function body returning sql query

    Hi
    using apex 4.0
    I have a requirement to create a report like cross tab and i have followed link "http://forums.oracle.com/forums/thread.jspa?threadID=697760".
    written below code in region source.
    declare
    q varchar2(4000);
    begin
    q := pk_pivot.pivotsql('select * from emp','deptno','empno,ename');
    return q;
    end;
    when running report it gives "web page can not found -HTTP 404 NOT FOUND" .
    Please help to sove this error.
    Thanks in advance

    Hi,
    I get the same error.. If you have a solution, could you share it ??
    Thanks,
    Poru

  • Problem with extended SQL functions in RTF Template

    Hello,
    I'm new to BI Publisher and I'm trying to create a new rtf template. I've created my layout and added fields without any problems, but I'm having trouble trying to insert calculations such as add,substract,multiply,divide, etc.
    Here is an example of what I'm trying to do:
    <?xdofx:STAFF_ASMT+100?>
    Where STAFF_ASMT is one of my fields. When I add this function all I get is the actual value from that field returned on the first page, and then on other pages I get the value plus an extra zero.
    So with my example data below I get: 6600 on page 1 and 51830 on page 2. Any ideas on what I'm doing wrong or if it is possible to do what I'm doing? Also, is it possible to add/substract/multiple two or more fields together?
    Something like this: <?xdofx:STAFF_ASMT+GROSS_INV?>
    I was going to add all of these functions to my SQL statement, but I have 30 or so calculations I want to perform in the layout and I don't want to have to write that all out in SQL.
    <ROWSET>
    <ROW>
    <STAFF_ASMT>6600</STAFF_ASMT>
    <GROSS_INV>0</GROSS_INV>
    </ROW>
    <ROW>
    <STAFF_ASMT>5183</STAFF_ASMT>
    <GROSS_INV>0</GROSS_INV>
    </ROW>
    </ROWSET>
    Thanks for your help

    When I tried that I get the following error message when I click the Validate Template option:
    [080609_031631893][][ERROR] [Line 162.184] Incorrect XPath: +
    And when I try to generate a PDF preview I get:
    java.lang.reflect.InvocationTargetException
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at oracle.apps.xdo.common.xml.XSLT10gR1.invokeNewXSLStylesheet(Unknown Source)
         at oracle.apps.xdo.common.xml.XSLT10gR1.transform(Unknown Source)
         at oracle.apps.xdo.common.xml.XSLTWrapper.transform(Unknown Source)
         at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(Unknown Source)
         at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(Unknown Source)
         at oracle.apps.xdo.template.FOProcessor.createFO(Unknown Source)
         at oracle.apps.xdo.template.FOProcessor.generate(Unknown Source)
         at RTF2PDF.runRTFto(RTF2PDF.java:629)
         at RTF2PDF.runXDO(RTF2PDF.java:439)
         at RTF2PDF.main(RTF2PDF.java:289)
    Caused by: oracle.xdo.parser.v2.XPathException: Error in expression: './/+'.
         at oracle.xdo.parser.v2.XSLProcessor.reportException(XSLProcessor.java:806)
         at oracle.xdo.parser.v2.XSLProcessor.newXSLStylesheet(XSLProcessor.java:571)

  • Replace trivial computation with PL/SQL Function?

    I have several queries that are computing integral day differences based on an Oracle date field -- for example, something along the line of:
    select
    Customer
    , trunc(current_date) - trunc(payment_date)
    from
    ( select 'Fred' Customer, to_date('2009-06-01 07:05:00', 'yyyy-mm-dd hh24:mi:ss') as payment_date from dual union all
    select 'Barney', to_date('2009-07-01 15:15:15', 'yyyy-mm-dd hh24:mi:ss') from dual
    -- Customer Account_Age
    -- Fred 49
    -- Barney 19
    I have a developer that is now advising that we use a PL/SQL user defined function rather than the difference of these TRUNC functions. That goes against the grain for me. In the MS SQL Server Transact SQL forums I would almost never recommend replacing a trivial expression with a user defined function because the UDF gets called for each row returned by the query and adds overhead to the query.
    Does the same kind of logic apply to Oracle UDFs? Is it a good idea to replace trivial calculations such as this with UDFs?
    Kent Waldrop

    Kent Waldrop wrote:
    Would you use the function instead of the inline calculation if it were not a large data warehouse but the target number of rows was in the millions?That would depend...
    - What are the odds that the business will change the definition of this calculation? The more likely it is to change, the bigger the benefit to centralizing it.
    - How many places is the calculation repeated today? Is that likely to increase over time? The more it is repeated, the bigger the benefit to having one standard place for it.
    - Is this going to be a calculation that gets reimplemented in a variety of reporting tools, in SQL, in applications, etc? Again, this goes to the size of the benefit.
    - What are you doing with the results of the SELECT statement? If you're using it in an INSERT ... SELECT, you're more likely to notice the performance overhead than if you've got a FOR loop that is doing row-by-row processing.
    - How critical is performance of this query? If you're processing millions of rows but that is happening in the dead of night, perhaps adding a few minutes to the run is well worth the improved maintainability.
    Different people, working on different systems, will weight these factors differently and come to different conclusions. Either solution is defensible under the right circumstances and there's a large middle ground where both are reasonable to most people. Steven Feuerstein, one of the most well respected PL/SQL gurus, would push strongly for a function in almost all cases. Most of the commentators here would tend to lean toward the performance benefits of putting the calculation in SQL.
    Justin

  • SQL Query problem (PL/SQL function returning SQl query)

    I am using 3.1.2 Apex. When I create the region source with the following code.
    DECLARE
    l_sql VARCHAR2(32767);
    X1 VARCHAR2(9);
    X2 VARCHAR2(9);
    X3 VARCHAR2(9);
    X4 VARCHAR2(9);
    X5 VARCHAR2(9);
    X6 VARCHAR2(9);
    X7 VARCHAR2(9);
    X8 VARCHAR2(9);
    BEGIN
    SELECT decode(:P3_FAILED_CDD,'0','0','1','1', '2','2' ) INTO X2
    FROM DUAL;
    SELECT decode(:P3_Order_status,'J','J','1','1','2') INTO X3
    FROM DUAL;
    SELECT decode(:P3_FAILED_STAGE,'0','0','1','1','2') INTO X4
    FROM DUAL;
    SELECT decode(:P3_ORDER_TYPE,'TYPE1','TYPE1','TYPE2','TYPE2','2') INTO X5
    FROM DUAL;
    SELECT decode(:P3_INCLUDE_SFIN,'NO','NO','YES','YES') INTO X6
    FROM DUAL;
    SELECT decode(:P3_CDD_MATCH,'0','0','1','1', '2','2' ) INTO X7
    FROM DUAL;
    SELECT decode(:P3_FIELD,'0','0','1','1', '2','2' ) INTO X8
    FROM DUAL;
    l_sql := 'SELECT
    ORDER_NR,
    FNN,
    ST,
    SOT,
    STAGE,
    CUST_NAME,
    STG_DAYS,
    ZONE,
    P1.OWNER,
    QUEUE_A,
    STG_LFD,
    LFD_LEFT,
    CIJ_FLAG,
    FST_FLAG,
    CCD_COUNT,
    TCD_COUNT,
    LATEST_RET_CODE,
    CRD,
    CDD_DATE,
    CRD_LEFT CDD_LEFT,
    TCD_DATE RTCD_DATE,
    PROP_TCD_DATE TCD_DATE,
    PROJECT_ID,
    APPLN_TBO,
    CO_ORD_ID,
    CON_WSTN,
    P1.STATE,
    A_DTB,
    B_DTB,
    DESIGN_NO,
    CREATE_DATE,
    DATE_APPLN,
    CUSTOMER_ID,
    SALES_QUEUE,
    TRACKING_NR,
    WORK_REQUIRED,
    SFIN_STAGE_ENTERED_DATE,
    APPLN_CONTACT_OFFICER,
    A_LOCATION_ADDRESS,
    B_LOCATION_ADDRESS,
    SO_CREATE_USERID,
    OP_SEP,
    WMC_CODE
    FROM RASS_TICKET_VIEW P1
    WHERE WMC_CODE like :p3_wmc_code
    AND ST in (SELECT SYSTEM_ID from PRDRF where PRODUCT_CATEGORY like :p3_product_cat)';
    IF X2 = '0' then
    l_sql := l_sql || ' and CRD_LEFT < 0';
    END IF;
    IF X2 = '1' then
    l_sql := l_sql || ' and CRD_LEFT >= 0';
    END IF;
    IF X3 = 'J' then
    l_sql := l_sql || ' and CIJ_FLAG = ''J''';
    END IF;
    IF X3 = '1' then
    l_sql := l_sql || ' and CIJ_FLAG is null';
    END IF;
    IF X4 = '0' then
    l_sql := l_sql || ' and LFD_LEFT < 0';
    END IF;
    IF X4 = '1' then
    l_sql := l_sql || ' and LFD_LEFT >= 0';
    END IF;
    IF X5 = 'TYPE1' then
    l_sql := l_sql || ' and SOT in (''NEW'',''NET'',''ERT'',''UGP'')';
    END IF;
    IF X5 = 'TYPE2' then
    l_sql := l_sql || ' and SOT not in (''NEW'',''NET'',''ERT'',''UGP'')';
    END IF;
    IF X6 = 'NO' then
    l_sql := l_sql || ' and STAGE in (''DSAL'',''DPLO'',''OISS'',''TRPB'',''OTST'',''TEQP'',''DSPS'')';
    END IF;
    IF X7 = '0' then
    l_sql := l_sql || ' and PROP_TCD_DATE <= CDD_DATE';
    END IF;
    IF     X7 = '1' then
    l_sql := l_sql || ' and PROP_TCD_DATE > CDD_DATE';
    END IF;
    RETURN l_sql;
    END;
    The query returns data.
    If I add some more code just after the where clause.
    AND decode(CUST_CODE,'TW','TW','RET') like (select decode(OPS_SEP,'TS','%',OPS_SEP) from T_U_CDW_BU_OP_SEP where upper(USER_ID) = upper(:APP_USER))
    The query just stops working and no error message is returned.
    I thought there was an issue prior to version 3.1.2 that was fixed in version 3.1.2
    Othwerwise is there a better way to write the code? As I have 7 radio btn's that control the condition within the where clause.
    Thanks
    Ron

    >
    bug in APEX 3.0
    >
    Are you sure?
    Do as Paul has suggested and post the code that doesn't work (including your extra line) using the {noformat}{noformat} tags +exactly+ as you had it in the region source.
    Cheers
    Ben                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Maybe you are looking for

  • Defect notification based on the operation

    Hi, We have task list operations and inspection characteristics attached to different operation. We are creating the inspection lot from the PM order release which has got task lists attached. We are doing the result recording through QE51N and recor

  • Customer -master upload using bapi

    hai ..   can any body send me some example for customer master  creation using bapi ..   in this account -group is mandatary.. but i did.nt find  acc-group in bapi structures .. plz do helpful .. Tanx in advance ..

  • IDOC is successfully triggered from SAP ECC

    hi,       IDOC has been Trigerred from ECC Sucssesfully and the status is 03, but it not reached in PI, what will be the error, please do the needful at the earliest. Share some more errors where i can stuck with idoc when doing IDOC to File scenario

  • In-Ear Earphones Warranty Length

    I purchased In-Ear Earphones online in January 2009. How long is the warranty for that product?

  • ITunes quits when click on playlist

    My iTunes keeps quitting unexpectedly when I click on either certain playlists or on the library. I also can't get a playlist to sync onto my iPod. Any suggestions?