Which is better - SQL Statement in APEX or as a function returning a type?

Hi
I have a general question about best practices for APEX development.
If we have say a report region based on a SQL statement, is it better (from a performance perspective) to have the SQL statement defined in the region in APEX OR have the actual select statement executed in the backend and have the result set returned in a type to APEX?
As an example:
In APEX region
SELECT col1, col2, col3 FROM table_aOR
In APEX region
select col1, col2, col3 from TABLE(CAST(<my package>.<my proceduere > AS <my type >)) ;<my package>.<my proceduere > would obviously execute the statement
SELECT col1, col2, col3 FROM table_ausing dynamic SQL and return the results to APEX in thy type <my type>.
Apologies if this sounds to be a really stupid thing to ask.
Kind regards
Paul

Denes Kubicek wrote:
You should use a pipelined function only then when you can't use SQL. Otherwise SQL is the way to go.
Denes Kubicek
http://deneskubicek.blogspot.com/
http://www.opal-consulting.de/training
http://apex.oracle.com/pls/otn/f?p=31517:1
------------------------------------------------------------------------------thanks Denes... but does it matter if:
1. The SQL statement is actually defined in the APEX region
or
2: The select statement is stored in a packageD function and returned to APEX?
I seem to recall an article I read stating that it is best for all client applications to call stored procedures and functions rather than have SQL statement embedded in the actual application?
Kind regards
Paul

Similar Messages

  • SQL statement using result of aggregate min function to fetch a row - how?

    Need help trying to get to something seemingly simple. I'll provide a simple example to illustrate the problem.
    I'll be using a simple addresses table with 4 fields.
    Create the table:
      CREATE TABLE "ADDRESSES"
       (     "OWNER_NAME" VARCHAR2(20 BYTE),
         "STREET_NAME" VARCHAR2(20 BYTE),
         "STREET_NUMBER" NUMBER
       ) ;populate with 6 rows
    Insert into ADDRESSES (OWNER_NAME,STREET_NAME,STREET_NUMBER) values ('FRED','MAIN',1);
    Insert into ADDRESSES (OWNER_NAME,STREET_NAME,STREET_NUMBER) values ('JOAN','MAIN',2);
    Insert into ADDRESSES (OWNER_NAME,STREET_NAME,STREET_NUMBER) values ('JEAN','MAIN',3);
    Insert into ADDRESSES (OWNER_NAME,STREET_NAME,STREET_NUMBER) values ('JACK','ELM',1);
    Insert into ADDRESSES (OWNER_NAME,STREET_NAME,STREET_NUMBER) values ('JANE','ELM',2);
    Insert into ADDRESSES (OWNER_NAME,STREET_NAME,STREET_NUMBER) values ('JEFF','ELM',3);We now have this:
    Select * from addresses
    OWNER_NAME           STREET_NAME          STREET_NUMBER         
    FRED                 MAIN                 1                     
    JOAN                 MAIN                 2                     
    JEAN                 MAIN                 3                     
    JACK                 ELM                  1                     
    JANE                 ELM                  2                     
    JEFF                 ELM                  3                     
    6 rows selectedNow i wish to group by StreetName, and get a count of houses. At the same time, i'd like to know the first and last house number
        select
        street_name,
        count(*) "NBR HOUSES",
        min(street_number) "First Number",
        max(street_number) "Last Number"
         from addresses
        group by street_name
    produces
    STREET_NAME          NBR HOUSES             First Number           Last Number           
    ELM                  3                      1                      3                     
    MAIN                 3                      1                      3                     
    2 rows selectedExcellent. Now for the problem. I wish to also list on each line, the owner that lives at the first and/or last house number. Note again, assume that house number and street name is unique
    It would seem i have all that i need. Not sure how to get at it.
    I tried:
    select
        street_name,
        count(*) "NBR HOUSES",
        min(street_number) "First Number",
        max(street_number) "Last Number",
        (Select b.owner_name from addresses b where b.street_number = min(street_number) and b.owner_name = owner_name) "First Owner"
         from addresses
        group by street_nameBut get a sql syntax error, group function not allowed when i add the subselect.
    any ideas?
    thanks for any help.
    Edited by: user6876601 on Nov 19, 2009 7:08 PM
    Edited by: user6876601 on Nov 19, 2009 7:30 PM

    Hi,
    Welcome to the forum!
    Getting the highest and lowest number for each street is a fairly simple concept; simpler to describe, and simple to code.
    Now you want the owner_name associated with the highest and lowest number, which is a more complicated concept; a little harder to describe, and, unfortunately, much less simple to code, and much, much harder to explain:
    select
        street_name,
        count (*)                "NBR HOUSES",
        min (street_number)      "First Number",
        min (owner_name) KEEP (DENSE_RANK FIRST ORDER BY street_number)
                        "First Owner",
        max (street_number)      "Last Number",
        min (owner_name) KEEP (DENSE_RANK LAST ORDER BY street_number)
                        "Last Owner"
         from addresses
        group by street_name
    ;Notice that I used min for both "First Owner" and "Last Owner". Why is that?
    The important keyword in these funtions is the word FIRST or LAST that comes after DENSE_RANK and before ORDER BY. The function at the beginning is merely a tie-breaker.
    That is, MIN in this context only refers to what should happen when there is a tie for the first or last in the group. Even if such a thing is impossibe in your data, the generic functions have to have some mechanism for returning a single owner_name when two or more rows have an equal claim to having the highest street_number. For example, if we change Joan's address to 1 Main, then MIN (street_number) is still 1, obviously, but who is the person associated with the minimum street_number: is it Fred or Joan? Both have an equal claim to being the owner with the lowest address on Main Street, but aggregate functions must return a single value, so we have to have some mechanism for tell the system whether to return 'JOAN' or 'FRED'. In this example, I arbitrarily said that in the een of a tie, the lowest name, in alphabetic order, should be returned. In this case, 'FRED' would be returned, since 'FRED' is earlier than 'JOAN' .
    Thanks for including the CREATE TABLE and INSERT statements!

  • Report based on a ITEM (which has SQL statement)

    Hi everyone,
    I have a created a form based on a table which has 1 column that stores SQL statement in the database.And i am displaying the SQL statement in TEXT AREA FILED.
    What i want to do is to create a report based on that SQL statement (Which is in the TEXT AREA field on the same page).I tried to create a report region with
    :P25_SQL_STATEMENT.But i am getting an error
    ----->invalid query, no select statement found.
    How can i do a report based on the item which has SQL query in it.
    Thanks
    phani
    .

    Hi Jkallman,
    Thanks for the reply.I have a (FORM WITH REPORT) on a table which has column of SQL_STMNT VARCHAR2(2000 BYTE) which takes the SQL statement entered from the FORM.
    1.I have a report which shows all the records in the above mention table on page 10
    2.If i hit the edit button in the report i go to page 11 which i have the FORM on the above mentioned table.In that form i have a field :P11_SQL_STMNT.
    3.I am trying to create a report on the same page 11 based on the SQL query of that :P11_SQL_STMNT.
    4.I did the follwoing steps
    --> create a region
    ----> report
    ---->sql report
    and entered the following code.
    begin
    return (:P11_SQL_STMNT);
    end;
    but it is giving me the error which i mentioned in the previous post.If u need any more details i can provide
    Thanks in advance
    phani

  • JDBC - Pl/SQL-Procedure or SQL-Statement???

    Hi,
    we have got the following problem:
    Our program is entirely written in Java. It has to communicate with an ORACLE 8i database (Version 8.1.7). The big question is whether to call pl/sql-procedures which include the sql-statement (select/ insert/update) or to write the sql-statements in the Java-code directly.
    We messure the time in our test-database. The procedure took twice the time of the direct statement, althoug the sql-statement had to be parsed each time.
    What is the better way: pl/sql-procedure or sql-statements? On which conditions depend the choose?
    (For your information: our statements aren't difficult. In our testdatabase aren't much datasources.)
    Here is a snippet of our code:
    1. PL/SQL-Prozedure:
    CallableStatement cs = conn.prepareCall("begin dbrb_test_pkg.test(?,?,?); end;");
    cs.registerOutParameter(1, OracleTypes.CURSOR);
    cs.registerOutParameter(2, OracleTypes.CURSOR);
    cs.registerOutParameter(3, OracleTypes.CURSOR);
    cs.execute();
    ResultSet rs1 = ((OracleCallableStatement)cs).getCursor(1);
    ResultSet rs2 = ((OracleCallableStatement)cs).getCursor(2);
    ResultSet rs3 = ((OracleCallableStatement)cs).getCursor(3);
    2. SQL-Statements directly in Java-Code:
    String statement1b = "SELECT bva_id, bva_datva FROM bva";
    ResultSet rs1b = stmt.executeQuery(statement1b);
    String statement2b = "SELECT brb_id, brb_datein FROM brb";
    ResultSet rs2b = stmt.executeQuery(statement2b);
    String statement3b = "SELECT bper_id, bper_nz1 FROM bper";
    ResultSet rs3b = stmt.executeQuery(statement3b);
    Thanks a lot.
    Claudia and Nicole

    this is a case-to-case basis.
    it's ok to use the Statement/PreparedStatement if you're constructing your SQL or DML (insert/update/delete) statements. like when you're WHERE condition is dynamically created. this can be done also in PL/SQL (CallabeStatement) but passing of data is very tedious for you.
    the PL/SQL is much better to use if all your SQL or DML statements are fixed. besides, this is easier to maintain. when you need to change a statement, you don't need to check the statement in SQL prompt then make the necessary changes in your java codes, then compile the class. when you're using PLSQL, you just need to change and recompile the PL you made. then presto! it's done. as long as you don't change the parameters the PL receives and sends, it should perfectly work with your java code. =)

  • About hints in sql statements

    hi,
    can you plz provide any best sides for sql hints?

    Suri wrote:
    You can learn basics from below site.
    http://www.dbasupport.com/oracle/ora9i/index_hints.shtml
    What an awful article...
    >
    Using Index Hints in SQL statements - Cause we know more about our application than Oracle does
    Hints are used to give specific information that we know about our data and application, to Oracle. This further improves the performance of our system. There can be instances where the default optimizer may not be efficient for a certain SQL statements. We can specify HINTS with the SQL statements, to improve the efficiency of those SQL statements.
    <cut>
    By using Hints, you can improve certain SQL statements that might otherwise be inefficient.
    >
    That is just so wrong and completely misses the point.
    If a query is inefficient, then it can be down to poor database design, lack of statistics, lack of correct indexes (sometimes too many indexes), or poorly written SQL statements. Hacking an SQL statement with Hints to try and make it work better because you believe you "know more about our application than Oracle does", shows a complete lack of understanding of the internals of Oracle. Oracle doesn't need to know about the application, but it certainly does need to know about how the data is stored and related on the underlying tables and in the tablespaces and datafiles etc. and it's sure as hell got a better idea about that than any programmer, especially as it can change and adapt in the future as the data changes, which a programmers SQL statements (with fixed hints) won't.
    That article is a good example of the wrong attitude towards using hints. Thanks for posting that to demonstrate it.

  • Sql problem in apex LOV

    I am not able to use this SQL statement for apex LOV, any ideas?
    select username, id
    from abusers
    order by decode(id,0, NULL ,username) NULLS FIRST ;
    I get the following error message:
    1 error has occurred
    * LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query.
    Re: How to concatenate two sql statements?

    Hi
    Remove the semi-colon at the end.
    Cheers
    Ben
    http://www.munkyben.wordpress.com
    Don't forget to mark replies helpful or correct ;)

  • Calling a PL/SQL function in the SQL statement

    I have a PL/SQL function which i should call in a SQL statement.
    Let's say the function is func1(parameter1,parameter2),
    it should be called like this :- SELECT func1() FROM mytable ;
    Can any one help me out on this ?
    ---Thanx in advance

    you can call pl/sql functions from pl/sql using
    select fn1('param1','param2') from table;
    if you dont want to pass paramters, you have to specify default
    value while creating function like below
    create function fn1(p1 number default null,p2 varchar2 default
    null) return...
    now you can call using
    select fn1 from table;

  • SQL statement to compare dates and return boolean (yes/no)

    I am looking for a SQL statement that can compare 2 dates and return a boolean. 1 (yes) if date 1 is => date2-threshold or 0 (No) if date < date2-threshold
    Ie
    date1=20130603
    threshold=2 days
    date2=sysdate-threshold
    if [ 20130603 > sysdate-$threshold ]
    then
    return 1
    else
    return 0
    fi
    Thanks to all that answer.

    Assumming I want to get "date1" from some other table instead of from
    dual will this syntax be valid
    I was going to invoke another SQLPLUS from my shell script and pass it in
    as a variable but if I can do it on one shot it would be better.
    In addition, if "no rows" are found for date1 from the below query, would
    I need code to handle that
    with xx as
        select TO_DATE(last_date','yyyymmdd') date1, from dba_audit_table where ...;
         select TO_DATE('20130603','yyyymmdd') date1, sysdate date2  from dual;
    Thanks to all who answer
    [/code1]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Expensive SQL statements & no proper indexing INCLUDE LBSVAU14-BSVA FuncGrp

    Expensive SQL statements & no proper indexing INCLUDE LBSVAU14 - Function Group BSVA (Status management)
    Hi there Forum
    During a recent upgrade we have implemented EhP4 with relevant Support Packs.
    Our Early Watch Report nows highlights INCLUDE LBSVAU14 as having expensive SQL statements along with improper indexing.
    Although I have seached through OSS and Forums I can find nothing of help.
    Is there an EXPERT out there who can help because SAP tell me that is the way it works!
    Thanks.
    Carl Cavendish-Davies

    Herewith the latest results from the Early Watch report on this:
    Object Type     Total Executions         Disk Reads   Elapsed Time   Buffer Gets    Records Processed
    TABLE     457663                 3282704       21081305        28310151       20031340
    SELECT
    FROM
    "JEST"
    WHERE
    "MANDT" = :A0 AND "OBJNR" IN ( :A1 , :A2 , :A3 , :A4 , :A5 )&
    Execution Plan
    V$SQL_PLAN addr= C000000774FF4038 hash= 3408408745 sql_id 4w93fuv5khc59
    SELECT STATEMENT Estimated Costs= 3 Estimated Rows= 0 Optimizer: ALL_ROWS
    3 INLIST ITERATOR
    2 TABLE ACCESS BY INDEX ROWID JEST
    Estimated Costs= 3 Estimated Rows= 10 Estim. Bytes: 330
    Estim. CPU-Costs = 20,886 Estim. IO-Costs = 3
    1 INDEX RANGE SCAN JEST~0
    Estimated Costs= 1 Estimated Rows= 10 Access predicates:
    "MANDT"=:A0 AND (("OBJNR"=:A1 OR "OBJNR"=:A2 OR "OBJNR"=:A3 OR "OBJNR"=:A4
    OR "OBJNR"=:A5)) Search Columns: 2 Estim. CPU-Costs = 6,137 Estim. IO-Costs = 1
    Program Data:
    Origin of ABAP coding
    Program Name       Line     Created By     Last Changed By    Last Changed On
    LBSVAU14            110     SAP     SAP              08.04.2007
    000110 SELECT * FROM JEST CLIENT SPECIFIED
    000111 APPENDING TABLE JEST_BUF
    000112 FOR ALL ENTRIES IN OBJNR_TAB
    000113 WHERE MANDT EQ CLIENT
    000114 AND OBJNR = OBJNR_TAB-OBJNR.

  • Expensive SQL statements & no proper indexing INCLUDE LBSVAF14-BSVA FuncGrp

    Expensive SQL statements & no proper indexing INCLUDE LBSVAF14 - Function Group BSVA (Status management)
    Hi there Forum
    During a recent upgrade we have implemented EhP4 with relevant Support Packs.
    Our Early Watch Report nows highlights INCLUDE LBSVAF14 as having expensive SQL statements along with improper indexing.
    Although I have seached through OSS and Forums I can find nothing of help.
    Is there an EXPERT out there who can help because SAP tell me that is the way it works!
    Thanks.
    Carl Cavendish-Davies

    Herewith the latest results from the Early Watch report on this:
    Cache Statistics
    Object Type     Total Executions     Disk Reads     Elapsed Time     Buffer Gets     Records Processed
    TABLE     1716707                            1854501     13325961     25580720     19606427
    SELECT
    FROM
    "JEST"
    WHERE
    "MANDT" = :A0 AND "OBJNR" = :A1&
    Execution Plan
    V$SQL_PLAN addr= C000000774FF4038 hash= 3408408745 sql_id 4w93fuv5khc59
    SELECT STATEMENT Estimated Costs= 2 Estimated Rows= 0 Optimizer: ALL_ROWS
    2 TABLE ACCESS BY INDEX ROWID JEST
    Estimated Costs= 1 Estimated Rows= 2 Estim. Bytes: 66
    Estim. CPU-Costs = 8,804 Estim. IO-Costs = 1
    1 INDEX RANGE SCAN JEST~0
    Estimated Costs= 1 Estimated Rows= 2
    Access predicates: "MANDT"=:A0 AND "OBJNR"=:A1 Search Columns: 2
    Estim. CPU-Costs = 5,817 Estim. IO-Costs = 1
    Program Data:
    Origin of ABAP coding
    Program Name       Line     Created By     Last Changed By   Last Changed On
    LBSVAF14           81     SAP     SAP             08.04.2007
    000080 * Einzelstatus von DB lesen in interne Tabelle
    000081 SELECT * FROM JEST CLIENT SPECIFIED
    000082 APPENDING TABLE JEST_TAB
    000083 WHERE MANDT = MANDT
    000084 AND OBJNR = OBJNR.

  • Sql statement  - compilation error

    I have a sql statement in a method that looks something like this:
    for each row in
    SELECT *
    FROM LASC.CMS.VW_CERTIFICATEOFGOODSTANDING1
    WHERE barNum = LASC.CertificationRequest.barNum
    do
    display ...
    end
    when I try to compile it, I get an error saying:
    SQL statements can only be used in functions or procedures that run on the server side.
    I am fairly new to BPM, so I am not sure how to resolve this.
    Any help would be greatly appreciated.
    Lilach

    here is the solution that Ignacio provided.
    You could go to Properties tab on the right (in Studio) for this method and inside the Method Properties section, you have on boolean property called "Server Side Method". Check it on "True".
    Hope this helps.
    Ignacio

  • Statement vs PreparedStatements which is better in which situation

    Hi i read in a few forums and a few articles that PreparedStatement object performs better than the Statement object in situations where a high number of the same sqls are used because it precompiles the sql statement. such as inserting a 1000 employees into a table.
    i did the following test and found that the gain for using PreparedStatements is sometimes not a gain but a loss.
    What the test basically does is that it inserts an item into the table a 2000 times using both PreparedStatements and Statement objects. And it switches between which object it uses to insert item into the table. So in the end 1000 items would have been inserted using PreparedStatements and 1000 using Statement objects.
    Am i doing somthing wrong with my test or is the so called gain by using PreparedStatements a fluke. Please advise.
    import java.sql.*;
    public class TEST {
        static int Prepcount = 1;
        static long PreptotalTime = 0;
        static long PrepstartTime = 0;
        static long PrependTime = 0;
        static long Prepavarage = 0;
        static int Stmtcount = 1;
        static long StmttotalTime = 0;
        static long StmtstartTime = 0;
        static long StmtendTime = 0;
        static long Stmtavarage = 0;
        static PreparedStatement pst;
        static Statement stmt;
        static ResultSet rs;
        static Connection conn;
        public static void usePrep() {
            try {
                pst = conn.prepareStatement("insert into Dhanu values (?,?)");
                PrepstartTime = System.currentTimeMillis();
                pst.setInt(1, Prepcount);
                pst.setInt(2, Prepcount);
                pst.executeQuery();
                PrependTime = System.currentTimeMillis();
                PreptotalTime = PreptotalTime + (PrependTime - PrepstartTime);
                Prepavarage = PreptotalTime / Prepcount;
                Prepcount++;
                pst.close();
            } catch (Exception e) {
                e.printStackTrace();
        public static void useStatement() {
            try {
                StmtstartTime = System.currentTimeMillis();
                stmt = conn.createStatement();
                rs = stmt.executeQuery("insert into Dhanu values ("+Stmtcount+","+Stmtcount+")");
                StmtendTime = System.currentTimeMillis();
                StmttotalTime = StmttotalTime + (StmtendTime - StmtstartTime);
                Stmtavarage = StmttotalTime / Stmtcount;
                Stmtcount++;
                rs.close();
                stmt.close();
            } catch (Exception e) {
                e.printStackTrace();
        public static void main(String[] args) {
            try {
                Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
                conn = DriverManager.getConnection("jdbc:oracle:thin:@XXX.XXX.XXX.XXX:1521:XXX", "XXX", "XXX");
                System.out.println("Connected to DB");
                conn.setAutoCommit(true);
                for(int x=1;x<=2000;x++){
                    if(x%100==0){
                       System.out.println("Count is "+x);
                    if(x%2==0){
                        usePrep();
                    }else
                        useStatement();
                System.out.println("Prepcount " + Prepcount + " Prepavarage " + Prepavarage + " CurrentExecution " +(PrependTime - PrepstartTime)+ " Totaltime "+PreptotalTime);
                System.out.println("Stmtcount " + Stmtcount + " Stmtavarage " + Stmtavarage+ " CurrentExecution " +(StmtendTime - StmtstartTime)+ " Totaltime "+StmttotalTime);
                System.err.println("Statement time - Prep Time " + (StmttotalTime - PreptotalTime ));
            } catch (Exception ex) {
                ex.printStackTrace();
                System.exit(0);
    }

    sjasja wrote:
    There can still be a performance advantage to PS's even when not used in a loop. Oracle in particular has a textual statement cache. When you execute
    insert into foo values(1);
    insert into foo values(2);
    insert into foo values(3);
    the three statements are textually different, so they get re-parsed and the query optimizer runs thrice. But when you prepare
    insert into foo values(?);
    the parsed and optimized statement remains in the statement cache for some time, and each execution with a different value for "?" can use the pre-parsed statement. The more complex the statement, the bigger the advantage.Yes they do, and so do many others. But it is only that, a cache. It will "usually" be available, not necessarily always. But, in any case, it is still best practice to prepare it, use it multiple times, and close it.
    >
    I have heard rumors of databases (MSSQL???) where a PS is indeed costlier, as the protocol between the JDBC driver and the DB server requires a separate compilation step. One could argue that in this world, where Java is so important in the server side, and the other advantages of PreparedStatement favor its use, any serious database has had much reason in the last decade to implement a protocol where a separate compilation step is not needed, and any other speed penalties for PSs are decidedly not a marketing advantage.One could argue that, and many have, but PreparedStatements did not spring into being with JDBC, they have existed previously. They are easier to use, however, in Java, and some sort or precompilation is required (even if it is only done the first time the statement is actually run) because at some point in time the DB must determine the paths to take when actually executing the statement, and that was the purpose behind precompiled statements in the first place, so that that determination is done once, and used multiple times. Otherwise it is done as the statement is executed, each time a statement is executed (unless, at least in Oracle, the same statement is still in the statement cache, then it is also reused, rather than redetermined).

  • Statement and PreparedStatement which is better?

    There are two method to getting data from the database which is:
    1. Statement stmt=con.createStatement();
    rs=stmt.executeQuery("select name from table where id='"+X+"' and yr='"+ year +"'");
    2. PreparedStatement ps = con.prepareStatement("select name from table where id=? and yr=?);
    ps.setString(1, X);
    ps.setString(2, year);
    rs = ps.executeQuery();
    Both method can get the same result. However can anyone tell me that which method 's performance is better or the same? Under the condition that both statement are NOT used in a loop.

    Well the prepared statement does have another advantage: you don't have to think about the format of a date literal. When you put together the SQL for a normal Statement you must somehow create a date literal. With Oracle for example you need to make sure you either use it with the to_date() function or set the session date format beforehand, or rely on the setting of the server (you see: many pitfalls). And no, java.sql.Date does not handle that correctly. The same goes for Timestamp and probably numeric values as well (decimal point vs. decimal comma)
    If you use a PreparedStatement the driver handles this problem for you. So if you want your app to be portable across different DBMS I would go for a PreparedStatement.
    Thomas

  • Apex 4.0 display image item :BLOB column returned by SQL statement

    Hello
    I'm creating an display image item in apex 4.0. The source is a BLOB column returned by SQL statement.
    When I'm issuing an sql statement like this:
       select lado.blob_content
       from   large_documents      lado
       ,        large_doc_headers    ladh
       where lado.ladh_nr = ladh.nr
       more criteriait works fine.
    When I create a function inside a package with the same query (in a cursor)
    function get_image(some parameters in) return blob
    Following in apex by:
    select get_image(some parameters) from dualI get a
    ORA-06502: PL/SQL: numeric or value error: character string buffer too smallAnybody any idea why this does not work?
    Regards Erik

    Hi Eric,
    the environment assumes varchar2-output by default, which will be limited to 32767 characters and may have problems with binary formats. You could define a blob-variable to select the value into.
    DECLARE
      l_blob BLOB;
    BEGIN
      SELECT get_image(some parameters)
        INTO l_blob
        FROM dual;
    END;
    /If you expect the BLOB-Content to be text (you should consider CLOB then), you may use UTL_RAW.CAST_TO_VARCHAR2 to convert the content. If your object is larger than the maximum varchar2 size, or you want to convert BLOB to CLOB, you might be interested in some converter like described here: {message:id=559749}
    Hope this is what you were searching for.
    -Udo

  • Which is better for performance Azure SQL Database or SQL Server in Azure VM?

    Hi,
    We are building an ASP.NET app that will be running on Microsoft Cloud which I think is the new name for Windows Azure. We're expecting this app to have many simultaneous users and want to make sure that we provide excellent performance to end users.
    Here are our main concerns/desires:
    Performance is paramount. Fast response times are very very important
    We want to have as little to do with platform maintenance as possible e.g. managing OS or SQL Server updates, etc.
    We are trying to use "out-of-the-box" standard features.
    With that said, which option would give us the best possible database performance: a SQL Server instance running in a VM on Azure or SQL Server Database as a fully managed service?
    Thanks, Sam

    hello,
    SQL Database using shared resources on the Microsft data centre. Microsoft balance the resource usage of SQL Database so that no one application continuously dominates any resource.You can try the 
    Premium Preview
    for Windows Azure SQL Database which offers better performance by guaranteeing a fixed amount of dedicated resources for a database.
    If you using SQL Server instance running in a VM, you control the operating system and database configuration. And the
    performance of the database depends on many factors such as the size of a virtual machine, and the configuration of the data disks.
    Reference:
    Choosing between SQL Server in Windows Azure VM & Windows Azure SQL Database
    Regards,
    Fanny Liu
    If you have any feedback on our support, please click here. 
    Fanny Liu
    TechNet Community Support

Maybe you are looking for

  • SAP Query in MSS - Not Data

    Hi Sap Experts, we added a custom query as described step by step in MSS Business Package (HCM Reports). <a href="http://help.sap.com/saphelp_erp2005/helpdata/en/3a/3198408d953154e10000000a1550b0/frameset.htm">http://help.sap.com/saphelp_erp2005/help

  • Keynote will not load!

    I just purchased Keynote for my iPad(16gb, WiFi+3G). It made me connect to a WiFi network to download it, because the ApSize was to large to download over the 3G network. I let the program download, and the Keynote Icon appeared on my homescreen. Now

  • Address Format

    Hi Experts, We are facing an issue in adress format of the customer.While taking the print of the document country name is coming as IN inspite of India. I already put the description check box at addres format window but the situation is remain same

  • Hide customised alv button

    hi, how should i go about hiding the customised alv button i created? thanks.

  • Import keynote presentation into iWeb?

    I was thinking about adding a keynote presentation onto my web page as a slide show. Is this possible? Thanks!