Caching in plsql

hi expert,
can anyone tell me that how i achieve cashing through plsql code.
i can not understand that how i am write a code in plsql.
Plz help me.
thx & Regds,
jaideep awasthi

There have been cases (several years ago) where I have used an explicit cache of a row to save a repeat lookup of static data. I had a function that accepted an ID and returned the corresponding row. If the ID was the same as the cached ID, it skipped the query and returned the cached row; otherwise it did the lookup and replaced the cached row with the new one. Alternatively for small volumes you might load them into an associative array. That kind of thing does complicate the code though, and potentially introduces bugs if the static data turns out to be less static than you hoped it was. It might not even give you any performance improvement - I would test any approach carefully to make sure it was worth the effort.

Similar Messages

  • Disable cache in plsql procedure

    Hello,
    I made a portal page using a UITemplate.
    This UITemplate have more plsql procedures that make the structure of my page.
    One of this create a news ticker that change every day.
    If I set the page cache "Cache Page Definition Only", when the news change, the page not views the correct news because it views the last version saved in cache.
    Can i disable the cache only into the plsql procedure that create the news ticker?
    Thanks
    Monica

    Just put all your html tag in htp.p, that will helps you to read html tags in PL/SQL Procedure.Just see the below example
    htp.p('<script>');
    htp.p('<table><tr><td>.......</td></tr></table>');
    Hope this will helps you to solve the things.>
    Just what exactly is that? Neither a proper script nor a proper HTML.
    HTP.P is to write to browser, not read .

  • Image cache not working with Firefox and apex

    Hi,
    I'd like to cache all my images to save page rendering time and bandwidth because my images are all static and never change.
    I use the John Scott's caching technique Link: [http://jes.blogs.shellprompt.net/2007/05/18/apex-delivering-pages-in-3-seconds-or-less/], in a few words this technique consists of adding a header line "Expires: date in the future" in the http response.
    It works very well in IE, the images are cached and the same image can be accessed several times (within the same session or in different sessions) without issuing an http request to the server each time.
    with Firefox it does not work, the same image is asked again and again to the server (i'm using FF 3.5 and APEX 3.2).
    - Is it a date format problem? no, because when i type about:cache in FF, i can find my image in the cache with an expire date in the future.
    The weird thing here is that the counter is incremented each time u request the image, so FF knows it is in the cache and even if the expire date is in the future, FF asks it again to the server.
    - Is it a FF bug? If u read the http specs or if u google a little, u can come to the conclusion that FF does not follow the standards,
    but... images.google.com for example manages to get its images cached with FF.
    They use an http response header "cache-control: public, max-age=604800".
    I tried the same and all kinds of combinations but without success.
    When i compare my image with the one from google in the FF cache, they both have the same attributes.
    - It's not an apex issue neither because it works with IE, most probably an incompatibility between apex and FF?
    Maybe the use of cookie? or the http request (not the response) containing "cache-control: max-age=0"?
    I've found so far 2 half solutions:
    1) use ETag and modified date, see the Tyler Muth's note Link: [http://tylermuth.wordpress.com/2008/02/04/image-caching-in-plsql-applications/].
    with this technique FF continues to send request each time but the answer is shorter because it's just a "304 not modified" instead of "200 OK" (200 response is bigger as it contains the image).
    it's better than nothing but you still have 1 request + 1 response for nothing.
    Another problem is that you need SYS access to implement this, which is not possible on an hosted server. (note that for images from the file system it is already foreseen by apex 3.1, Tyler's note is for images from the db)
    2) if you preload the image (using myimage=new Image();myimage.src='...';), then there is max 1 request per browser session.
    There are 2 minor issues here:
    - no caching across sessions
    - if u don't want to preload all the images (example a page with lots of thumbnails, when user clicks it show a bigger image, in that case the thumbnails can be preloaded but overkill for the big images), then you need to load the image, wait until the image has loaded before displaying it, it does not slow down the execution, but requires some extra JS.
    I'm not asking anyone to investigate it, i can live with the 2 workarounds,
    but just in case someone encountered the same problem and already fixed it.
    Let me know if u managed to use the John Scott's technique with Firefox. (U can use Firebug to see the http traffic)
    Thx
    Tim

    Hi Anshul, hope these help. Let me know if you need to see anything else.
    Best,
    Menu Settings:
    Tab Hyperlink:
    Label Text with with hyper link option not available (works as a hyperlink in chrome and IE though):
    Thanks for the help in advance!

  • Blog: Image Caching in PL/SQL Applications

    Blog: Image Caching in PL/SQL Applications
    http://tylermuth.wordpress.com/2008/02/04/image-caching-in-plsql-applications/
    Enjoy,
    Tyler

    Anyone? Or is it the wrong forum?
    Alessandro

  • JDBC Drviers and Linux

    What driver should I use for O8.1.6 using RedHat 6.2 Linux
    Thanks
    P.S. Please respond to [email protected]

    the jdbc driver readme file:
    Oracle JDBC Drivers release 8.1.7 README
    ========================================
    What Is New In This Release?
    These are the major new features/enhancements in this release:
    - Statement Caching
    * Implicit Statement Caching
    * Explicit Statement Caching
    - Full XA Support
    * Including XA Recover and Forget
    * OracleXid independent implementation for 8.1.7 servers and above
    - Connection Caching
    * New Scheme (FIXED_WAIT_SCHEME)
    * Statement Caching coupling
    - PLSQL Tables Support for Scalar types (for OCI driver only)
    - User-Defined Datatypes Performance Enhancement
    - Object Types Extensions
    * Serializable Type Descriptors
    * Accessing collection elements in Java primitive types
    * Buffering and indexing collection elements
    * Creating empty Lobs
    - Support for 56-bit encryption algorithms for connection using
    the Thin JDBC driver.
    These are the major bug fixes:
    - BUG-903011
    The JDBC Thin driver could not be used with usernames that
    contained Latin-1 characters when the server used UTF8 character
    set. This problem has been fixed in release 8.1.7.
    - BUG-1052489
    There was a problem with PreparedStatements being executed
    multiple times and the length of one of the bind variables (bound
    with setBinaryStream or setCharacterStream) increased. This
    problem has been fixed in release 8.1.7.
    - BUG-1069768
    There was a problem with insertion of ADTs with an image bigger
    than 4K with the JDBC Thin driver. This problem has been fixed
    in release 8.1.7.
    - BUG-1247015
    When using ResultSet::getObject() to access CHAR or VARCHAR columns
    in scrollable result sets, ResultSet::getObject() returned null.
    - BUG-1349713
    getString() of scrollable result sets returns incorrect values if
    the column data contains multibyte characters.
    Driver Versions
    These are the driver versions in the 8.1.7 release:
    - JDBC OCI Driver 8.1.7
    Client-side JDBC for use on a machine where OCI 8.1.7 is installed.
    - JDBC Thin Driver 8.1.7
    100% Java client-side JDBC for use in applets and applications.
    - JDBC Thin Server-side Driver 8.1.7
    JDBC for use by Java Stored Procedures or by Java CORBA objects
    running in Oracle 8.1.7. This driver is typically used in a middle
    tier server.
    - JDBC Server-side Internal Driver 8.1.7
    Server-side JDBC for use by Java Stored procedures or by Java CORBA
    objects running in Oracle 8.1.7. This driver used to be called the
    "JDBC Kprb Driver".
    For complete documentation, please refer to "JDBC Developer's Guide
    and Reference".
    Contents Of This Release
    The [ORACLE_HOME]/jdbc/lib directory contains:
    - classes111.zip
    Classes for use with JDK 1.1.x. It contains the JDBC driver
    classes except classes necessary for NLS support in Object and
    Collection types.
    - nls_charset11.zip
    NLS classes for use with JDK 1.1.x. It contains classes necessary
    for NLS support in Object and Collection types.
    - classes111_g.zip
    Same as classes111.zip, except that classes were compiled with
    "javac -g".
    - classes12.zip
    Classes for use with JDK 1.2.x. It contains the JDBC driver
    classes except classes necessary for NLS support in Object and
    Collection types.
    - nls_charset12.zip
    NLS classes for use with JDK 1.2.x. It contains classes necessary
    for NLS support in Object and Collection types.
    - classes12_g.zip
    Same as classes12.zip, except that classes were compiled with
    "javac -g".
    Note that the packaging of the JDBC classes to support NLS was
    changed in 8i. The classes pertaining to specific character sets
    support in Object and Collection types have been separated from the
    basic zip files. These NLS classes are now packaged into the
    extension zip files. This allows the user to include the NLS
    classes only if necessary. Please refer to the "NLS Extension Zip
    Files (for client-side only)" for further details.
    [ORACLE_HOME]/lib directory contains libocijdbc8.so and
    libocijdbc8_g.so (on Solaris), which are the shared libraries used by
    the JDBC OCI driver.
    [ORACLE_HOME]/jdbc/doc/javadoc.tar contains the JDBC Javadoc. This
    release contains a beta release of the Javadoc files for the public
    API of the public classes of Oracle JDBC.
    [ORACLE_HOME]/jdbc/demo/demo.tar contains sample JDBC programs.
    Demo programs written for JDK 1.1 must be modified to run in JDK 1.2.
    Please refer to the "Support For JDK 1.2" for porting details.
    NLS Extension Zip Files (for client-side only)
    The JDBC Server-side Internal Driver provides complete NLS support.
    It does not require any NLS extension zip files, nls_charset*.zip.
    Discussions in this section do not apply to the JDBC Server-side
    Internal Driver. You can skip this section if you only use the
    Server-side Internal Driver.
    The basic zip files, classes111.zip and classes12.zip, contain all the
    necessary classes to provide complete NLS support for:
    - Oracle Character sets for CHAR/VARCHAR/LONGVARCHAR/CLOB type data
    that is not retrieved or inserted as a data member of an Oracle 8
    Object or Collection type.
    - NLS support for CHAR/VARCHAR data members of Objects and
    Collections for a few commonly used character sets. These
    character sets are: US7ASCII, WE8DEC, WE8ISO8859P1 and UTF8.
    Users must include the appropriate extension zip in their CLASSPATH
    if utilization of other character sets in CHAR/VARCHAR data members
    of Objects/Collections is desired. It is important to note that
    extension zip files are large in size due to the requirement of
    supporting a large number of character sets. Users may choose to
    include only the necessary classes from the extension zip file.
    To do so, users can first unzip the extension zip file, and then put
    only the necessary classes in the CLASSPATH. The character set
    extension class files are named in the following format:
    CharacterConverter<OracleCharacterSetId>.class
    where <OracleCharacterSetId> is the hexidecimal representation of the
    Oracle character set id of the corresponding character set.
    Installation
    Please do not try to put multiple versions of the Oracle JDBC drivers
    in your CLASSPATH. The Oracle installer installs the JDBC Drivers in
    the [ORACLE_HOME]/jdbc directory.
    Setting Up Your Environment
    On Win95/Win98/NT:
    - Add [ORACLE_HOME]\jdbc\lib\classes111.zip and
    [ORACLE_HOME]\jdbc\lib\nls_charset11.zip to your CLASSPATH.
    (Add classes12.zip and nls_charset12.zip if JDK 1.2.x is used.)
    - Add [ORACLE_HOME]\jdbc\lib to your PATH.
    On Solaris/Digital Unix:
    - Add [ORACLE_HOME]/jdbc/lib/classes111.zip and
    [ORACLE_HOME]/jdbc/lib/nls_charset11.zip to your CLASSPATH.
    (Add classes12.zip and nls_charset12.zip if JDK 1.2.x is used.)
    - Add [ORACLE_HOME]/jdbc/lib to your LD_LIBRARY_PATH.
    On HP/UX:
    - Add [ORACLE_HOME]/jdbc/lib/classes111.zip and
    [ORACLE_HOME]/jdbc/lib/nls_charset11.zip to your CLASSPATH.
    (Add classes12.zip and nls_charset12.zip if JDK 1.2.x is used.)
    - Add [ORACLE_HOME]/jdbc/lib to your SHLIB_PATH and LD_LIBRARY_PATH.
    On AIX:
    - Add [ORACLE_HOME]/jdbc/lib/classes111.zip and
    [ORACLE_HOME]/jdbc/lib/nls_charset11.zip to your CLASSPATH.
    (Add classes12.zip and nls_charset12.zip if JDK 1.2.x is used.)
    - Add [ORACLE_HOME]/jdbc/lib to your LIBPATH and LD_LIBRARY_PATH.
    Some Useful Hints In Using the JDBC Drivers
    Please refer to "JDBC Developer's Guide and Reference" for details
    regarding usage of Oracle's JDBC Drivers. This section only offers
    useful hints. These hints are not meant to be exhaustive.
    These are a few simple things that you should do in your JDBC program:
    1. Import the necessary JDBC classes in your programs that use JDBC.
    For example:
    import java.sql.*;
    import java.math.*;
    2. Register the Oracle driver before before calling other JDBC APIs.
    (This is not needed if you are using the JDBC Server-side Internal
    Driver because registration is done automatically in the server.)
    To register the Oracle driver, make sure the following statement
    is executed at least once in your Java session:
    DriverManager.registerDriver(
    new oracle.jdbc.driver.OracleDriver());
    3. Open a connection to the database with the getConnection call.
    Different connection URLs should be used for different JDBC
    drivers. The following examples demonstrate the different URLs.
    For the JDBC OCI8 Driver:
    Connection conn = DriverManager.getConnection(
    "jdbc:oracle:oci8:@<database>",
    "scott", "tiger");
    where <database> is either an entry in tnsnames.ora or a SQL*net
    name-value pair.
    For the JDBC Thin Driver, or Server-side Thin Driver:
    Connection conn = DriverManager.getConnection(
    "jdbc:oracle:thin:@<database>",
    "scott", "tiger");
    where <database> is either a string of the form
    <host>:<port>:<sid> or a SQL*net name-value pair.
    For the JDBC Server-side Internal Driver:
    Connection conn = DriverManager.getConnection(
    "jdbc:oracle:kprb:");
    Note that the trailing ':' character is necessary. When you use
    the Server-side Internal Driver, you always connect to the
    database you are executing in. You can also do this:
    Connection conn
    = new oracle.jdbc.driver.OracleDriver().defaultConnection();
    Java Stored Procedures
    Please note that examples for callins and instance methods using Oracle
    8 Object Types are provided in:
    [ORACLE_HOME]/javavm/demo/demo.zip
    Once unzipped, the directory containing the examples is:
    [ORACLE_HOME]/javavm/demo/examples/jsp
    Known Problems/Limitations In This Release
    The following is a list of known problems/limitations:
    1. There is a limitation regarding the use of stream input for LOB
    types. Stream input for LOB types can only be used for 8.1.7
    JDBC OCI driver connecting to an 8.1.7 Oracle server. The use of
    stream input for LOB types in all other configurations may result
    in data corruption. PreparedStatement stream input APIs include:
    setBinaryStream(), setAsciiStream(), setUnicodeStream(),
    setCharacterStream() and setObject().
    2. BUG-1018797
    Extra characters may be appended to the end of a CLOB value
    mistakenly under the following conditions:
    - setCharacterStream() is used to insert a CLOB value, and
    - The Oracle server uses multi-byte character set.
    (See 1 for limitation of stream input for LOB type.)
    3. Programs can fail to open 16 or more connections using our
    client-side drivers at any one time. This is not a limitation
    caused by the JDBC drivers. It is most likely that the limit of
    per-process file descriptors is exceeded. The solution is to
    increase the limit.
    4. The Server-side Internal Driver has the following limitation:
    - Data access for LONG and LONG RAW types is limited to 32K of
    data.
    - Inserts of Object Types (Oracle 8 Objects, Collections and
    References) will not work when the database compatibility mode
    is set to 8.0. This limitation does not apply when the
    compatibility mode is set to 8.1.
    - Statement.cancel() is not implemented.
    - In a chain of SQLExceptions, only the first one in the chain
    will have a getSQLState value.
    5. The JDBC OCI driver on an SSL connection hangs when the Java
    Virtual Machine is running in green threads mode. A work-around
    is to run the Java Virtual Machine in native threads mode.
    6. Date-time format, currency symbol and decimal symbols are always
    presented in American convention.
    7. When using OracleStatement.defineColumnType(), it is not necessary
    to define the column type to be the same as the column type
    declared in the database. If the types are different, the
    retrieved values are converted to the type specified in
    defineColumnType.
    Note: Most reasonable conversions work, but not all. If you find
    a conversion that you think is reasonable, but that does not wo rk,
    please submit a TAR to Oracle Support.
    8. The utility dbms_java.set_output or dbms_java.set_stream that is
    used for redirecting the System.out.println() in JSPs to stdout
    SHOULD NOT be used when JDBC tracing is turned on. This is
    because the current implementation of dbms_java.set_output and
    set_stream uses JDBC to write the output to stdout. The result
    would be an infinite loop.
    9. The JDBC OCI and Thin drivers do not read CHAR data via binary
    streams correctly. In other word, using getBinaryStream() to
    retrieve CHAR data may yield incorrect results. A work-around is
    to use either getCHAR() or getAsciiStream() instead. The other
    alternative is to use getUnicodeStream() although the method is
    deprecated.
    10. BUG-899078 (since 8.1.6 SDK):
    The JDBC Server-side Internal driver has extra space padding with
    PL/SQL CHAR OUT (2 to 3 space depending on character set).
    Problem occurs in most of the multibyte database character set
    except UTF8.
    11. There is a limitation for Triggers implemented in Java and Object
    Types. It only affects the IN argument types of triggers
    implemented using Java on the client-side. The restriction does
    not apply to JDBC programs running inside the server. Triggers
    implemented as Java methods cannot have IN arguments of Oracle 8
    Object or Collection type. This means the Java methods used to
    implement triggers cannot have arguments of the following types:
    - java.sql.Struct
    - java.sql.Array
    - oracle.sql.STRUCT
    - oracle.sql.ARRAY
    - oracle.jdbc2.Struct
    - oracle.jdbc2.Array
    - any class implementing oracle.jdbc2.SQLData or
    oracle.sql.CustomDatum
    12. The scrollable result set implementation has the following
    limitation:
    - setFetchDirection() on ScrollableResultSet is not supported.
    - refreshRow() on ScrollableResultSet does not support all
    combinations of sensitivity and concurrency. The following
    table depicts the supported combinations.
    Support Type Concurrency
    no TYPE_FORWARD_ONLY CONCUR_READ_ONLY
    no TYPE_FORWARD_ONLY CONCUR_UPDATABLE
    no TYPE_SCROLL_INSENSITIVE CONCUR_READ_ONLY
    yes TYPE_SCROLL_INSENSITIVE CONCUR_UPDATABLE
    yes TYPE_SCROLL_SENSITIVE CONCUR_READ_ONLY
    yes TYPE_SCROLL_SENSITIVE CONCUR_UPDATABLE
    13. BUG-1324918
    Repeatedly updating a clob with jdbc-oci, prepared statement,
    and setCharacterStream consumes the temporary tablespace. If
    you repeatedly update the clob, either the temp tablespace will
    continue to grow, or you may get a Exception in thread "main"
    java.sql.SQLException: ORA-01652: unable to extend segment if
    you have a limit on the tablespace size. The work-around is to
    use oracle.sql.CLOB::setCharacterOutputStream() instead.

  • PLSQL Caching

    Hi!
    Does anyone have experience with PLSQL caching on Portal30. I have an old WebDB 2.2 "application" where most of the items were based on PLSQL packages using the htp and htf packages! This application should run under the new version (portal30) using some king of caching!
    It would be greater with an example!
    Thank you
    Fred

    Hi,
    Portlets have caching APIs. check out the plsql and java pdk docs for this. however, must caution you that we are experiencing quite a few difficulties with caching in Portal.

  • Clear cache from URL

    Hi ! I have a question !
    Is there a way to clear the cache of my entire application by passing parameters to my URL address ?
    For now, I have this URL : f?p=103:"+html_GetElement('P0_NO_PAGE').value+":"+html_GetElement('pInstance').value+":MODIF::12:
    but it clears only the cache of page 12.
    Anyone can help me ?
    Thanks, Chantale

    1) search for js example of call PLSQL on this forum
    2) from URL you can call that through Application process on demand (there are also some examples on forum).
    You can use both ways...what suits you more. I was using Application process (on demand type) because it is mor PLSQL driven and I'm no expert in js...
    Hope this helps ...

  • Plsql procedure with sql query data

    plsql newbie(learning sql): please excuse for asking a basic plsql question
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod on windows server 2003
    PL/SQL Release 10.2.0.1.0 - Production
    "CORE     10.2.0.1.0     Production"
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    CREATE OR REPLACE PROCEDURE p_check
    AS
    v1 NUMBER(20,0);
    BEGIN
    SELECT count(*) INTO v1
    FROM ad_reg;
    dbms_output.put_line(v1);
    end;
    inserts the number of rows in the table ad_reg into v1
    and displays v1 by using dbms_output
    i want my procedure to return table data
    CREATE TABLE "TEST_SH"
    "TEXT_ID" NUMBER,
    "TEXT" CLOB
    Insert into TEST_SH (TEXT_ID) values (1);
    Insert into TEST_SH (TEXT_ID) values (2);
    Insert into TEST_SH (TEXT_ID) values (3);
    Insert into TEST_SH (TEXT_ID) values (4);
    there will be a way with which i can see all the data(select * from test_sh) as the output of the plsql procedure
    1.please tel me what to google
    2.please guide me with a site or tell what is actually used and help me
    3.or post an example here
    thank you much
    Edited by: 946207 on Nov 20, 2012 2:05 PM

    946207 wrote:
    there will be a way with which i can see all the data(select * from test_sh) as the output of the plsql procedurePL/SQL is
    a) nothing at all like T-SQL
    b) two different languages, PL (Programming Logic) and SQL
    SQL is used to access data in the Oracle database. So select * from test_sh is the correct statement to access the data.
    The client can make execute this SQL statement itself. And view the data. However, this requires the client to understand the SQL language, and the database model. Which is typically not that you want. You want to abstract that from the client.
    Why would you want the client to deal with the complexities of the SQL language? Or deal with the complexities of your database model in Oracle?
    So instead of the client doing SQL, PL/SQL can do it on behalf of the client. The client uses PL/SQL as an API - in a similar fashion as the client would use any other API.
    The PL/SQL code determines the SQL statement - and returns a SQL cursor handle to the client. The client then simply uses the SQL cursor that the PL/SQL code created for it (and the client needs to close the SQL cursor when done, so as to not cause server resource leakage).
    E.g. (using PL/SQL as an API to abstract SQL and the data model)
    create or replace procedure TestProc( c out sys_refcursor ) is
    begin
      open c for select * from test_sh order by 1;
    end;The client then calls TestProc and gets a reference cursor handle. E.g. (the client call to Oracle):
    begin
      TestProc( c => :1 );
    end;The client needs to supply a host (client language) bind variable of type cursor, as value for bind variable +:1+.
    This is the correct way to deal with PL/SQL and cursors from a client GUI/language perspective. Any other method, like using PL/SQL to cache SQL data as a collection, is usually very wrong.

  • How to execute a function in oracle plsql object, when object dies

    I have a plsql object with a member function as exec_last.
    I want this procedure to be called when plsql object is cleaned or when the session hosting this object dies.
    In C, we have a system call as atexit(). Is there any such feature in Oracle 10g or any workaround using embedded java.
    This feature is required to flush the contents stored in plsql table in the object to the database, when program exits.
    Thank you,
    Warm Regards,
    Navin Srivastava

    navsriva wrote:
    Is there any better way to implement this in memory caching. What is the buffer cache of Oracle? It is exactly that - a memory cache for data blocks. Both new blocks (created by inserting new rows) and existing blocks (used by selects, updates and deletes, and re-used (freespace) by inserts).
    The Oracle buffer cache is a very mature and sophisticated cache. Attempting to do it "+better+" than the db buffer cache in another software layer (like PL/SQL) is mostly a waste of time and resources.. and invariable introduces another s/w layer that simply increases the number of moving parts. This in turn usually means increased complexity and slower performance.
    Why use bulk processing in PL/SQL? The basic and fundamental answer to that is to decrease the context switching between the PL engine and SQL engine.
    When running PL code to insert data into SQL, that data needs to be passed to the SQL engine, the PL engine needs to perform a context switch to the SQL engine to allow it to process that data and perform the SQL instruction.
    If there are a 1000 rows to inserts, it means a 1000 context switches.
    Bulk processing makes the "+communication/data pipe+" between the two bigger. Instead of passing a single row's data to the SQL engine via a context switch, a bulk collection/array of a 100 rows is passed. There is now a mere 10 context switches required to push that 1000 rows from the PL engine to the SQL engine.
    You can do the same from any other SQL client... (remember, that PL itself is also a SQL client). You can, using C/C++ for example, do the exact same thing. When passing row data to the SQL engine to insert, pass a collection of a 100 rows instead of the data for a single row.
    The exact same benefits result as in PL/SQL. A bigger communication pipe, allowing more data to be transferred to/from the SQL engine, resulting in less context switching.
    Of course, a context switch ito C/C++ is a lot more expensive than in PL/SQL - as the PL engine sits in the very same physical process as the SQL engine. Using C/C++, this will usually be a separate process communicating with the SQL engine process across the network.
    The same applies to other languages, like Java, C#, Delphi, Visual Basic and so on.
    It does not make sense to introduce another s/w layer, the PL/SQL engine, and have the client "+insert+" rows into its memory structures... and then use the PL engine to "+flush"+ that to the SQL engine via a bulk process command.
    It will be faster, and more scalable, having the client language using bulk processing directly and dealing with the SQL engine directly.
    Simple example. What does the SQL*Loader program (written in C) use? It does not use PL as a proxy for moving data from a CSV file into a SQL table. It calls SQL directly. It uses bulk processing. It is very fast at loading data.
    There is an exception to this. When PL is used as a business processing and validation layer. Instead of the client code implementing that logic, it is done using PL. The client then no longer will manually add an invoice to the INVOICES table for example. It instead calls the AddNewInvoice PL/SQL procedure - and this procedure does all. It checks the customer code as valid. Ensures that there's stock available of the products being ordered on the invoice. Etc.
    But in this scenario, PL is not used a secondhand "buffer cache". It is used for what it has been designed for - a proper application layer inside the database.

  • Serveroutput in the command window of PLSQL Developer

    In sqlplus, I input the following SQL:
    SQL> set serveroutput on
    SQL> show serveroutput
    serveroutput ON SIZE UNLIMITED FORMAT WORD_WRAPPED
    SQL> select /*+ no_index(t1 idx_t1) */ * from t1 where n=3;
         N
         3
    SQL> select * from table(dbms_xplan.display_cursor(null,null,'advanced'));
    PLAN_TABLE_OUTPUT
    While I input the same SQL in PLSQL Developer:
    SQL> select * from table(dbms_xplan.display_cursor(null,null,'advanced'));
    PLAN_TABLE_OUTPUT
    SQL_ID     9babjv8yq8ru3, child number 0
    BEGIN DBMS_OUTPUT.GET_LINES(:LINES, :NUMLINES); END;
    NOTE: cannot fetch plan for SQL_ID: 9babjv8yq8ru3, CHILD_NUMBER: 0
    Please verify value of SQL_ID and CHILD_NUMBER;
    It could also be that the plan is no longer in cursor cache (check v$sql_plan)
    And the most important is:
    SQL> show serveroutput
    SQL>
    The result of it is empty.
    The reason for that is serveroutput is only supported in sqlplus not PLSQL? I know serveroutput is sqlplus language not SQL. However I use "show serveroutput" in command window of PLSQL Developer which is the same as sqlplus. What's the real reason for that?
    Thanks for your kindly reply.

    " If serveroutput is on when you call this function, the last statement you will have run will be the (hidden) call to dbms_output that follows your execution of any other statement – so you won’t get the plan and statistics."
    http://jonathanlewis.wordpress.com/2006/11/09/dbms_xplan-in-10g/
    "Luckily I recognized the line BEGIN DBMS_OUTPUT.GET_LINES(...); END; from the tkprof output files. It is what SQL*Plus does after each statement: flushing the dbms_output buffer to the screen. To have the dbms_xplan.display_cursor show what I want, I started writing a little script against V$SQL to get the latest "real" SQL-statement, but then I realised I cannot possibly be the first to encounter this problem. Googling led me to this very useful blog entry by Jonathan Lewis. It contains almost everything you want to know about the display_cursor function. A simple "set serveroutput off" is enough to get the function working! "
    http://rwijk.blogspot.nl/2008/03/dbmsxplandisplaycursor.html
    So, actually you should have set serverout off.
    Probably also depending on how you're gathering the execution plan statistics (you're not using the gather_plan_statistics hint?) and the SQL*Plus version and database version you're working with...

  • Image Caching

    Hi
    I'm trying to implement Image Caching on an Oracle XE database following Tyler Muth's blog post http://tylermuth.wordpress.com/tag/oracle-plsql-images-caching/
    Has anyone managed to implement this successfully?
    I've run the following as sys :
    begin
    DBMS_EPG.SET_DAD_ATTRIBUTE (
       dad_name    => 'APEX',
       attr_name   => 'cgi-environment-list',
       attr_value  => 'HTTP_IF_NONE_MATCH');
    DBMS_EPG.SET_DAD_ATTRIBUTE (
       dad_name    => 'APEX',
       attr_name   => 'cgi-environment-list',
       attr_value  => 'IF_MODIFIED_SINCE');
    end;
    /And my function to download the images includes the following:
        v_etag_head := owa_util.get_cgi_env('HTTP_IF_NONE_MATCH');
        v_etag_str := lpad(p_file_id,2,0)||to_char(v_date_last_modified,'DDMMYYYYHH24MISS');
        if v_etag_head = v_etag_str then
          owa_util.status_line(
          NSTATUS         => 304,
          CREASON         => 'Not Modified',
          BCLOSE_HEADER   => true);
          return;
        else
          owa_util.mime_header(v_mimetype, FALSE );
          htp.p('Date: ' ||to_char(sysdate,'Dy, DD Mon RRRR hh24:mi:ss')||' GMT');
          htp.p('Content-length: '||v_file_length);
          htp.p('Content-Disposition: inline; filename="'||v_filename||'"');
          htp.p('Last-Modified: '||to_char(v_date_last_modified,'Dy, DD Mon RRRR hh24:mi:ss')||' GMT');
          htp.p('ETag: '||v_etag_str);
          htp.p('Expires: ' ||to_char(sysdate+(1/12),'Dy, DD Mon RRRR hh24:mi:ss')||' GMT');
          htp.p('Cache-Control: max-age=300');
          owa_util.http_header_close;
          wpg_docload.download_file(v_blob);
       end if;However, owa_util.get_cgi_env('HTTP_IF_NONE_MATCH') always returns null. I've checked using LiveHTTPHeaders and the If-None-Modified is being sent. This is running on a local Oracle XE database (using the EPG), running APEX 4.0.0.00.46 and Windows 7.
    I've searched the forum and there are four other posts that refer to HTTP_IF_NONE_MATCH, however these haven't helped. If anyone has any ideas or needs any more information, please let me know. And if you have got this working I'd love to know how, even just so I know it's possible!!
    Thanks for any help.
    Sara

    Bump.
    Has anyone managed to implement this successfully? Is there anything I can check? Or is this a bug with the EPG?
    This is causing us massive problems and I can't see what I've done wrong. Any help is really appreciated.
    Thanks
    Sara

  • How to remove blocks from buffer cache for a specific object

    hi everybody,
    is it possible to remove blocks which belogns to a specific object (a table for ex) from buffer cache.
    as you know, there is
    alter system flush buffer_cache;command but it does it's job for all buffer cache. if you ask me why i want this, for tuning reasons. I want to test some plsql codes when they run as if they are running for the first time (reading from disk).
    ps: I use oracle 11g r2

    Hi mustafa,
    Your performance will not degrade if you run the query second time ( if i understood correctly, you worry about the performance if you execute the procedure second time). Executing/running the code/sql statements over and over again will have following two good benefits.
    1) This will avoid hard parsing (Hard parsing is resource intensive operation and this generally increase the overall processing time.
    2) This will avoid physical read IO (You gonna see the benefits if data blocks already cached and you dont have to spend time in reading blocks from disk. Reading from disk is much costlier and time consuming operation as compared to data in RAM)
    Having that said sometime bad written queries will acquire more blocks then required and consume most part of buffer cache, and this can some times effect the other important blocks and force to flush out from buffer cache.
    Oracle have built some intelligence for large full table scan operations for e.g will doing full table scan(I hope you already know what is fts) oracle will put its blocks at end of LRU chain. So these will be the buffers will would flush out first then any other.
    From oracle documentation:
    "When the user process is performing a full table scan, it reads the blocks of the table into buffers and puts them on the LRU end (instead of the MRU end) of the LRU list. This is because a fully scanned table usually is needed only briefly, so the blocks should be moved out quickly to leave more frequently used blocks in the cache.
    You can control this default behavior of blocks involved in table scans on a table-by-table basis. To specify that blocks of the table are to be placed at the MRU end of the list during a full table scan, use the CACHE clause when creating or altering a table or cluster. You can specify this behavior for small lookup tables or large static historical tables to avoid I/O on subsequent accesses of the table."
    Regards
    Edited by: 909592 on Feb 6, 2012 4:37 PM

  • PLSQL Insert and Special Circumstance

    I am using APEX 4.0.
    This one is strange. I have a system used to renew UCC filings, which must be renewed within six months of their expiration. I have a report (UCC Tracker Report) which lists all records falling within this date range. I click a sequence number (column link) for a record and go to a form detail page (UCC Detail) for the record identified by the sequence number. There are a number of data items on this page which will not change with the filing renewal; so I want to carry these data items into the new record. I do this with a button labeled "Renew UCC." It executes a PLSQL process which does two things: (1) it inserts a new record with the data preserved from the old record, and (2) updates the old record with an "H" in the "histrec" column (which makes this record history).
    Now, the second part works; the old record is always updated. The first part (the insert) does not work, except under a special circumstance. Back on the UCC Tracker Report page there is a button labeled "Enter New UCC Record." This button calls the same page (UCC Detail) that is called for the renewal, but, of course, since it is for new record, it will have null items. There is a button on it (Return to UCC Tracker Report) which will simply allow the user to return to the report page. If the user goes to this UCC Detail page, then returns to the UCC Tracker Report page, and then clicks a sequence number (column link) to bring up the record for renewal, clicking the Renew UCC button causes the PLSQL to insert the new record. Otherwise, it will not insert.
    Somewhere there must be a setting that needs to be changed for this form to operate as intended. Please help.
    **********************************Additional Wrinkle***************************
    After posting this question, I tried one more thing. I clicked the "Enter New UCC Record" button to go to the UCC Detail page and then edited the Action on the "Return to UCC Tracker Report" button to clear the cache on this page. After that the PLSQL insert would not work.
    Edited by: Doug on Apr 27, 2012 3:45 PM

    Hi,
    The Form page where you Create/Edit does not really come into play in the duplication of record process , unless you are trying to insert a row on that page (which would be bad idea) in the Page rendering side. Analyzing the UCC Detail page may offer clues, but it can also confuse.
    Chances are you are inserting a new record while navigating out of the UCC Tracker Report page in a OnSubmit process. And that would be the right thing to do.
    You also need to make a distinction between "Row not getting inserted in the table" and "Row not showing in the Edit (UCC Detai)". If the parameter passing from UCC Tracker Report to UCC Detail page is not correct you will not see the newly created row even though it is present in the table.
    The scenario you are describing is a routine one.
    If you put up this scenario on apex.oracle.com it will be possible to help fix it. Otherwise one can only guess !
    Regards,

  • Caching in TopLink

    Hi,
    I have created a session bean in a TopLink Project. This hits a DB.
    My proc is as follows:
    public Vector findHR()
    Session session = getSessionFactory().acquireSession();
    String sqlStatement="select * from locations where location_id > 1100";
    DataReadQuery readQuery = new DataReadQuery(sqlStatement);
    //readQuery.dontMaintainCache();
    Vector queryResults = (Vector)session.executeQuery(readQuery);
    if(queryResults != null)
    System.out.println("Size=" +queryResults.size());
    session.release();
    return queryResults;
    I have created a datacontrol out of this proc and have put the same on a form.
    Now my Qs are:
    1)when I fire the 'dynamic' query "select * from locations where location_id > 1100" then does TopLink generate an Object when it returns the results?
    2) On successive invocations, does it cache the object and avoid DB hits?
    3) Is the call to dontMaintainCache() valid in here?? - this is to avoid caching and making the query hit the DB again and afresh.
    Regards,
    venkat

    This is a followup to Venkat's question...
    We need a mechanism to execute queries. These queries will be stored in the table and these queries can change. We don't want to create / modify the entity bean when there is a addition or modification in the sql queries. Also these SQL queries are complex and the business logic is stored in plsql functions / procs. We can't create java objects as we don't have a visibility on the data structures that will be required to accommodate the data that can be returned by those queries.
    questions we have is
    is it a good design to have such dynamic queries - we seem to loose the TopLink cache. Is there any other big disadvantage in doing that? Any thoughts if its not advisable?
    Is there any other known mechanism to achieve such functionality?
    We are using oc4j as an application server and can use EJB 3.0 as another option - but couldn't find a way to write such dynamic query without creating the java classes.
    Thanks in advance!
    Regards,
    -Pranav.
    Message was edited by:
    user533287

  • Table in memory using plsql

    I have to convert a table and the plsql will check a small table a lot of times , I'd like to put this table in memory and do this check using variables,
    I trying to use record type but I have to find a record using 2 columns and I can not able to use the EXISTS,
    I'd like to have a table cache, and find a row in this cache ( using 2 columns as key ) ,
    Any help I appreciate .

    A multilevel associative array may help you. Here is an example.
    set serveroutput on
    declare
    type row_type is record ( col_1 number, col_2 number );
    type inner_aa_type is table of row_type index by varchar2(10) ;
    type outer_aa_type is table of inner_aa_type index by varchar2(10) ;
    v_row row_type ;
    v_aa        outer_aa_type ;
    begin
    v_row.col_1 := 10 ;
    v_row.col_2 := 100 ;
    v_aa('A')('1') := v_row ;
    v_row.col_1 := 20 ;
    v_row.col_2 := 200 ;
    v_aa('A')('2') := v_row ;
    dbms_output.put_line ( v_aa('A')('1').col_1 );
    dbms_output.put_line ( v_aa('A')('1').col_2 );
    dbms_output.put_line ( v_aa('A')('2').col_1 );
    dbms_output.put_line ( v_aa('A')('2').col_2 );
    if ( v_aa.exists('A') and v_aa('A').exists('1') )
    then dbms_output.put_line( 'First test is true' );
    end if;
    if not ( v_aa.exists('A') and v_aa('A').exists('5') )
    then dbms_output.put_line( 'Second test is false' );
    end if;
    if not ( v_aa.exists('X') and v_aa('X').exists('5') )
    then dbms_output.put_line( 'Third test is false' );
    end if;
    end ;
    10
    100
    20
    200
    First test is true
    Second test is false
    Third test is false
    PL/SQL procedure successfully completed.--
    Joe Fuda
    [SQL Snippets|http://www.sqlsnippets.com/|SQL Snippets]

Maybe you are looking for

  • Couldn't Load DLL and Call JNI in Portal Servlet !!!

    Hello, I'm trying to write a small test servlet in portal which will call functions in a DLL using JNI. Here is my source code. I put my DLL in \Window\system32, usr/sap/J2E/JC01/j2ee/os_libs, even included into my portal project \PORTAL-INF\lib. But

  • ISE 1.2 and Posture Report Before Login

    Hi everyone, Is it possible for the ISE 1.2 NAC/Posture agent to submit a posture report before user login on a Windows desktop system? We're trialling ISE 1.2, performing machine based authentication using EAP-TLS/Certificates. On top of this we are

  • Color of adjustment brush in grayscale

    hope someone can help me out, I would like to get the colors of the color picker in the adjustment tool in grayscale, how can i get it, i see only colors and white. thanks Davy

  • Magic Trackpad Glass Cracked!

    I've owned my Magic Trackpad for a good few months with no issues.  Today the glass has spontaneously cracked while I was cleaning it (I wasn't even rubbing hard, just applying light pressure to the bottom edge to rub off a piece of melted chocolate)

  • I cannot connect to itune store

    please help i tried switching of wifi i just upgraded to 5.0.1 and im using iphone4