PL/SQL region query issue

Dears;
I'm in trouble for a moment with my PL/sql block in a region.
Could you take a look on the following block and tell me what i do wrong?
DECLARE
v_counter INTEGER := 0;
v_line VARCHAR2 (4000);
v_rec_in_row INTEGER := 12;
lpar varchar2(50;
BEGIN
HTP.prn ('&lt table &gt ');
HTP.prn ('&lt tr &gt ');
HTP.prn ('&lt td &gt ');
lpar:=v('P48_LVAR')
CASE lpar
WHEN 'SERVERS'
THEN
               FOR c IN
                    ( SELECT CASE
WHEN SERVER_MARK='SUN'
THEN '&lt table &gt '
|| '&lt tr &gt &lt td &gt &lt a href="#WORKSPACE_IMAGES#New Image.GIF" &gt &lt img src="#WORKSPACE_IMAGES#New Image.GIF"/ &gt &lt /td &gt &lt /tr &gt '
|| '&lt tr &gt &lt td style="text-align:center" &gt &lt h1 &gt '
|| SERVER_NAME
|| '&lt / &gt &lt /td &gt &lt /tr &gt &lt /a &gt &lt /table &gt '
WHEN SERVER_MARK='HP'
THEN '&lt table &gt '
|| '&lt tr &gt &lt td &gt &lt a href="#WORKSPACE_IMAGES#New Image.GIF" &gt &lt img src="#WORKSPACE_IMAGES#hp.GIF"/ &gt &lt /td &gt &lt /tr &gt '
|| '&lt tr &gt &lt td style="text-align:center" &gt &lt h1 &gt '
|| SERVER_NAME
|| '&lt / &gt &lt /td &gt &lt /tr &gt &lt /a &gt &lt /table &gt '
                                   END emp
                         FROM SERVERS)
                         LOOP
                         v_line := v_line || c.emp || '&lt /td &gt &lt td &gt ';
                         v_counter := v_counter + 1;
                         IF v_counter = v_rec_in_row
                         THEN
                              HTP.prn (v_line);
                              HTP.prn ('&lt /td &gt &lt /tr &gt &lt tr &gt &lt td &gt ');
                              v_line := NULL;
                              v_counter := 0;
                         END IF;
                    END LOOP;
                    HTP.prn (v_line);
                    HTP.prn ('&lt /td &gt &lt /tr &gt &lt /table &gt ');
WHEN 'ZONES'
          THEN
               FOR c IN
                    ( SELECT '&lt table &gt '
|| '&lt tr &gt &lt td &gt &lt a href="#WORKSPACE_IMAGES#New Image.GIF" &gt &lt img src="#WORKSPACE_IMAGES#New Image.GIF"/ &gt &lt /td &gt &lt /tr &gt '
|| '&lt tr &gt &lt td style="text-align:center" &gt &lt h1 &gt '
|| ZONE_NAME
|| '&lt / &gt &lt /td &gt &lt /tr &gt &lt /a &gt &lt /table &gt '
END emp
                    FROM ZONES)
                    LOOP
                         v_line := v_line || c.emp || '&lt /td &gt &lt td &gt ';
                         v_counter := v_counter + 1;
                         IF v_counter = v_rec_in_row
                         THEN
                              HTP.prn (v_line);
                              HTP.prn ('&lt /td &gt &lt /tr &gt &lt tr &gt &lt td &gt ');
                              v_line := NULL;
                              v_counter := 0;
                         END IF;
                    END LOOP;
                    HTP.prn (v_line);
                    HTP.prn ('&lt /td &gt &lt /tr &gt &lt /table &gt ');
WHEN 'ALIAS'
          THEN
               FOR c IN
                    ( SELECT           
          '&lt table &gt '
|| '&lt tr &gt &lt td &gt &lt a href="#WORKSPACE_IMAGES#New Image.GIF" &gt &lt img src="#WORKSPACE_IMAGES#New Image.GIF"/ &gt &lt /td &gt &lt /tr &gt '
|| '&lt tr &gt &lt td style="text-align:center" &gt &lt h1 &gt '
|| ALIAS_NAME
|| '&lt / &gt &lt /td &gt &lt /tr &gt &lt /a &gt &lt /table &gt '
                              END emp
                              FROM ALIAS)
                              LOOP
                              v_line := v_line || c.emp || '&lt /td &gt &lt td &gt ';
                              v_counter := v_counter + 1;
                              IF v_counter = v_rec_in_row
                              THEN
                                   HTP.prn (v_line);
                                   HTP.prn ('&lt /td &gt &lt /tr &gt &lt tr &gt &lt td &gt ');
                                   v_line := NULL;
                                   v_counter := 0;
                              END IF;
                         END LOOP;
                         HTP.prn (v_line);
                         HTP.prn ('&lt /td &gt &lt /tr &gt &lt /table &gt ');
          WHEN 'FS'
          THEN
               FOR c IN
                    ( SELECT
                    '&lt table &gt '
|| '&lt tr &gt &lt td &gt &lt a href="#WORKSPACE_IMAGES#New Image.GIF" &gt &lt img src="#WORKSPACE_IMAGES#New Image.GIF"/ &gt &lt /td &gt &lt /tr &gt '
|| '&lt tr &gt &lt td style="text-align:center" &gt &lt h1 &gt '
|| FS_NAME
|| '&lt / &gt &lt /td &gt &lt /tr &gt &lt /a &gt &lt /table &gt '
END emp
FROM FS
LOOP
v_line := v_line || c.emp || '&lt /td &gt &lt td &gt ';
v_counter := v_counter + 1;
IF v_counter = v_rec_in_row
THEN
HTP.prn (v_line);
HTP.prn ('&lt /td &gt &lt /tr &gt &lt tr &gt &lt td &gt ');
v_line := NULL;
v_counter := 0;
END IF;
END LOOP;
HTP.prn (v_line);
HTP.prn ('&lt /td &gt &lt /tr &gt &lt /table &gt ');
END CASE;
END;
I get this error :
1 error has occurred
ORA-06550: line 56, column 21: PL/SQL: ORA-00923: FROM keyword not found where expected ORA-06550: line 51, column 7: PL/SQL: SQL Statement ignored ORA-06550: line 83, column 13: PL/SQL: ORA-00923: FROM keyword not found where expected ORA-06550: line 77, column 7: PL/SQL: SQL Statement ignored ORA-06550: line 110, column 12: PL/SQL: ORA-00923: FROM keyword not found where expected ORA-06550: line 104, column 7: PL/SQL: SQL Statement ignored
I know it's a long post but i hope u will take the time to look.
Thx.
Celio

Okay, when using CASE you have to flavours.
One for PL/SQL statements and one in a query.
In PL/SQL the structure is like this:
case n
  when 1 then Action1;
  when 2 then Action2;
  when 3 then Action3;
  else        ActionOther;
end case;In a query it's like this:
SELECT CASE WHEN (<column_value>= <value>) THEN
            WHEN (<column_value> = <value>) THEN
            ELSE <value>
            END AS <alias>
FROM <table_name>;So rewriting your code, this should work:
DECLARE
   v_counter     INTEGER         := 0;
   v_line        VARCHAR2 (4000);
   v_rec_in_row  INTEGER         := 12;
   lpar varchar2(50);
BEGIN
   HTP.prn ('<table>');
   HTP.prn ('<tr>');
   HTP.prn ('<td>');
   lpar:=v('P48_LVAR');
   CASE
    WHEN lpar='SERVERS'
                THEN 
                  FOR c IN
                      ( SELECT   CASE
                WHEN SERVER_MARK='SUN'
                THEN     '<table>'
                         || '<tr><td><a href="#WORKSPACE_IMAGES#New Image.GIF"><img src="#WORKSPACE_IMAGES#New Image.GIF"/></td></tr>'
                         || '<tr><td style="text-align:center"><h1>'
                         || SERVER_NAME
                         || '</td></tr></a></table>'
                WHEN SERVER_MARK='HP'
                THEN     '<table>'
                         || '<tr><td><a href="#WORKSPACE_IMAGES#New Image.GIF"><img src="#WORKSPACE_IMAGES#hp.GIF"/></td></tr>'
                         || '<tr><td style="text-align:center"><h1>'
                         || SERVER_NAME
                         || '</td></tr></a></table>'
                                   END AS emp
                          FROM SERVERS)
                          LOOP
                           v_line := v_line || c.emp || '</td><td>';
                           v_counter := v_counter + 1;
                           IF v_counter = v_rec_in_row
                           THEN
                               HTP.prn (v_line);
                               HTP.prn ('</td></tr><tr><td>');
                               v_line := NULL;
                               v_counter := 0;
                           END IF;
                       END LOOP;
                       HTP.prn (v_line);
                       HTP.prn ('</td></tr></table>');
   WHEN lpar='ZONES'
            THEN 
                  FOR c IN
                      ( SELECT '<table>'
                         || '<tr><td><a href="#WORKSPACE_IMAGES#New Image.GIF"><img src="#WORKSPACE_IMAGES#New Image.GIF"/></td></tr>'
                         || '<tr><td style="text-align:center"><h1>'
                         || ZONE_NAME
                         || '</td></tr></a></table>'
                 emp
                    FROM ZONES)
                    LOOP
                           v_line := v_line || c.emp || '</td><td>';
                           v_counter := v_counter + 1;
                           IF v_counter = v_rec_in_row
                           THEN
                               HTP.prn (v_line);
                               HTP.prn ('</td></tr><tr><td>');
                               v_line := NULL;
                               v_counter := 0;
                           END IF;
                       END LOOP;
                       HTP.prn (v_line);
                       HTP.prn ('</td></tr></table>');
   WHEN lpar='ALIAS'
            THEN 
                  FOR c IN
                      ( SELECT           
                           '<table>'
                         || '<tr><td><a href="#WORKSPACE_IMAGES#New Image.GIF"><img src="#WORKSPACE_IMAGES#New Image.GIF"/></td></tr>'
                         || '<tr><td style="text-align:center"><h1>'
                         || ALIAS_NAME
                         || '</td></tr></a></table>'
                                  emp
                              FROM ALIAS)
                              LOOP
                                v_line := v_line || c.emp || '</td><td>';
                                v_counter := v_counter + 1;
                                IF v_counter = v_rec_in_row
                                THEN
                                    HTP.prn (v_line);
                                    HTP.prn ('</td></tr><tr><td>');
                                    v_line := NULL;
                                    v_counter := 0;
                                END IF;
                            END LOOP;
                            HTP.prn (v_line);
                            HTP.prn ('</td></tr></table>');
           WHEN lpar='FS'
            THEN 
                  FOR c IN
                      ( SELECT
                              '<table>'
                         || '<tr><td><a href="#WORKSPACE_IMAGES#New Image.GIF"><img src="#WORKSPACE_IMAGES#New Image.GIF"/></td></tr>'
                         || '<tr><td style="text-align:center"><h1>'
                         || FS_NAME
                         || '</td></tr></a></table>'           
         emp
      FROM FS
   LOOP
      v_line := v_line || c.emp || '</td><td>';
      v_counter := v_counter + 1;
      IF v_counter = v_rec_in_row
      THEN
         HTP.prn (v_line);
         HTP.prn ('</td></tr><tr><td>');
         v_line := NULL;
         v_counter := 0;
      END IF;
   END LOOP;
   HTP.prn (v_line);
   HTP.prn ('</td></tr></table>');
END CASE;
END;Unless I'm missing something aswell ;-)
Edited by: Michel van Zoest on Oct 6, 2009 10:46 PM

Similar Messages

  • UCCX 5 SQL Dbase Query Issues - Slow Returns

    For several months it seemed to me that our UCCX 5 system was beginning to have trouble. At first it appeared as a problem with our wallboard system being unable to display the real-time data properly. I had deduced that queries to the db_cra database were taking 4 - 5 minutes to return data.
    At first I called on the vendor for our wallboard, but they were unable to help stating that it was a UCCX database issue - and I agreed. I then went to Cisco TAC and fed them all my information and asked them for help. They also were unable to help figure out what was happening, but they could see that the SQL queries that used to take 2 seconds were now taking several minutes. Since the wallboard system queried the database every 10 seconds, it was over-taxing the database.
    This began to cause little anomalies in things like call-distribution, dropped calls, slow to no Historical reports returns, and this ultimately began to cause failovers to our backup node. I could not go a day without a failover and I had to reboot the servers almost every night.
    I felt there was no solution and was afraid we needed to replace our system.
    After talking to all the engineers around the world, my solution came from our very own SQL administrator. Within 5 minutes he was able to resolve all our issues.
    The root of our problem was that the indexing of the db_cra database was extremely fragmented.
    He wrote a SQL sript that he had me run against the database and he told me that this would correct any indexing issues.
    It worked like a charm.
    The system stopped behaving poorly immediately. This resolved many of our problems that I had been living with for a long time. It made the Admin page work so much faster, call distribution issues halted, the wallboard is running faster than ever with real-time data, and the list goes on. This resolved so many smaller issues that I cannot even list them all.
    I would advise anyone using a SQL database, whether it be a Cisco product or not, to always keep their database 'defragmented'.
    My SQL admin also setup the script to run automatically, on a schedule to keep our database running like a Ferrari. It has been sweet ever since.
    KEEP YOUR INDEXES CLEAN AND YOU WILL REAP HAPPINESS!

    I was equally shocked that there was no escalation, as was my boss and my Cisco rep. They let me go with no resolution and hung-up the phone leaving me with instructions to have some-one else take a look at the database. It was very unexpected, especially considering how close they were to the point when we were trouble-shooting.
    The TAC SR # 611904619 - IPCC Database Not Returning Query Data.
    With this resolution, it also raised to my mind the issue of Informix. We are using CUCM 6.1.2 and are concerned about the same issue happening there and we would like to determine if this can happen there also, and if there is a re-indexing tool available for Informix.

  • PL/SQL region. query get rounded up when displayed using htp.p procedure.

    Hi,
    I tried to apply the above code, but the coordinates don't seem to come out right.
    When I test the following query:
    select c.employee_id
    ,t.X
         , t.Y
    from employees c, TABLE(SDO_UTIL.GETVERTICES(c.geom)) t;
    It works fine. Don't let the spatial component discourage you. The output are just two coordinates, just like normal sql. I tested the output in a Report page.
    When I display the columns via an alert, instead of ( 43.907787,-79.359741) I get (43,-79).
    for row in employees loop
    htp.p('
    alert('||to_char(row.y)||');
    alert('||row.x||');
    Any idea how to get around this?
    ThanX,
    Pim

    Hi,
    I tried to apply the above code, but the coordinates don't seem to come out right.
    When I test the following query:
    select c.employee_id
    ,t.X
         , t.Y
    from employees c, TABLE(SDO_UTIL.GETVERTICES(c.geom)) t;
    It works fine. Don't let the spatial component discourage you. The output are just two coordinates, just like normal sql. I tested the output in a Report page.
    When I display the columns via an alert, instead of ( 43.907787,-79.359741) I get (43,-79).
    for row in employees loop
    htp.p('
    alert('||to_char(row.y)||');
    alert('||row.x||');
    Any idea how to get around this?
    ThanX,
    Pim

  • SQL Group Query issue

    Dear All,
    I have a result set like this
    A
    UK
    A
    USA
    A
    Canada
    B
    Canada
    B
    UK
    I need a query that can give me results like this
    A
    UK
    USA
    B
    Canada
    UK
    Any help would be greatly appreciated
    cheers,
    Sammy

    Thanks for your reply.  But I want the results to be like this
     A
    UK
    USA
    Canada
    B
    Australia
    Germany
    Like all the resuts of A should be combined into one row. and same is with B right now when I run the query It looks like this:
    A
     UK
    null
    USA
    null
    Canada
    B
    Australia
    null
    Germany
    Thank you for your help in advance

  • How to connect to SQL*Plus and issue a query all in one command?

    Hi everyone,
    Does anyone know of a way to connect to a db with SQL*Plus, and issue a simple query, all with one command?
    I know that I can save a .sql script with a query, then do this:
    sqlplus user/pwd@db @myscript.sql
    But I'm wondering if there's any way to put the actual query right into the connect command, something like:
    sqlplus user/pwd@db "select count(*) from dba_tables;"
    Does anyone know of a way to do this?

    you didn't mention windows or unix. so, here's a link with both
    Re: windows sql script
    it also has a link to another thread on how to deal with the parens when using ehco in dos.

  • SQL Report query ORA-06502: PL/SQL: numeric or value error: character strin

    Hello,
    I have saved below query in the sql scripts, which executes good under SQL Developer,
    select     "RVV"."RLNUM" as "RLNUM",
         "GVREB"."RLNUM" as "RLNUM",
         "TVV"."RLNUM" as "RLNUM_1",
         "Regulation"."CODE" as "CODE",
         "Regulation"."NAAM" as "NAAM",
         "GVREB"."BRONCODE" as "BRONCODE",
         sum(RVV.RVV_MODULATIE) as "RVV_MODULATIE",
         sum(RVV.RVV_EXTRA_MODUL) as "RVV_EXTRA_MODUL",
         sum(GVREB.PMB) as "PMB",
         sum(GVREB.VVM) as "VVM",
         sum(GVREB.VVEM) as "VVEM",
         "GVREB"."STATUS" as "STATUS",
         sum(TVV.VVM) as "VVM",
         sum(TVV.VVEM) as "VVEM",
         "Regulation"."version" as "version",
         "TVV"."Appyear" as "Appyear"
    from     "GVREB" "GVREB",
         "RVV" "RVV",
         "TVV" "TVV",
         "Regulation" "Regulation"
    where      "RVV"."RLNUM" = :P17_Relationnum
    and     "GVREB"."RLNUM" = "RVV"."RLNUM"
    and     "TVV"."RLNUM" = "GVREB"."RLNUM"
    and     "GVREB"."CODE" = "TVV"."RegulationSCODE"
    and     "Regulation"."CODE" = "GVREB"."CODE"
    and     "GVREB"."STATUS" = 'VWT'
    and     "TVV"."Appyear" = 2009
    group by RVV.RLNUM, GVREB.RLNUM, TVV.RLNUM, Regulation.CODE, Regulation.NAAM, GVREB.BRONCODE, GVREB.STATUS, Regulation.version, TVV.Appyear
    order by Regulation.version ASC
    however when tried to put in the region -> query builder it gives below error,
    italics ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    Return to application.+italics+
    Kindly suggest me work around this error.
    Cheers,
    G1R15|-|
    Edited by: G on Jul 11, 2010 10:03 PM

    Hi,
    I was able to resolve the issue. I changed it to = To_Number while assigning.
    and for other issue, earlier I choose "Select List" for drop down. I changed this to "Select list with Submit". for the issue of "depending on this values in the report should get change"
    Thanks for your support,
    Girish

  • Report Using PL/SQL Region

    Hi,
    I have bit experiment create custom reports using PL/SQL region
    http://dbswh.webhop.net/apex/f?p=BLOG:READ:0::::ARTICLE:97800346956448
    I would like have from you tips and ideas how enhance this.
    Because I'm not so good with SQL,
    I really appreciate if you have tips enhance performance for query used for cursor.
        /* Report query */
        l_sql := '
          SELECT * FROM(
            SELECT a.*, row_number() OVER (ORDER BY '
            || l_sort_col
            || ' '
            || l_sort_ord
            || ') rn, COUNT(1) over() mrn
            FROM(' || l_sql || ') a
          ) WHERE rn BETWEEN ' || l_start_row || ' AND ' || l_last_row
        ; Regards,
    Jari

    Hi Jari
    I'm guessing you're trying to do paginated grid data or somewthing similar? You could try something like this...
        l_sql := 'SELECT * '||
               'FROM ('||
                      'SELECT /*+ FIRST_ROWS(n) */ '||
                              'a.*, ROWNUM rnum '||
                       'FROM ('||l_sql||' '||
                              'ORDER BY '||l_sort||' '||l_dir||') a '||
                       'WHERE ROWNUM <= '||l_max_row||') '||
               'WHERE rnum >= '||l_start;The variables would be initialized in the procedure as follows...
        l_max_row := p_start + p_limit;
        l_start   := p_start + 1;
        l_sort    := NVL(p_sort,'1');
        l_dir     := NVL(p_dir, 'ASC');My application process would be called something like follows, to spit out a JSON object...
    BEGIN
      htp.p(wwv_flow.g_widget_num_return||'(');
      munky_extjs.grid_json(p_app_id => wwv_flow.g_x01,
                        p_app_page_id => wwv_flow.g_x02,
                        p_region_id => TO_NUMBER(wwv_flow.g_x03),
                        p_start => NVL(wwv_flow.g_x04,0),
                        p_limit => NVL(wwv_flow.g_x05,10),
                        p_sort => wwv_flow.g_x06,
                        p_dir => wwv_flow.g_x07);
      htp.p(')');
    END;I think your use of analytics in the inner query may be slowing you down if you have a lot of data?
    Cheers
    Ben

  • Pagination with pl/sql region.

    Hi all,
    I have created one more sample page with pl/sql region
    workspace: srijaks
    login:[email protected]
    password:srijakutty
    Application: 49471 - Sample Field Display
    page 16
    Initially it will display the first two records of the concerned department.
    but then by clicking the next and previous buttons it has to display the next two records and the previous 2 records respectively.
    Please, if some one can help me !!!?
    Thanks in advance
    bye
    Srikavi

    Hi Srikavi,
    OK - I've updated your page to get the next/previous buttons working. I have removed the bit in the PL/SQL code that assigned a value to the next button as this was causing me problems. I have also updated the select statement in this to include: and empno >= v('P16_EMPNO').
    The next/previous buttons are based on:
    Previous:
    WITH EMPS AS (SELECT EMPNO, DENSE_RANK () OVER (ORDER BY EMPNO DESC) EMPNUMBER FROM EMP WHERE DEPTNO = :P16_SELECT_DEPT AND EMPNO &lt; :P16_EMPNO ORDER BY EMPNO DESC)
    SELECT NVL(MAX(EMPNO),0)
    FROM EMPS
    WHERE EMPNUMBER = 2Next:
    WITH EMPS AS (SELECT EMPNO, DENSE_RANK () OVER (ORDER BY EMPNO) EMPNUMBER FROM EMP WHERE DEPTNO = :P16_SELECT_DEPT AND EMPNO &gt; :P16_EMPNO ORDER BY EMPNO)
    SELECT NVL(MIN(EMPNO),0)
    FROM EMPS
    WHERE EMPNUMBER = 2These are calculated Before Header and are unconditional
    I have also added an Employees item that is set as:
    {code
    SELECT COUNT(*)
    FROM EMP
    WHERE DEPTNO = :P16_SELECT_DEPT
    This is only calculated when the item is null - which will be the case when a new dept is selected - so this only happens once per selection.  This returns a correct record count - updating the select statement in the report as above, caused problems with the existing count.  Not sure if you want to change these back?
    As you can see, I've assigned a ranking to each item - this could have been achieved using a row number as well.  There are several ways this could have been handled.  The next/previous buttons could be based on the ranking/rownumber value and the EMPNO retrieved based on this.  The EMPNOs could be queried into a collection and you could use the sequence numbers to move through the records.  The above is just one example - you might like to try the others to see which one you prefer.
    Andy                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Using SQL in Query in 3.0.0

    I'm very happy to see this feature added to 3.0.0 along with methodQL. This
    should alleviate a lot of the issues with trying to use only JDOQL,
    especially when the desired SQL statemetn is well understood. Thanks for
    adding this!
    Ben

    Marc,
    Calling pm.flush() explicitly doesn't help. Calling
    query.setIgnoreCache(true) does work, so that's good.
    I even get the correct number of rows back in the Collection. Unfortunately
    every item in the Collection is null. I definitely did a
    query.setClass(DSChannelValueImpl.class) and it is enhanced properly,
    because that's how the table got populated earlier in the test. I am doing a
    SELECT *, so the class indicator and pk should be there. I'm assuming it
    doesn't mind me aliasing the FROM table name, since I need to disambiguate
    it to do a join (below).
    Ben
    "Marc Prud'hommeaux" <[email protected]> wrote in message
    news:[email protected]...
    Ben-
    I've made a bug report for this:
    http://bugzilla.solarmetric.com/show_bug.cgi?id=780
    In the meantime, a nicer workaround will probably be to just call
    setIgnoreCache(true) on the Query.
    In article <[email protected]>, Marc Prud'hommeaux wrote:
    Ben-
    A potential (but, admittedly, not very nice) workaround for this for the
    time being might be to enable NonTransactionalRead=true, and ensure that
    there is not a transaction running at the time of query execution.
    In article <[email protected]>, Patrick Linskey wrote:
    Well, sounds like a bug. We'll take a look. Sorry about that.
    What happens if you explicitly flush the PM before execution?
    -Patrick
    Ben Eng wrote:
    Query query = pm.newQuery( "kodo.jdbc.SQL", null );
    query.setClass( ChannelValue.class );
    query.declareParameters( "VARCHAR pConn, DATETIME pStart,
    DATETIME pEnd" );
    String filter = "select * from dschannel as c" +
    " left join channelsegment as s" +
    " on c.pk = s.channel and" +
    " c.supporting = pConn and" +
    " (s.validForEnd > pStart or" +
    " s.validForStart < pEnd)" +
    " where s.channel is null";
    query.setFilter( filter );
    Collection resultSet = (Collection) this.query.execute(
    connection, start, end );
    This is being called from a method of a stateless session bean that is
    only
    performing this query. CMT, Required, and the client is not definingits own
    transaction boundaries. Therefore, I would not expect anything to bedirtied
    in this transaction. This is with the BEA WLS 7.0 appserver.
    Ben
    "Patrick Linskey" <[email protected]> wrote in message
    news:[email protected]...
    Ben,
    Can you post the code that you're using to create the query?
    -Patrick
    Ben Eng wrote:
    I just ran into a snag with this feature.
    kodo.util.UnsupportedOptionException: kodo.jdbc.SQL language queries
    cannot
    be executed in-memory. Either set the javax.jdo.option.IgnoreCacheproperty
    to true, set the kodo.FlushBeforeQueries property to true, or executethe
    query before modifying objects within the transaction.
    at
    kodo.jdbc.query.SQLQuery.newInMemoryQueryExecutor(SQLQuery.java:117)
    at kodo.query.AbstractQuery.internalCompile(AbstractQuery.java:545)
    atkodo.query.AbstractQuery.getAccessPathMetaDatas(AbstractQuery.java:938)
    >>>>
    atkodo.query.AbstractQuery.isAccessPathDirty(AbstractQuery.java:745)
    at kodo.query.AbstractQuery.executeWithMap(AbstractQuery.java:672)
    at kodo.query.AbstractQuery.executeWithArray(AbstractQuery.java:640)
    at kodo.query.AbstractQuery.execute(AbstractQuery.java:622)
    at
    com.metasolv.resources.queries.ChannelAvailabilityQueryBean.execute(ChannelA
    >>>>
    vailabilityQueryBean.java:84)
    at
    com.metasolv.oss.inventory.InventorySessionBean.queryInventory(InventorySess
    >>>>
    ionBean.java:1504)
    Oddly, my ra.xml already has the following properties set.
    <config-property>
    <description>If false, then the JDO implementation mustconsider
    modifications, deletions, and additions in the PersistenceManager
    transaction cache when executing a query inside a transaction. Else,the
    implementation is free to ignore the cache and execute the querydirectly
    against the data store.</description>
    <config-property-name>IgnoreCache</config-property-name>
    <config-property-type>java.lang.Boolean</config-property-type>
    <config-property-value>true</config-property-value>
    </config-property>
    <config-property>
    <description>Whether or not Kodo should automatically flush
    modifications to the data store before executingqueries.</description>
    >>>>>>
    <config-property-name>FlushBeforeQueries</config-property-name>
    <config-property-type>java.lang.String</config-property-type>
    <config-property-value>true</config-property-value>
    </config-property>
    I also tried explicitly calling ((KodoPersistenceManager)pm).flush()before
    newQuery to no avail. I am at a loss how to get the Query to NOT
    execute
    in-memory.
    Ben
    "Ben Eng" <[email protected]> wrote in message
    news:[email protected]...
    I'm very happy to see this feature added to 3.0.0 along with
    methodQL.
    >>>>>>
    This
    should alleviate a lot of the issues with trying to use only JDOQL,
    especially when the desired SQL statemetn is well understood. Thanks
    for
    adding this!--
    Marc Prud'hommeaux [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • Render Dynamic PL/SQL region as PDF?

    Hi!
    I would like to be able to render a Dynamic PL/SQL region as a PDF. Anybody have an idea how to do this or even if it can be done? This is not a report region.
    Also any idea's on how I might do pagination in a dynamic PL/SQL region?
    Any hope that a future version of APEX will accept lines from a PL/SQL function (including anonymous ones) as the source of a report region? It would need to preserve blank lines. Currently only select statements are valid for generating APEX reports.
    Thanks in advance for your help!
    Dave Venus

    Scott,
    This is what is what debug mode puts out just before it issues the data not found error:
    0.07: ...Process "create collection": PLSQL (ON_SUBMIT_BEFORE_COMPUTATION) -- -- Create Collections -- -- declare la_cks apex_application_global.vc_arr2; begin if apex_application.g_f19.count > 0 then -- wwv_flow.debug('count gt 0 for checksum'); la_cks := apex_application.g_f19; else
    0.09: Encountered unhandled exception in process type PLSQL
    0.09: Show ERROR page...
    0.09: Performing rollback...
    I was hoping that the wwv_flow.debug statements would help me figure out where the error was occurring, but they did not produce anything so I commented them out. One thing that might be useful is that when I am not in debug mode and I click the OK link after the Oracle error message, the repainted screen still has the checkboxes that have been marked so I am guessing the error handler can see the data that I put into the .g_fnn arrays within my pl/sql region code.
    In other tabular forms within the same application, the create collection code starts the same way and I do not have any problems.
    One of the tests I did this morning was to replace my reference to the fcs array with f19 just in case there was something special being done for checksums, but the change had no effect.
    thanks,
    Peter

  • Official documents on escaping characters in SQL Server query statements

    Hi,
    Are there any official documents on how to escaping special characters in SQL Server query statements? I find a lot of online resources discussing about this, but there are no definitive conclusions on:
    Which characters should be escaped? (Some only said single-quote needs to be escaped, double-quote does not need. While others said both need to be escaped)
    How to escape characters? (Some said using two single-quote to escape a single-quote. Others said using a backslash, etc.)
    So I just wonder if there is an official document from Microsoft regarding this?
    Thanks
    Alan

    Depends on where you're using them
    If its string values then single quotes(') should be escaped by putting one more single quote before it.
    If its LIKE operator you can use ESCAPE keyword or use [] to escapre special characters 
    see
    http://visakhm.blogspot.in/2013/01/wildcard-character-based-pattern-search.html
    If inside SSIS expression you can escape characters like \ " etc by adding an extra \ before the characters
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Required info on SQL Server Performance Issue Analysis and Troubleshoot way

    Dear All,
    I am going to prepare the simple documentation steps on SQL Server Performance Issue Analysis and troubleshoot method. I am struggling to make this documentation since we have different checklist (like network latency,disk latency, memory/processor pressure,SQL
    query tuning etc) to validate once application performance issue reported from the customer.So, I am looking for the experts document or link sharing .
    Your input will help for document preparation in better way.
    Thanks in advance.

    Hi,
    Recommendations and Guidelines on configuring disk partitions for SQL Server
    http://support.microsoft.com/kb/2023571
    Disk and File Layout for SQL Server
    https://blogs.technet.com/b/dataplatforminsider/archive/2012/12/19/disk-and-file-layout-for-sql-server.aspx
    Microsoft SQL Server 2012 Performance Tuning: Implementing Physical Database Structure
    http://www.packtpub.com/article/sql-server-2012-implementing-physical-database-strusture
    Database Mirroring Best Practices and Performance Considerations
    http://technet.microsoft.com/en-us/library/cc917681.aspx
    Hope the information helps.
    Tracy Cai
    TechNet Community Support

  • SQL Azure - query with row_number() executes slow if columns with nvarchar of big size are included

    I am linking my question from Stack Overflow here. The link: http://stackoverflow.com/questions/27943913/sql-azure-query-with-row-number-executes-slow-if-columns-with-nvarchar-of-bi
    Appreciate your help!
    Gorgi

    Hi,
    Thanks for posting here.
    I suggest you to check this link and optimize your query on sql azure.
    http://www.sqlusa.com/articles/query-optimization/
    http://sqlblog.com/blogs/paul_white/archive/2011/02/23/Advanced-TSQL-Tuning-Why-Internals-Knowledge-Matters.aspx
    Also check this blog which had similar issue.
    https://social.msdn.microsoft.com/Forums/en-US/c1da08b4-265d-4ec8-a252-8d7090234e3e/simple-select-query-takes-long-time-to-execute-with-nvarchar-columns?forum=transactsql
    Girish Prajwal

  • SQL Server Connection Issue

    I've tried going through the steps to resolve the issue, but I am still coming up blank. The part that I am not understanding is the, "A non-recoverable error occurred during a database lookup." part.
    Is this a security problem? I can establish an ODBC connection to the server as well as connect and query through visual studio, however when trying to run it through one of our custom programs, it throws this error message. 
    A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider:
    TCP Provider, error: 0 - A non-recoverable error occurred during a database lookup.)

    There are many reasons of SQL server connectivity issue. Refer checklist to find out the real cause of connectivity issue.
    1. Check SQL services are running
    2. Check SQL Browser service is running
    3. Check remote connections are enabled
    4. Network connectivity between database & application servers by TRACERT command
    5. Check TCP/IP protocol enabled at SQL server
    6. Check talent connectivity – telnet <IP address> <port no on SQL server running>
    7. Check UDP port 1434 is open or not on SQL Server
    8. Check firewall is running or not Check
    9. If firewall running, SQL Server & UDP port must be added in exception in firewall
    10. Run SQL Discovery report on machine SQL server installed, to check you are using correct instance name to connect( default \named) -http://mssqlfun.com/2013/02/26/sql-server-discovery-report/
    http://mssqlfun.com/2012/09/28/check-list-for-sql-server-connectivity-issue/
    Regards,
    Rohit Garg
    (My Blog)
    This posting is provided with no warranties and confers no rights.
    Please remember to click Mark as Answer and Vote as Helpful on posts that help you. This can be beneficial to other community members reading the thread.

  • Oracle SQL Select query takes long time than expected.

    Hi,
    I am facing a problem in SQL select query statement. There is a long time taken in select query from the Database.
    The query is as follows.
    select /*+rule */ f1.id,f1.fdn,p1.attr_name,p1.attr_value from fdnmappingtable f1,parametertable p1 where p1.id = f1.id and ((f1.object_type ='ne_sub_type.780' )) and ( (f1.id in(select id from fdnmappingtable where fdn like '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#%')))order by f1.id asc
    This query is taking more than 4 seconds to get the results in a system where the DB is running for more than 1 month.
    The same query is taking very few milliseconds (50-100ms) in a system where the DB is freshly installed and the data in the tables are same in both the systems.
    Kindly advice what is going wrong??
    Regards,
    Purushotham

    SQL> @/alcatel/omc1/data/query.sql
    2 ;
    9 rows selected.
    Execution Plan
    Plan hash value: 3745571015
    | Id | Operation | Name |
    | 0 | SELECT STATEMENT | |
    | 1 | SORT ORDER BY | |
    | 2 | NESTED LOOPS | |
    | 3 | NESTED LOOPS | |
    | 4 | TABLE ACCESS FULL | PARAMETERTABLE |
    |* 5 | TABLE ACCESS BY INDEX ROWID| FDNMAPPINGTABLE |
    |* 6 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
    |* 7 | TABLE ACCESS BY INDEX ROWID | FDNMAPPINGTABLE |
    |* 8 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
    Predicate Information (identified by operation id):
    5 - filter("F1"."OBJECT_TYPE"='ne_sub_type.780')
    6 - access("P1"."ID"="F1"."ID")
    7 - filter("FDN" LIKE '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#
    8 - access("F1"."ID"="ID")
    Note
    - rule based optimizer used (consider using cbo)
    Statistics
    0 recursive calls
    0 db block gets
    0 consistent gets
    0 physical reads
    0 redo size
    0 bytes sent via SQL*Net to client
    0 bytes received via SQL*Net from client
    0 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    9 rows processed
    SQL>

Maybe you are looking for