Problem with LIKE in Cursor

I have table week_tab with data
week_num bkg1 bkg2 bkg_type
1     10     20     at_prod
2     40     10     at_serv
3     30     20     prod
2     20     60     at_prod
1     10     50     at_serv
1     20     80     at_net
3     10     30     at_net
I'm trying to put this query in a cursor
SELECT SUM(bkg2), bkg_type
FROM week_tab
WHERE bkg_type LIKE 'at%'
GROUP BY bkg_type;
PROCEDURE get_bkg_tot(
p_colName IN VARCHAR2,
p_refCursor OUT ref_cursor) AS
v_query VARCHAR2(4000);
BEGIN
v_query := 'select sum('||p_colName||'), bkg_type
from week_tab
where bkg_type like : x
group by bkg_type';
OPEN p_refcursor FOR v_query USING 'at%';
END;
PROCEDURE get_total_val AS
v_refCursor ref_cursor;
v_sum NUMBER;
v_week NUMBER;
v_total NUMBER := 0;
v_colName STRARRAY := STRARRAY ('BKG1','BKG2');
BEGIN
FOR i IN v_colName.FIRST .. v_colName.LAST LOOP
get_bkg_tot ('bkg2', v_refcursor);
LOOP
FETCH v_refCursor
INTO v_sum, v_week;
EXIT WHEN v_refcursor%NOTFOUND;
v_total := v_total + v_sum;
DBMS_OUTPUT.PUT_LINE ('Week '|| v_week||' : '|| v_sum);
END LOOP;
DBMS_OUTPUT.PUT_LINE ('Total Bookings Sale :'|| v_total);
END LOOP;
END get_total_val;
When I tried to execute get_total_val, I'm getting
ORA-01722: invalid number
ORA-06512: at "SCOTT.GET_TOTAL", line 45
ORA-06512: at line 2
What could be the error?
Thanks in advance

Hi,
After corrected fetch into clause...
CREATE OR REPLACE PACKAGE BODY GET_TOTAL AS
   PROCEDURE get_week_total(p_colName   IN VARCHAR2,
                            p_refCursor OUT ref_cursor) AS
      v_query VARCHAR2(4000);
   BEGIN
      v_query := 'SELECT SUM(' || p_colName ||
                 '), week_num FROM week_tab GROUP BY week_num ORDER BY week_num';
      OPEN p_refcursor FOR v_query;
   END get_week_total;
   PROCEDURE get_bkg_tot(p_colName   IN VARCHAR2,
                         p_refCursor OUT ref_cursor) AS
      v_query VARCHAR2(4000);
   BEGIN
      v_query := 'select sum(' || p_colName || '), WEEK_NUM ';
      v_query := v_query || 'from week_tab ';
      v_query := v_query || 'where bkg_type like :x ';
      v_query := v_query || 'group by week_num';
      OPEN p_refcursor FOR v_query
         USING 'at%';
   END;
   PROCEDURE get_total_val AS
      v_refCursor ref_cursor;
      v_sum       NUMBER;
      v_week      NUMBER;
      v_total     NUMBER := 0;
      v_colName   STRARRAY := STRARRAY('BKG1',
                                       'BKG2');
   BEGIN
      FOR i IN v_colName.FIRST .. v_colName.LAST LOOP
         get_bkg_tot(v_colName(i),
                     v_refcursor);
         LOOP
            FETCH v_refCursor
               INTO v_sum, v_week;
            EXIT WHEN v_refcursor%NOTFOUND;
            v_total := v_total + v_sum;
            DBMS_OUTPUT.PUT_LINE('Week ' || v_week || ' : ' || v_sum);
         END LOOP;
         DBMS_OUTPUT.PUT_LINE('Total Bookings Sale :' || v_total);
      END LOOP;
   END get_total_val;
END GET_TOTAL;The output is:
Week 1 : 40
Week 2 : 60
Week 3 : 10
Total Bookings Sale :110
Week 1 : 150
Week 2 : 70
Week 3 : 30
Total Bookings Sale :360Regards,

Similar Messages

  • Has anybody had a problem with the mouse cursor lagging when navigating the drop down menus? this only started happening after a re-install. it only occurs in Photoshop elements 13 in the  photo editing section,and no other application. My mouse drivers a

    Has anybody had a problem with the mouse cursor lagging when navigating the drop down menus? this only started happening after a re-install. it only occurs in Photoshop elements 13 in the  photo editing section,and no other application. My mouse drivers are up to date.Any help or advice would be most welcome.

    Good day!
    Please post Photoshop Elements related queries over at
    http://forums.adobe.com/community/photoshop_elements
    and please read this (in particular the section titled "Supply pertinent information for quicker answers"):
    http://blogs.adobe.com/crawlspace/2012/07/photoshop-basic-troubleshooting-steps-to-fix-mos t-issues.html
    Regards,
    Pfaffenbichler

  • Problem with my hand cursor: it shows three little hands

    Hi there,
    I work for many years with CS4 and now suddenly, my hand cursor shows up as three little hands in a row. I don't know what went wrong or how to correct this. Please help
    Bert

    Hi there,
    That works! And my mouse is scrolling a lot smoother too! Thanks a lot! I am very grateful.
    Best Regards
    Bert
    Boteijken 323
    3454 PD De Meern
    Tel:   030-8201164
    Mob: 0655-720309
    Email:  <mailto:[email protected]> [email protected]
    Van: R_Kelly [email protected]
    Verzonden: zaterdag 31 augustus 2013 17:32
    Aan: Roozworks
    Onderwerp: Problem with my hand cursor: it shows three little hands
    Re: Problem with my hand cursor: it shows three little hands
    created by R_Kelly <http://forums.adobe.com/people/R_Kelly>  in Photoshop for Beginners - View the full discussion <http://forums.adobe.com/message/5642784#5642784

  • Problem with native SQL cursor in generic data source

    Hi, All!
    I am implementing generic data source based on FM.
    Because of complicated SQL I canu2019t use Open SQL and RSAX_BIW_GET_DATA_SIMPLE-example u201Cas isu201D.
    So, I have to use Native SQL. But Iu2019ve got a problem with a cursor. When I test my data source in RSA3, everything is Ok. But, if I start appropriate info-package, I get error u201CABAP/4 processor: DBIF_DSQL2_INVALID_CURSORu201D. It happens after selecting of 1st data package in line u201CFETCH NEXT S1 INTOu2026u201D. It seems to me that when system performs the second call of my FM the opened cursor has already been disappeared.
    Did anyone do things like this and what is incorrect?
    Is it real to make generic data source based on FM with using Native SQL open, fetch, closeu2026

    Hi Jason,
    I don't think this SQL is very valuable It is just an aggregation with some custom rules. This aggregation is performing on info-provider which consists of two info-cubes. Here we have about 2 billion records in info-provider and about 30 million records in custom db-table Z_TMP (certainly, it has indexes). I have to do this operation on 21 info-providers like this and I have to do this 20 times for each info-provider (with different values of host-variable p_GROUP)
    SELECT T.T1, SUM( T.T2 ), SUM( T.T3 ), SUM( T.T4 )
            FROM (
                    SELECT F."KEY_EVENT06088" AS T1,
                            F."/BIC/EV_COST" + F."/BIC/EV_A_COST" AS T2,
                            DECODE( D.SID_EVENTTYPE, 23147, 0,
                                                          23148, 0,
                                                          23151, 0,
                                                          23153, 0,
                                                          23157, 0,
                                                          23159, 0,
                                                          24896734, 0,
                                                          695032768, 0,
                                                          695029006, 0,
                                                          695029007, 0,
                                                          695036746, 0, F."/BIC/EV_COST") +
                              DECODE( D.SID_EVENTTYPE, 23147, 0,
                                                          23148, 0,
                                                          23151, 0,
                                                          23153, 0,
                                                          23157, 0,
                                                          23159, 0,
                                                          24896734, 0,
                                                          695032768, 0,
                                                          695029006, 0,
                                                          695029007, 0,
                                                          695036746, 0, F."/BIC/EV_A_COST") AS T3,
                            DECODE( D.SID_EVENTTYPE, 23147, F."/BIC/EV_DURAT",
                                                          23148, F."/BIC/EV_DURAT",
                                                          23151, F."/BIC/EV_DURAT",
                                                          23153, F."/BIC/EV_DURAT",
                                                          23157, F."/BIC/EV_DURAT",
                                                          23159, F."/BIC/EV_DURAT",
                                                          24896734, F."/BIC/EV_DURAT",
                                                          695032768, F."/BIC/EV_DURAT",
                                                          695029006, F."/BIC/EV_DURAT",
                                                          695029007, F."/BIC/EV_DURAT",
                                                          695036746, F."/BIC/EV_DURAT", 0) AS T4
                      FROM "/BIC/VEVENT0608F" F,
                           Z_TMP G,
                           "/BIC/DEVENT06085" D
                      WHERE F."KEY_EVENT06088" = G.ID
                            AND F."KEY_EVENT06085" = D.DIMID
                            AND G.GROUP_NO = :p_GROUP
                            AND ( F."/BIC/EV_COST" < 0 OR F."/BIC/EV_A_COST" < 0 )
                            AND D.SID_EVENTTYPE <> 695030676 AND D.SID_EVENTTYPE <> 695030678
                    UNION
                    SELECT F."KEY_EVNA06088" AS T1,
                            F."/BIC/EV_COST" + F."/BIC/EV_A_COST" AS T2,
                            DECODE( D.SID_EVENTTYPE, 23147, 0,
                                                          23148, 0,
                                                          23151, 0,
                                                          23153, 0,
                                                          23157, 0,
                                                          23159, 0,
                                                          24896734, 0,
                                                          695032768, 0,
                                                          695029006, 0,
                                                          695029007, 0,
                                                          695036746, 0, F."/BIC/EV_COST") +
                              DECODE( D.SID_EVENTTYPE, 23147, 0,
                                                          23148, 0,
                                                          23151, 0,
                                                          23153, 0,
                                                          23157, 0,
                                                          23159, 0,
                                                          24896734, 0,
                                                          695032768, 0,
                                                          695029006, 0,
                                                          695029007, 0,
                                                          695036746, 0, F."/BIC/EV_A_COST") AS T3,
                            DECODE( D.SID_EVENTTYPE, 23147, F."/BIC/EV_DURAT",
                                                          23148, F."/BIC/EV_DURAT",
                                                          23151, F."/BIC/EV_DURAT",
                                                          23153, F."/BIC/EV_DURAT",
                                                          23157, F."/BIC/EV_DURAT",
                                                          23159, F."/BIC/EV_DURAT",
                                                          24896734, F."/BIC/EV_DURAT",
                                                          695032768, F."/BIC/EV_DURAT",
                                                          695029006, F."/BIC/EV_DURAT",
                                                          695029007, F."/BIC/EV_DURAT",
                                                          695036746, F."/BIC/EV_DURAT", 0) AS T4
                    FROM "/BIC/VEVNA0608F" F,
                         Z_TMP G,
                         "/BIC/DEVNA06085" D
                    WHERE F."KEY_EVNA06088" = G.ID
                          AND F."KEY_EVNA06085" = D.DIMID
                          AND G.GROUP_NO = :p_GROUP
                          AND ( F."/BIC/EV_COST" < 0 OR F."/BIC/EV_A_COST" < 0 )
                          AND D.SID_EVENTTYPE <> 695030676 AND D.SID_EVENTTYPE <> 695030678
                 ) T
            GROUP BY T.T1

  • Problem with OS X, Cursor, Zoom, Dictionary Issues

    Hi All,
    I'm wondering if someone can provide some guidance to problems I've recently been having with my Mac Book Pro laptop. Starting about a week ago, my cursor on the screen seemed to grow a mind of it's own and all of a sudden started acting strangely. When I'd go to scroll down a screen it wouldn't respond at first and then it would respond but not go anywhere in the direction I was moving it. Simultaneously, the screen would zoom in and out and become unresponsive and then whatever text was in the range of the cursor would randomly hightlight in yellow and a dictonary definition of the word would pop up.
    If anyone has any experience with problems such as these, can you please let me know. I'm having these issues frequently enough to make the computer really unusable. I'm not sure if this is a problem with my computer itself or some software glitch. I've never had problems with this MacBook Pro before, and it is very new, purchased just like 18 months ago.

    Portables and Magic Trackpad: Jumpy or erratic trackpad operation

  • Satellite P100-324: Problems with Vista installation - cursor blinking

    All greetings. Tried to put one of these days Windows Vista. But my attempts by failure have ended. After the first ???????????? there is a black screen and the blinking cursor. Thus any activity HDD and DVD it is not observed. BIOS recently updated up to v3.30. Help to put, already and I do not know what to think up.
    For English I apologize, I from Russia:)

    The disk "With" was formatted under NTFS then there was a pure installation from a loading disk through BIOS. At the start the computer starts to be loaded, and reaching a place where there should be a window of loading there is a black screen with the blinking cursor in the top left corner. Tried to wait for 10-15 mines, results has not brought.: (

  • Problem with collection in cursor

    hi ,
    oracle srvr : 10.2.0.1.0
    when I'm executing the following
    declare
    type i_values is varray(20000) of employee_details%rowtype;
    s_values i_values :=i_values();
    cursor c1 is select * from employee_details where rownum < 11;
    begin
    loop
    begin
    fetch c1  into s_values  ;
    s_values.extend;
    exit when c1%NOTFOUND;
    exception
    when  invalid_cursor then
    dbms_output.put_line('Cursor invalid');
    when others then
    dbms_output.put_line('Others');
    end ;
    end loop;
    for i in 1 .. s_values.count loop
    dbms_output.put_line(s_values(i).eid);
    end loop;
    end;
    / I get the error as
    ERROR at line 8:
    ORA-06550: line 8, column 16:
    PLS-00597: expression 'S_VALUES' in the INTO list is of wrong type
    ORA-06550: line 8, column 1:
    PL/SQL: SQL Statement ignoredInstead when I run cursor as bulk collect its executing but going to a infinite loop
    please help

    As Justin showed, you want to use BULK collect if you need to fetch data into a collection.
    e.g.
    SQL> set serverout on
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    type t_emps is table of emp%rowtype;
      3    v_emps t_emps;
      4    cursor c1 is
      5      select *
      6      from emp
      7      where rownum <= 10;
      8  begin
      9    open c1;
    10    fetch c1 bulk collect into v_emps;
    11    close c1;
    12    for i in 1 .. v_emps.count
    13    loop
    14      dbms_output.put_line(v_emps(i).empno||' - '||v_emps(i).ename);
    15    end loop;
    16* end;
    SQL> /
    7369 - SMITH
    7499 - ALLEN
    7521 - WARD
    7566 - JONES
    7654 - MARTIN
    7698 - BLAKE
    7782 - CLARK
    7788 - SCOTT
    7839 - KING
    7844 - TURNER
    PL/SQL procedure successfully completed.
    SQL>If your code has got stuck in an infinite loop, you've probably left the LOOP construct in your code. That isn't needed with a bulk collect, unless you limit the number of rows fetched and need to process in set sized chunks.
    If you planning on extracting the data to a load of INSERT statements then consider that as being bad practice.
    You would be better to export the data to a flat file (CSV) and then have the receiving database use an external table (or SQL*Loader) if you must, to load that data back in. Lots of insert statements WILL be slow.
    If you want to export data to a flat file you can use something like:
    As sys user:
    CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
    GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
    /As myuser:
    CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
                                         ,p_dir IN VARCHAR2
                                         ,p_header_file IN VARCHAR2
                                         ,p_data_file IN VARCHAR2 := NULL) IS
      v_finaltxt  VARCHAR2(4000);
      v_v_val     VARCHAR2(4000);
      v_n_val     NUMBER;
      v_d_val     DATE;
      v_ret       NUMBER;
      c           NUMBER;
      d           NUMBER;
      col_cnt     INTEGER;
      f           BOOLEAN;
      rec_tab     DBMS_SQL.DESC_TAB;
      col_num     NUMBER;
      v_fh        UTL_FILE.FILE_TYPE;
      v_samefile  BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
    BEGIN
      c := DBMS_SQL.OPEN_CURSOR;
      DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
      d := DBMS_SQL.EXECUTE(c);
      DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
      FOR j in 1..col_cnt
      LOOP
        CASE rec_tab(j).col_type
          WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
          WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
          WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
        ELSE
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
        END CASE;
      END LOOP;
      -- This part outputs the HEADER
      v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
      FOR j in 1..col_cnt
      LOOP
        v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
      END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
      UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      IF NOT v_samefile THEN
        UTL_FILE.FCLOSE(v_fh);
      END IF;
      -- This part outputs the DATA
      IF NOT v_samefile THEN
        v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
      END IF;
      LOOP
        v_ret := DBMS_SQL.FETCH_ROWS(c);
        EXIT WHEN v_ret = 0;
        v_finaltxt := NULL;
        FOR j in 1..col_cnt
        LOOP
          CASE rec_tab(j).col_type
            WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                        v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
            WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                        v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
            WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                        v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
          ELSE
            v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
          END CASE;
        END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
        UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      END LOOP;
      UTL_FILE.FCLOSE(v_fh);
      DBMS_SQL.CLOSE_CURSOR(c);
    END;This allows for the header row and the data to be written to seperate files if required.
    e.g.
    SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
    PL/SQL procedure successfully completed.Output.txt file contains:
    empno,ename,job,mgr,hiredate,sal,comm,deptno
    7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
    7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
    7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
    7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
    7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
    7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
    7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
    7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
    7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
    7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
    7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
    7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
    7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
    7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10The procedure allows for the header and data to go to seperate files if required. Just specifying the "header" filename will put the header and data in the one file.
    Adapt to output different datatypes and styles are required.

  • Named query problem with "like" statement

    I'm having issues with a named query that contains a 'like' statement in it. I have other named queries that have like statements that have hardcoded like values in them that work fine.
    (i.e. select * from foo where foo.col1 like 'foo%' )
    But when the like value to be tested is a parameter, it doesn't seem to work at all, no matter what variation i've tried, other than no wildcards.
    (i.e.
    this DOES work
    select * from foo where foo.col1 like #fooParm
    this DOES NOT work
    select * from foo where foo.col1 like '%#fooParm%'
    Any suggestions on how to get this to work?
    Thanks in advance

    Try building your select statement in a different way.
    Instead of:
    select * from foo where foo.col1 like '%#fooParm%'
    Try something like:
    select * from foo where foo.col1 like '#fooParm'
    And include the wild cards in the parameter.
    i.e. if fooParam was 'abc', make fooParm = '%abc%'

  • Problem with LIKE parameter in SQL

    Hi there,
    I got some problem trying to execute a query. Mainly the idea is that the user can choose the itemcode or part of it, thats why I use the Like operator. I try different way of using the LIKE operator,based on other topic, but still I don't get out.
    I post my query, hoping that somebody can help me (the LIKE Clause you see is one of the last I tried)
    SELECT DISTINCT ItemCode,
         (CASE WHEN WhsCode = '01' THEN (OnHand-IsCommited+OnOrder) ELSE 0 END) AS DispMag01,
         (CASE WHEN WhsCode = '02' THEN (OnHand-IsCommited+OnOrder) ELSE 0 END) AS DispMag02,
         (CASE WHEN WhsCode = '03' THEN (OnHand-IsCommited+OnOrder) ELSE 0 END) AS DispMag03,
         (CASE WHEN WhsCode = '04' THEN (OnHand-IsCommited+OnOrder) ELSE 0 END) AS DispMag04
    FROM OITW  WHERE(OnHand-IsCommited+OnOrder)>0 AND ItemCode Like '%%' + '[%itemC]' + '%%' ORDER BY ItemCode
    Waiting for your kind reply
    Rgds
    Roberto

    I think that itemc is some variable. You should creaqte the string of query as
    SELECT DISTINCT ItemCode,
         (CASE WHEN WhsCode = '01' THEN (OnHand-IsCommited+OnOrder) ELSE 0 END) AS DispMag01,
         (CASE WHEN WhsCode = '02' THEN (OnHand-IsCommited+OnOrder) ELSE 0 END) AS DispMag02,
         (CASE WHEN WhsCode = '03' THEN (OnHand-IsCommited+OnOrder) ELSE 0 END) AS DispMag03,
         (CASE WHEN WhsCode = '04' THEN (OnHand-IsCommited+OnOrder) ELSE 0 END) AS DispMag04
    FROM OITW  WHERE(OnHand-IsCommited+OnOrder)>0 AND ItemCode Like '%' + itemC + '%' ORDER BY ItemCode
    the string at the end should be like
    SELECT DISTINCT ItemCode,
         (CASE WHEN WhsCode = '01' THEN (OnHand-IsCommited+OnOrder) ELSE 0 END) AS DispMag01,
         (CASE WHEN WhsCode = '02' THEN (OnHand-IsCommited+OnOrder) ELSE 0 END) AS DispMag02,
         (CASE WHEN WhsCode = '03' THEN (OnHand-IsCommited+OnOrder) ELSE 0 END) AS DispMag03,
         (CASE WHEN WhsCode = '04' THEN (OnHand-IsCommited+OnOrder) ELSE 0 END) AS DispMag04
    FROM OITW  WHERE(OnHand-IsCommited+OnOrder)>0 AND ItemCode Like '%part_of_code%' ORDER BY ItemCode
    hope it helps

  • Problem with query in cursor (Oracle 8i)

    Hi all,
    Following query works perfectly fine if I test it in my development environment
    SELECT dt,
          (SELECT 'Y'
             FROM dual
            WHERE EXISTS (SELECT 'x'
                            FROM top_days t
                           WHERE t.date = dt))
    FROM (SELECT to_date(p_date_start, 'dd-mm-yyyy') + LEVEL - 1 dt
                       FROM dual
                     CONNECT BY LEVEL <=
                                to_date(p_date_end, 'dd-mm-yyyy') - to_date(p_date_start, 'dd-mm-yyyy') + 1
                            AND PRIOR dbms_random.value IS NOT NULL) --workaround for oracle 8i
                    top_days t
    WHERE dt = t.date(+)
    ORDER BY dt;However, when I try to include it in my package (where it's used in a cursor) I get a PLS-00103: Encountered the symbol "SELECT" when expecting one of the following: ( - + mod null others <an identifier> etc)
    CURSOR c_holidays IS
               SELECT dt,
                    (SELECT 'Y'
                       FROM dual
                      WHERE EXISTS (SELECT 'x'
                               FROM top_days t
                              WHERE t.date = dt))
               FROM (SELECT to_date(p_date_start, 'dd-mm-yyyy') + LEVEL - 1 dt
                       FROM dual
                     CONNECT BY LEVEL <=
                                to_date(p_date_end, 'dd-mm-yyyy') - to_date(p_date_start, 'dd-mm-yyyy') + 1
                            AND PRIOR dbms_random.value IS NOT NULL) --workaround for oracle 8i
                    top_days t
              WHERE dt = t.date(+)
              ORDER BY dt;Is there some special thing I don't know about Oracle 8i that prevents me from using this query in a cursor? Or am I just missing something blatantly obvious?
    Note: p_date_start and p_date_end are parameters that are filled in the function
    FYI: Oracle 8i release 8.1.7.4.1 and PL/SQL Release 8.1.7.4.0

    Hi,
    You can do a join instead of using a scalar sub-query:
    SELECT        a.dt
    ,       CASE
              WHEN  t.dt IS NOT NULL
              THEN  'Y'
           END          AS in_top_days
    FROM        (
              SELECT      to_date (p_date_start, 'dd-mm-yyyy') + LEVEL - 1 dt
                    FROM dual
                    CONNECT BY      LEVEL <=
                                     to_date(p_date_end, 'dd-mm-yyyy') - to_date(p_date_start, 'dd-mm-yyyy') + 1
                            AND      PRIOR dbms_random.value IS NOT NULL --workaround for oracle 8i
           )          a
    ,         top_days     t
    WHERE        a.dt      = t.dt (+)
    ORDER BY  a.dt; 
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), a few sets of parameters (p_date_start and p_date_end), and the results you want from that data for each set.
    Explain, using specific examples, how you get those results from that data.

  • Problem with LIKE operator in select query

    Hi,
    I want to compare one field using LIKE operator. But i m not able to do that.
    DATA: l_doctext type c value ''''.
    CONCATENATE l_doctext s_lbktxt-low '%' l_doctext INTO s_lbktxt-low.
    SELECT bukrs belnr gjahr blart bldat budat xblnr bktxt waers awtyp
                FROM bkpf INTO TABLE g_t_bkpf_labor
                FOR ALL ENTRIES IN g_t_bseg_unique
                WHERE bukrs = g_t_bseg_unique-bukrs
                AND belnr = g_t_bseg_unique-belnr
                AND gjahr = g_t_bseg_unique-gjahr
                AND blart = p_ldtype
                AND bktxt LIKE s_lbktxt-low.
    plz help. Am i dng something wrong.
    Value in s_lbktxt can be like 'TEA.....'

    hi ,
    check this program..
    tables:mara.
    data: begin of it_mara occurs 0,
          matnr like mara-matnr,
          meins like mara-meins ,
          mtart like mara-mtart,
          end of it_mara.
    select-options: s_matnr for mara-matnr.
          select matnr
                 meins
                 mtart
                 from mara
                 into table it_mara
                 where matnr like '%7'.
    sort it_mara by matnr.
    loop at it_mara.
    write:/ it_mara-matnr,
    it_mara-meins,
    it_mara-mtart.
    endloop.
    regards,
    venkat.

  • Problem with Like Keyword

    Display the last name of all employees who have an a and an e in their last name using like keyword in oracle 10g...............

    870737 wrote:
    Display the last name of all employees who have an a and an e in their last name using like keyword in oracle 10g...............need to utilize "OR" in WHERE clause

  • Upgraded to iOS 6 and now I can't open anything in the kindle app? I have to say that I have had my ipad3 for 6 months and intensely dislike the problems with using it. Also is there any way of opening more than one screen as it is hopeless otherwise?

    I Have had my iPad for 6 months as I cannot access my work emails using windows. I have to say that it is the most unhelpful device I have ever used and although it looks like there isn't an answer for some of the questions I have asked below, I thought I would try!
    1) I have upgraded to ios6 and the kindle app will open but crashes and disappears when I try to access a book?
    2) is there any way I can open more than one page at a time, as opening one at a time is hopeless?
    3) Is there any way you can replicate the right click function on word? As pasting and copying on the iPad is irritating to say the least!
    4) why can't my Samsung 11 phone connect to my iPad via Bluetooth? A they can't seem to 'see' each other? I may have turned a setting off when I was recently abroad and didn't want huge roaming charges.
    5) Why do the submit buttons on some websites not work and how can I get them to? I never have a problem with windows, but it is often a problem with the iPad.
    6) I have several websites which I have built and usually upgrade on the windows desktop, usually through Internet explorer, but I can't access the sites properly on the iPad (I can see them but can't alter them) and when sending emails through the websites they won't show the page and I can't navigate the page (the size of the email page is bigger than the iPad screen, but I can't either shrink the page to size or move the page around as you normally would on the pad, any ideas?
    7) finally, when roaming abroad recently, I had no problems using the wifi, but when trying to use the cellular data (using the roaming function) I could not get it to work? The ipad seemed to be connected to the network with no problems, but wouldn't actually update the emails? I tried turning it on and off, but that didn't make a difference. My kindle and mobile phone (both also on 3G ) worked great, it was just (as usual) the ipad playing up.
    8) when wanting to alter part of a sentence, I can't always get the cursor in the right place? Sometimes it is simple the wrong line, but often it will only go at the end or start of a word and not where I want it. Is there any way of making it more exact? Again I never have a problem with moving the cursor on windows, either by mouse or on the touch screen function on windows 7. Any ideas? As after pressing the screen multiple times I just want to throw it out of the window!
    IT might just be that I don't have the correct settings (I am a technophobe) but I absolutely hate the iPad and only have it for work emails, it is so annoying that I can get my mobile phone and kindle3g to work fine, but always have problems with the iPad. I am sure it could be good (and for reading emails on the go in the uk it is great, as I like the key board) but it just seems to make everything else difficult.
    i Hope you can help and sorry for asking questions others have, but I am just hoping that something new might have been developed!
    thanks,
    K
    Message was edited by: K Paton

    1) I have upgraded to ios6 and the kindle app will open but crashes and disappears when I try to access a book?
    Try rebooting your iPad, that should fix he issue. I that doesn't work, delete the app and re-download it.  The Kindle books should all be in he Kindle cloud services and you can get them again. I have an iPad2 w/ Kindle app and it works just fine - no issues.
    2) is there any way I can open more than one page at a time, as opening one at a time is hopeless?
    Page as in a kindle book way? turn iPad to landscape position from portrait position. If, however, you mean open more than one application at a time, then no. And not hopeless, as it takes a bit of time to get used to, going from a desktop/laptop format to tablet format.
    3) Is there any way you can replicate the right click function on word? As pasting and copying on the iPad is irritating to say the least!
    It's actually fairly easy. Press down on the word, then you can expand by drawing your finger to cover word/sentence/paragraph/page, hit select or select all then it gives you the option to cut, copy, paste, define. If you want to use a word processing app on the iPad, Pages is a good application.
    4) why can't my Samsung 11 phone connect to my iPad via Bluetooth? A they can't seem to 'see' each other? I may have turned a setting off when I was recently abroad and didn't want huge roaming charges.
    It's the connection on your phone. Samsung Galaxy SII? Android software?  What you have to do is go to the phone's settings and connect via wireless, not Bluetooth. Go to System Settings (on phone) and under Wireless and Networks click 'more' and go to the Tethering and Portable Hotspot option. Set up your mobile wifi hotspot,  name it though it will probably come up with 'AndroidAP', choose a WPA2 security level and put in a password. Go back to previous screen and turn on 'Portable Wi-Fi Hotspot' box. Then on your iPad in the Settings - Wi-Fi section, it should then recognize your phone for tethering. If it's a Windows Phone 7,  I don't know the layout of that software, but presumeably similar.
    5) Why do the submit buttons on some websites not work and how can I get them to? I never have a problem with windows, but it is often a problem with the iPad.
    Sometimes the issue is with the website design, not all websites are optimized for mobile devices - not just iPad but also Android devices. It happens. They're getting there, but occasionally the page might need a refresh.
    6) I have several websites which I have built and usually upgrade on the windows desktop, usually through Internet explorer, but I can't access the sites properly on the iPad (I can see them but can't alter them) and when sending emails through the websites they won't show the page and I can't navigate the page (the size of the email page is bigger than the iPad screen, but I can't either shrink the page to size or move the page around as you normally would on the pad, any ideas?
    It depends on what you use to build the websites on the computer. Recommend a free program on the computer called CoffeeCup Free HTML Editor. I don't recommend using IE period; Firefox or Chrome are my choices on Windows machines. I have two websites that I manage, both using this program. I'm assuming that when you mean you can't access the sites on the iPad you mean to update them? Ostensible there are apps to let you do this. What format are the sites? Without seeing what exactly you mean and what you want to do, it's hard to explain.
    As for seeing full page while emailing within a site, turn iPad to portrait mode, and try to finger-pinch touch the screen to see if that will bring the fuller page  into view. Other option is opening a second tab with same website and just go between tabs to reference material.
    7) finally, when roaming abroad recently, I had no problems using the wifi, but when trying to use the cellular data (using the roaming function) I could not get it to work? The ipad seemed to be connected to the network with no problems, but wouldn't actually update the emails? I tried turning it on and off, but that didn't make a difference. My kindle and mobile phone (both also on 3G ) worked great, it was just (as usual) the ipad playing up.
    If you were outside the US or Canada, my guess is the problem lies within the SIM card in your iPad. If you were outside North America, there are different band levels - I'm guessing you have a SIM thats locked to a particular provider. Band level frequencies differ per country/continent, so a SIM card that will work in Canada/US will not likely work in UK/Europe/Asia/Australia, etc. you will be able to get your emails again when back on a wifi network. Mobile phone may have a different type SIM card (GSM/HSPA) from your iPad SIM. Also, check your email settings.
    8) when wanting to alter part of a sentence, I can't always get the cursor in the right place? Sometimes it is simple the wrong line, but often it will only go at the end or start of a word and not where I want it. Is there any way of making it more exact? Again I never have a problem with moving the cursor on windows, either by mouse or on the touch screen function on windows 7. Any ideas? As after pressing the screen multiple times I just want to throw it out of the window!
    Moving the cursor on a sentence is a matter of putting your finger on the screen where you want it. It's exceptionally easy to do. I'm using the Notes app to write this whole segment and I just need to put my finger where I want to change things and presto it's ready for me to change where I want it.
    Here's a solution: sell your iPad (after you wipe your data off it) to someone who will appreciate it, and put your money towards the Windows Surface Tablet out later this year/early next year, where you can (reportedly) connect a mouse to it. It will have some of the Windows 7/8 functionality that you're more familiar with, or get a netbook.
    - Ceridwyn2

  • Problems with the items (control) in forms 9i (Re)

    Hello,
    I write this problem in a other post and but don't have any feedback about it(So I will give another try:-) )
    The problem that I will describe don't happen all the time and is very rare but I want to know if it's a normal bug of forms or something more special of our PL/SQL code...
    So here we are.
    Is there others developpers here that have problems with the mouse cursor of the user that seems to be "jammed"(blocked, trapped) in a text item (or another control, like a list item). When this problems happen, the user can't go on another field of the forms with his mouse cursor(Mouse click), the only thing that can resolve that is to refresh the page with Internet Explorer, and after that, he is free to go on another field of the forms.
    This problem is very rare but happens sometimes.
    Thanx in advance!

    Hi,
    This problem is due to failuer of navigation of mouse cursore. For more specific solution can you give the error message and error code, So that we can have exact picture. Waiting for error code......

  • I had a problem with my mouse double(multiple) clicking when I didn't want it to, now pressing enter in a window like this will close the current window and open one of my Taboo sites, and the cursor keys don't work.

    This happens in any text entry window, but there is no problem with Wordpad or Word or other apps, just in Firefox. It's like the keyboard mapping has gotten fouled up in Firefox, but I can't find where I might check what is going on.

    You may have '''Switched ON Caret Browsing'''. press '''F7 (on Mac: fn + F7)''' to toggle '''Caret Browsing ON/OFF'''
    * click '''Firefox''' button and click '''Options''' -> Advanced -> General -> remove
    Checkmark from '''Always use the cursor keys to navigate within pages'''
    * http://kb.mozillazine.org/Scrolling_with_arrow_keys_no_longer_works
    * http://kb.mozillazine.org/Accessibility_features_of_Firefox
    Check and tell if its working.

Maybe you are looking for

  • Reading in a txt file, appending numbers to it.

    So I'm a student at Georgia Tech working on a relatively simple Java program for a research internship, but it's been awhile since I've had my Java course and I'd really like some help on this. Basically, what I'm looking to do is to take in a text f

  • Query based on parameters

    Hello, I have two forms. The first takes several values that are entered and then passes them as parameters to the second form. How can I retrieve all records (execute query) in the second form based on the passed parameters. What I want to do is sea

  • Named destinations - unicode

    Hi i am wondering how i can use named destinations that has special letters in them linking from a homepage? My Document.pdf#target dãc I get it to work using the command line: AcroRd32.exe /A "nameddest=target dãc" "My Document.pdf" and i get html l

  • Deleting movie on iphone???

    Hi guys can anybody help me. Would like to know how I can delete a movie on my iphone. Swiping or clicking not helping in the video section. Thx dany

  • BT Make Final Adjustments for Faster FTTC Broadban...

    BTOpenreach has advised ISPreview.co.uk that their first trial of VDSL Vectoring (ITU-T G.993.5) technology, which could make even faster speeds available to more people on BT’s superfast (‘up to’ 80Mbps) hybrid-fibre (FTTC) broadband network, has be