Stored procedures, pro's / con's.

Post Author: ebry74
CA Forum: General
Hello,
I work as a crystal report developer in decision support, and have been working with Crystal reports for many, many years.  A data architect has joined our team to help with the development of our data warehouse (not familiar with Crystal), and he is suggesting that we write stored procedures as a base for all of our reporting, instead linking the tables/views in crystal.  I am not necessarily opposed to doing this, as I'll gain T-SQL skills, but I was wondering if anyone would be willing to pipe in with what the pro's and con's to doing this would be.
I can with out a doubt say it will take me longer to develop reports using this method, but I'm sure I would become proficient over time.
Thanks for any input!
- Bryan

Post Author: synapsevampire
CA Forum: General
Generally it's best to post your software version with any question about any software product.
In a nutshell, Stored Procedures enjoy performance gains as a result of a precompiled execution plan. Since you posted neither your Crystal version, the database version (we can infer the type as either Sybase or SQL Server), or the type of connectivity, I can't address specifics.
One of the serious downsides about using stored procedures is that you cannot pass multiple value parameters from Crystal in the usual way. This knowledgable database person should know this about SPs, and should have forewarned you thqat if you intend to pass a group of zip codes, you'll have to write a custom front end to do so using SPs.
In Crystal you could have the users enter comma delimited values in a string parameter, but that's a bad experience for the user, and a kludge.
And in some cases, you'll find that the database isn't significantly slower using the tables and Views.
It's good that they're aware of SPs performance gains, but it's a shame that they haven't already addressed the downsides for developers when using them.
I generally avoid them unless performance demands that I use them, however I tend to NOT use tables, rather Views (make a View of just a table if need be) to allow for database changes and not having to open each report to address that change.
-k

Similar Messages

  • SQLException while calling a Stored Procedure in Oracle

    Hi all,
    I am getting this error while calling a Stored Procedure in Oracle...
    java.sql.SQLException: ORA-00600: internal error code, arguments: [12259], [], [
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:207)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:540)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1273)
    at oracle.jdbc.ttc7.TTC7Protocol.fetch(TTC7Protocol.java:780)
    at oracle.jdbc.driver.OracleResultSet.next(OracleResultSet.java:135)
    at StoredProcedureDemo.main(StoredProcedureDemo.java:36)
    The Program is ...
    import java.sql.*;
    public class StoredProcedureDemo {
         public static void main(String[] args) throws Exception {
              Connection con = null;
              ResultSet rs = null;
              Statement st = null;
              CallableStatement cs = null;
              int i;
              try {
                   Class.forName("oracle.jdbc.driver.OracleDriver");
                   con = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:SHYAM","scott","tiger");
                   System.out.println("Got Connection ");
                   st = con.createStatement();
                   String createProcedure = "create or replace PROCEDURE Get_emp_names (Dept_num IN NUMBER) IS"
                             +" Emp_name VARCHAR2(10);"
                             +" CURSOR c1 (Depno NUMBER) IS"
                             +" SELECT Ename FROM emp WHERE deptno = Depno;"
                             +" BEGIN"
                             +" OPEN c1(Dept_num);"
                             +" LOOP"
                             +" FETCH c1 INTO Emp_name;"
                             +" EXIT WHEN C1%NOTFOUND;"
                             +" END LOOP;"
                             +" CLOSE c1;"
                             +" END;";
                   System.out.println("Stored Procedure is \n"+createProcedure);
                   i = st.executeUpdate(createProcedure);
                   System.out.println("After creating the Stored Procedure "+i);
                   cs = con.prepareCall("{call Get_emp_names(?)}");
                   System.out.println("After calling the Stored Procedure ");
                   cs.setInt(1,20);
                   System.out.println("Before executing the Stored Procedure ");
                   rs = cs.executeQuery();
                   System.out.println("The Enames of the given Dept are ....");
                   while(rs.next()) {
                        System.out.println("In The while loop ");
                        System.out.println(rs.getString(1));
              catch (Exception e) {
                   e.printStackTrace();
    Stored Procedure is ...
    create or replace PROCEDURE Get_emp_names (Dept_num IN NUMBER) IS
    Emp_name VARCHAR2(10);
    CURSOR c1 (Depno NUMBER) IS
    SELECT Ename FROM emp WHERE deptno = Depno;
    BEGIN
    OPEN c1(Dept_num);
    LOOP
    FETCH c1 INTO Emp_name;
    EXIT WHEN C1%NOTFOUND;
    END LOOP;
    CLOSE c1;
    END;
    Stored procedure is working properly on sql*plus(Oracle 8.1.5)) editor. But it is not working from a standalone java application. Can anyone please give me a solution.
    thanks and regards
    Shyam Krishna

    The first solution is to not do that in java in the first place.
    DDL should be in script files which are applied to oracle outside of java.
    Other than I believe there are some existing stored procedures in Oracle that take DDL strings and process them. Your user has to have permission of course. You can track them down via the documentation.

  • Calling a stored procedure of oracle 8 from java

    hello,
    i made a stored procedure as below in 1 program :
         String url = "jdbc:odbc:rjc1";
         Connection con = DriverManager.getConnection(url,"scott","tiger");
         Statement stmt = con.createStatement();
         String createProc =
              "Create procedure sp1 as select * from items order by iprice desc";
         stmt.executeUpdate(createProc);
    in other program i have a code as below to retrieve the result of stored procedure :
    CallableStatement cs = con.prepareCall("{call sp2}");
         ResultSet rs = cs.executeQuery();
    the error message that i get is SCOTT.SP1 is invalid.
    any help would be great.
    thanx in advance.

    hello :
    1. i created procedure sp2 and called sp2.
    2. sql statement that we created works fine on oracle - sql i have tested the same.
    3. i did not create a separte userid or password in oracle i was using test account scott which is already present in oracle.
    any thoughts please.

  • Calling a stored procedure or ioracle 8 from java

    hello,
    i made a stored procedure as below in 1 program :
         String url = "jdbc:odbc:rjc1";
         Connection con = DriverManager.getConnection(url,"scott","tiger");
         Statement stmt = con.createStatement();
         String createProc =
              "Create procedure sp1 as select * from items order by iprice desc";
         stmt.executeUpdate(createProc);
    in other program i have a code as below to retrieve the result of stored procedure :
    CallableStatement cs = con.prepareCall("{call sp2}");
         ResultSet rs = cs.executeQuery();
    the error message that i get is SCOTT.SPa is invalid.
    any help would be great.
    thanx in advance.

    this might be a silly answer, but i donot see any SPa in ur code????

  • How Do I Call PL/SQL Stored Procedure That Returns String Array??

    I Have Problem Calling An Oracle(8i) Stored Procedure That Returns Array Type (Multi Rows)
    (As Good As String Array Type..)
    In This Fourm, I Can't Find Out Example Source.
    (Question is Exist.. But No Answer..)
    I Want An Example,, Because I'm A Beginner...
    (I Wonder...)
    If It Is Impossible, Please Told Me.. "Impossible"
    Then, I'll Give Up to Resolve This Way.....
    Please Help Me !!!
    Thanks in advance,

    // Try the following, I appologize that I have not compiled and run this ... but it is headed in the right direction
    import java.sql.*;
    class RunStoredProc
    public static void main(String args[])
    throws SQLException
    try
    Class.forName("oracle.jdbc.driver.OracleDriver");
    catch(Exception ex)
    ex.printStackTrace();
    java.util.Properties props = new java.util.Properties();
    props.put("user", "********"); // you need to replace stars with db userid
    props.put("password", "********"); // you need to replace stars with userid db password
              // below replace machine.domain.com and DBNAME, and port address if different than 1521
    Connection conn =
    DriverManager.getConnection("jdbc:oracle:thin:@machine.domain.com:1521:DBNAME", props);
    // replace "Your Stored Procedure" with your stored procedure
    CallableStatement stmt = conn.prepareCall("Your Stored Procedure");
    ResultSet rset = stmt.execute();
    while(rset.next())
    System.out.println(rset.getString(1));

  • Error ORA-04031 while executing a stored procedure from Pro C++ code

    I am getting the error ORA-04031(Unable to allocate 4096 bytes of shared memory("Shared Pool",.....)) while trying to execute a stored procedure from my pro*C application. This happens only after a few hours since the application has been running. I am closing the cursor after every database call.
    Does anyone know why it is happening and any possible solutions?
    TIA
    Srithaj.

    One thing that can be done is to flush the shared pool before starting the application.
    alter system flush shared pool;
    Another is to increase the shared pool size by setting the parameter shared_pool_size in init_sid.ora file.
    null

  • What are the pros and cons of storing heavely used CFCs in the application scope?

    I've been storing all the required CFCs for a site in the application scope. During onApplicationStart I do something like this application.objSomeCfc =CreateObject('component', 'com.someCfc').init().
    Here is my reasoning.
    Get the CFCs initialized once and stored in memory for better performance.
    Using CreateObject several times on each page load can have a negative impact on performance.
    Having one place to create application scoped CFCs makes it easier to manage code.
    So is my thinking flawed? Are there any additional pros or cons for dealing with CFCs? Is there any docs, articles, blogs, videos, frameworks, ...... that I should check that may change my perspective on how I'm doing this?
    Thanks

    Your approach is fine, depending on how many and what type of CFCs you are talking about. If they are "singletons" - that is, only one instance of each CFC is needed to be in memory and can be reused/shared from multiple parts of your application - caching them in the application scope is common.  Just make sure they are thread safe ("var" or local.* all your method variables).
    You might consider taking advantage of a dependency injection framework, such as DI/1 (part of the FW/1 MVC framework), ColdSpring, or WireBox (a module of the ColdBox platform that can be used independently).  They have mechanisms for handling and caching singletons.  Then you wouldn't have to go to the application scope to get your CFC instances.
    -Carl V.

  • Dynamic SQL Stored Procedure call in Pro*C Application

    Hello All
    Could you help with a sample Pro*C program (or snippet) which has a dynamic call to a stored procedure? The procedure to be called is determined at run time and so also the number of parameters to it.
    Is this even possible using Pro*C?
    Thanks in Advance
    RD

    Hi Colin & Faust
    We found sample pro*c programs for dynamically calling PL/SQL blocks but not for dynamically calling stored procedures.
    Heres the program we compiled successfully but it doesnt work, it gives a core dump on execution. Could you point out whats wrong.
    #include<stdio.h>
    #include<iostream>
    #include<fstream>
    #include<stdlib.h>
    #include<sqlca.h>
    #include<string>
    #include<sys/types.h>
    #include<sys/ipc.h>
    #include<sys/msg.h>
    #include<thread.h>
    #include<sqlda.h>
    #include<sqlcpr.h>
    using namespace std;
    #define TRUE 1
    int main()
    EXEC SQL BEGIN DECLARE SECTION;
    char *UserID = getenv( "DATABASE" );
    char query[100];
    EXEC SQL END DECLARE SECTION;
    SQLDA *bind_des;
    EXEC SQL CONNECT :UserID;
    EXEC SQL WHENEVER SQLERROR CONTINUE;
    bind_des = SQLSQLDAAlloc( 0, 2, (size_t)10, (size_t)0 );
    bind_des->N = 2;
    strcpy( query, "CALL sel_dept( :empno,:name );");
    //Calling stored procedure sel_dept( no NUMBER IN, name VARCHAR2 OUT)
    EXEC SQL PREPARE sql_stmt from :query;
    EXEC SQL DESCRIBE BIND VARIABLES FOR sql_stmt INTO bind_des;
    bind_des->N = bind_des->F;
    //cout << " bind_des->N after assigment = " << bind_des->N;
    //--------------------- Enter the Input values -----------------------------
    //parameter :1
    bind_des->L[0] = 4;
    /* Allocate storage for value and null terminator. */
    bind_des->V[0] = (char *) malloc(bind_des->L[0] + 1);
    /* Store value in bind descriptor. */
    strcpy(bind_des->V[0], "50");
    /* Set datatype to STRING. */
    bind_des->T[0] = 2;
    //parameter :2
    bind_des->L[1] = 20;
    /* Allocate storage for value and null terminator. */
    bind_des->V[1] = (char *) malloc(bind_des->L[1] + 1);
    /* Store value in bind descriptor. */
    strcpy(bind_des->V[1], "");
    /* Set datatype to STRING. */
    bind_des->T[1] = 5;
    EXEC SQL EXECUTE sql_stmt;
    //cout<<"name"<<"\t"<bind_des->V[0]<<"\t"<<bind_des->V[1]<<endl;
    cout << "name"<<"\t";
    cout << "bind_des->V[0]=" << bind_des->V[0]<<"\t";
    cout << "bind_des->V[1]=" << bind_des->V[1]<<"\t"<<endl;
    for (int i = 0; i < bind_des->F; i++) /* for bind descriptor */
    free(bind_des->V);
    free(bind_des->I[i]);
    SQLSQLDAFree(0, bind_des);
    EXEC SQL COMMIT;
    return 0;

  • How to call stored procedure from Pro*C

    How to call stored procedure from Pro*C ?
    my system spec is SuSE Linux 9.1, gcc version : 3.3.3, oracle : 10g
    my Pro*C code is the following..
    EXEC SQL EXECUTE
    begin
    test_procedure();
    end;
    END-EXEC;
    the test_procedure() has a simple update statement. and it works well in SQL Plus consol. but in Pro*C, there is a precompile error.
    will anybody help me what is the problem ??

    I'm in the process of moving C files (with embedded SQL, .PC files) from Unix to Linux. One program I was trying to compile had this piece of code that called an Oracle function (a standalone), which compiled on Unix, but gives errors on Linux:
    EXEC SQL EXECUTE
    BEGIN
    :r_stat := TESTSPEC.WEATHER_CHECK();
    END;
    END-EXEC;
    A call similar to this is in another .PC file which compiled on Linux with no problem. Here is what the ".lis" file had:
    Pro*C/C++: Release 10.2.0.1.0 - Production on Mon Jun 12 09:26:08 2006
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Error at line 193, column 5 in file weather_check.pc
    193 BEGIN
    193 ....1
    193 PCC-S-02346, PL/SQL found semantic errors
    Error at line 194, column 8 in file weather_check.pc
    194 :r_stat := TESTSPEC.WEATHER_CHECK();
    194 .......1
    194 PLS-S-00000, Statement ignored
    Error at line 194, column 18 in file weather_check.pc
    194 :r_stat := TESTSPEC.WEATHER_CHECK();
    194 .................1
    194 PLS-S-00201, identifier 'TESTSPEC.WEATHER_CHECK' must be declared
    Pro*C/C++: Release 10.2.0.1.0 - Production on Mon Jun 12 09:26:08 2006
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    System default option values taken from: /oracle_client/product/v10r2/precomp/ad
    min/pcscfg.cfg
    Error at line 194, column 18 in file weather_check.pc
    :r_stat := TESTSPEC.WEATHER_CHECK();
    .................1
    PLS-S-00201, identifier 'TESTSPEC.WEATHER_CHECK' must be declared
    Error at line 194, column 8 in file weather_check.pc
    :r_stat := TESTSPEC.WEATHER_CHECK();
    .......1
    PLS-S-00000, Statement ignored
    Semantic error at line 193, column 5, file weather_check.pc:
    BEGIN
    ....1
    PCC-S-02346, PL/SQL found semantic errors

  • Stored procedures in Pro C

    I know that stored procedures for Oracle are
    written in PL/SQL, and now you could also
    do so using Java. I am, however, interested
    in knowing if it is possible to write stored
    procedures in C (actually Proc-C), for
    performance reasons. Essentially, one should
    be able to create a dll out of the Pro-C code
    and somehow make the Oracle server to attach
    the dll on demand, when I invoke the stored
    procedure.
    Don't know if any of this is possible. If
    yes, then I would very much like to know more
    about it, with some sample code or some pointer to documentation.
    Thanks.
    null

    This may be because PROC is maintaining and referring(Handle) the OLD package.
    Try the following code
    EXEC ORACLE OPTION (ORACA =YES);
    EXEC ORACLE OPTION (RELEASE_CURSOR=YES);
    Recreate the package thru PROC is another way of doing it.
    Closing the connections and re-establishing is one workaround.

  • Execute Oracle Java Stored Procedure in Pro*C

    I found this is a very usefull example of calling Java procedure via Pro*C module. You could find the source and instructions at: http://www.oracle.com/technology/sample_code/tech/java/travel/travelschema.htm#user.
    Some minor issues arose during installation of C/C++ environment. I use MS Visual Studio 6 and it works just fine. Also you have to be very observant when modifying "procCallJSP.bat" file where SETing environment variables.
    I found some flaw in Pro*C "procCallJSP.pc" script. During the execution of "procCallJSP.exe", when you provide not numeric argumet at the command prompt (eg. ` ) it puts the program to infinite loop. It needs an additional check to eliminate such kind of typing. The change needs to applied at line # 142 in "procCallJSP.pc". Other then that it works OK.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by tomon Lee ([email protected]):
    I try to call a stored procedure of oracle8i
    in Pro*c using follow statement:
    EXEC SQL EXCUTE
    BEGIN
    insert_date(sysdate,:out_timecode);
    END;
    END-EXEC;
    but when i use "proc SQLCHECK=SEMANTICS test.pc" to compile it ,but it return an
    error as follow:
    "insert_date must be declared."
    but the sample code above come from
    oracle8i 8.1.6's documents.
    what's wrong with me?<HR></BLOCKQUOTE>
    If you have right to exec the insert_date ,Check the database connect set in your cfg file

  • Error when stored procedure returns cursor in pro c

    Hi
    I was trying to make work the stuff explained at
    [m-2537153]
    It executes a stored procedure from pro c that returns a cursor.
    But when i compllie at pro c I get following error. My procedure name is TEST.
    If i change the output parameter to a int value. It compiles ok.
    PLS-S-00306, wrong number or types of arguments in call to 'TEST'
    Error at line 34, column 5 in file E:\C\Test\tt.pc
    TEST(:test_cursor);
    +....1+
    PLS-S-00000, Statement ignored
    Semantic error at line 33, column 1, file E:\C\Test\tt.pc:
    BEGIN
    +1+
    PCC-S-02346, PL/SQL found semantic errors
    Can any one point out what could be the error?
    I am working from oracle 8i client. which connects to oracle 9.0.1.
    OS is win 2000 sp4

    This is my code
    int main(int argc, char** argv)
    +{+
    EXEC SQL BEGIN DECLARE SECTION;
    char user[]="scott";
    char pwd[]="tiger";
    char server[]="testdb";
    char msg_buf[51|http://forums.oracle.com/forums/]+="";+
    int intarg1;
    int intId;
    char strName[]="";
    SQL_CURSOR tcr;
    EXEC SQL END DECLARE SECTION;
    +/* Register sql_error() as the error handler. */+
    EXEC SQL WHENEVER SQLERROR DO sql_error("ORACLE error\n");
    EXEC SQL CONNECT :user IDENTIFIED BY :pwd USING :server;
    Printf("Connected to %s successfully",server);
    EXEC SQL ALLOCATE :tcr;
    EXEC SQL EXECUTE
    BEGIN
    TEST(:tcr);
    END;
    END-EXEC;
    Procedure name is TEST and it like
    CREATE OR REPLACE PROCEDURE TEST (crsdata out sys_refcursor)
    as
    BEGIN
    open crsdata for select id,name from newtab;
    END;

  • Do SQL pros write seperate stored procedures to handle Save and update operations?

    hi friends,
    Currently i'm bit confused with the industry standard of writing store procedures for save and update operations. I have sees people write separate stored procedure to handle save and update operations even they have to write complex queries. Also I have
    seen people writing one store procedure to handle both Save and Update operations even when the queries are complicated. when I asked them why they do it, they said why should waste time on writing another query to update instead write one save store procedure
    to handle all.
    In here there are SQL Pros, Gurus, what would say about this?
    what is the actual industry standard with stored procedure to perform save and update operations, do you write separate ones or do both in one?
    thanks
    I use Visual studio 2012 Ultimate and SQL server 2008 developer edition!

    >what is the actual industry standard with stored procedure to perform save and update operations
    There is no industry standard. Guideline though you want to be happy with the sp-s; same for your peers.
    As noted above the MERGE command is like a Swiss Army knife; it can perform INSERT, UPDATE & DELETE
    in one (huge) statement.
    Make sure you pick good names for the sp-s, document the parameters and comment the logic if any.
    Format the stored procedure for readability:
    http://www.sqlusa.com/sqlformat/
    Kalman Toth Database & OLAP Architect
    SELECT Query Video Tutorial 4 Hours
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Using CLOB data type - Pros and Cons

    Dear Gurus,
    We are designing a database that will be receiving comments from external data source. These comments are stored as CLOB in the external database. We found that only 1% of incoming data will be larger than 4000 characters and are now evaluating the Pros and Cons of storing only 4000 characters of incoming comments in VARCHAR2 data type or using CLOB data type.
    Some of the concerns brought up during discussion were:
    - having to store CLOBs in separate tablespace;
    - applications, such Toad require changing defaults settings to display CLOBs in the grid. Default value is not to display them;
    - applications that build web page with CLOBs will be struggling to fit 18 thousand chararcters of which 17 thousand are blank lines;
    - cashing CLOBs in memory will consume big chunk of data buffers which will affect performance;
    - to manipulate CLOBs you need PL/SQL anonymous block or procedure;
    - bind variables cannot be assigned CLOB value;
    - dynamic SQL cannot use CLOBs;
    - temp tables don't work very well with CLOBs;
    - fuzzy logic search on CLOBs is ineffective;
    - not all ODBC drivers support Oracle CLOBs
    - UNION, MINUS, INTERSECT don't work with CLOBs
    I have not delt with CLOB data type in the past, so I am hoping to hear from you of any possible issues/hastles we may encounter?

    848428 wrote:
    Dear Gurus,
    We are designing a database that will be receiving comments from external data source. These comments are stored as CLOB in the external database. We found that only 1% of incoming data will be larger than 4000 characters and are now evaluating the Pros and Cons of storing only 4000 characters of incoming comments in VARCHAR2 data type or using CLOB data type.
    Some of the concerns brought up during discussion were:
    - having to store CLOBs in separate tablespace;They can be stored inline too. Depends on requirements.
    - applications, such Toad require changing defaults settings to display CLOBs in the grid. Default value is not to display them;Toad is a developer tool so that shouldn't matter. What should matter is how you display the data to end users etc. but that will depend on the interface. Some can handle CLOBs and others not. Again, it depends on the requirements.
    - applications that build web page with CLOBs will be struggling to fit 18 thousand chararcters of which 17 thousand are blank lines;Why would they struggle? 18,000 characters is only around 18k in file size, that's not that big to a web page.
    - cashing CLOBs in memory will consume big chunk of data buffers which will affect performance;Who's caching them in memory? What are you planning on doing with these CLOBs? There's no real reason they should impact performance any more than anything else, but it depends on your requirements as to how you plan to use them.
    - to manipulate CLOBs you need PL/SQL anonymous block or procedure;You can manipulate CLOBs in SQL too, using the DBMS_LOB package.
    - bind variables cannot be assigned CLOB value;Are you sure?
    - dynamic SQL cannot use CLOBs;Yes it can. 11g supports CLOBs for EXECUTE IMMEDIATE statements and pre 11g you can use the DBMS_SQL package with CLOB's split into a VARCHAR2S structure.
    - temp tables don't work very well with CLOBs;What do you mean "don't work well"?
    - fuzzy logic search on CLOBs is ineffective;Seems like you're pulling information from various sources without context. Again, it depends on your requirements as to how you are going to use the CLOB's
    - not all ODBC drivers support Oracle CLOBs not all, but there are some. Again, it depends what you want to achieve.
    - UNION, MINUS, INTERSECT don't work with CLOBsTrue.
    I have not delt with CLOB data type in the past, so I am hoping to hear from you of any possible issues/hastles we may encounter?You may have more hassle if you "need" to accept more than 4000 characters and you are splitting it into seperate columns or rows, when a CLOB would do it easily.
    It seems as though you are trying to find all the negative aspects of CLOBs and ignoring all the positive aspects, and also ignoring the negative aspects of not using CLOB's.
    Without context you're assumptions are just that, assumptions, so nobody can tell you if it will be right or wrong to use them. CLOB's do have their uses, just as XMLTYPE's have their uses etc. If you're using them for the right reasons then great, but if you're ignoring them for the wrong reasons then you'll suffer.

  • Stored Procedures for Simple SQL statements

    Hi Guys,
    We are using Oracle 10g database and Web logic for frontend.
    The Product is previously developed in DotNet and SQL Server and now its going to develop into Java (Web Logic) and Oracle 10g database.
    Since the project is developed in SQL Server, there are lot many procedures written for simple sql queries. Now I would like to gather your suggestions / pointers on using procedures for simple select statements or Inserts from Java.
    I have gathered some list for using PL/SQL procedure for simple select queries like
    Cons
    If we use procedures for select statements there are lot many Ref Cursors opened for Simple select statements (Open cursors at huge rate)
    Simple select statements are much faster than executing them from Procedure
    Pros
    Code changes for modifying select query in PL/SQL much easier than in Java
    Your help in this regard is more valuable. Please post your points / thoughts here.
    Thanks & Regards
    Srinivas
    Edited by: Srinivas_Reddy on Dec 1, 2009 4:52 PM

    Srinivas_Reddy wrote:
    Cons
    If we use procedures for select statements there are lot many Ref Cursors opened for Simple select statements (Open cursors at huge rate)No entirely correct. All SQLs that hit the SQL engine are stored as cursors.
    On the client side, you have an interface that deals with this SQL cursor. It can be a Java class, a Delphi dataset, or a PL/SQL refcursor.
    Yes, cursors are created/opened at a huge rate by the SQL engine. But is is capable of doing that. What you need to do to facilitate that is send it SQLs that uses bind variables. This enables the SQL engine to simply re-use the existing cursor for that SQL.
    Simple select statements are much faster than executing them from ProcedureAlso not really correct. SQL performance is SQL performance. It has nothing to do with how you create the SQL on the client side and what client interface you use. The SQL engine does not care whether you use a PL/SQL ref cursor or a Java class as your client interface. That does not change the SQL engine's performance.
    Yes, this can change the performance on the client side. But that is entirely in the hands of the developer and how the developer selected to use the available client interfaces to interface with the SQL cursor in the SQL engine.
    Pros
    Code changes for modifying select query in PL/SQL much easier than in JavaThis is not a pro merely for ref cursors, but using PL/SQL as the abstraction layer for the data model implemented, and having it provide a "business function" interface to clients, instead of having the clients dealing with the complexities of the data model and SQL.
    I would seriously consider ref cursors in your environment. With PL/SQL servicing as the interface, there is a single place to tune SQL, and a single place to update SQL. It allows one to make data model changes without changing or even recompiling the client. It allows one to add new business logical and processing rules, again without having to touch the client.

Maybe you are looking for

  • Unresolved cross reference - unresolved text inset

    Is ti possible having at a book all crosses unresolved just because of file renamig?? it's hard to understand the philosophy of resolving crosses, any knowledge would be welcome

  • How do you make the "mouse down event" achnolage the area of an image

    Hi I am trying to program a simple game. In this game I would like to insert giff images, that when "clicked on" by the mouse, will finallly return some kind of action. In the book that I am reading, I have learnt how to use the basics of the "moused

  • Pops When Recording

    I am getting intermittent static pops when recording live audio. I know that it's not clipping, because I am setting the peaks below zero and I get no warning message when the recording is done. I thought that maybe it might be my mic pre-amp/line-in

  • When starting iTunes (for WinXP) and go to Store, crashes with R6002

    As the subject says, when I try to start iTunes on this WinXP machine, and it is set to go to the store (or I start it otherwise, and then choose to go to the store) it crashes (freezes) and gives a R6002 floating point support not loaded error... I

  • Wacom functions not working in Lightroom

    I recently picked up a Wacom Intuos Pro second hand. It seems to work fine in all applications except Lightroom (5.6), which it refuses to recognise. None of the regular Express buttons work right and even right-click fails. Help!? It also can't be s