Variable in which returns no rows

Hello

I'm sorry if this is a simple question but I must be missing something and I can not find the answer. I'm writing a very simple search, and when I get to the USER: P10_SEARCH (inside the SQL workshop pop up) it returns no rows, but when I change it to "where ut." USERNAME = 'USER' "without the double quote him returns the row for the USER username. I'm under APEX 3.2.0.00.27 in 10 Express. I looked at some examples of Oracle applications and I couldn't find my mistake, if someone could guide me in the right direction I'd appreciate it.


Select ut. Username "username".
ut. Username "username".
ut. FIRST_NAME. ' ' || STH Last_name 'full name '.
ut. DEPARTMENT "Department".
c USER_TABLE
where ut. USERNAME =: P10_SEARCH

Hello
If the USER name column is defined as a CHAR data type, then you will need to mount your binding variable (P10_SEARCH) being of the CHAR type.

....
where a.USERNAME = cast( :P10_SEARCH as char(n)  )   --- where n is the same size as declared for USERNAME

CITY

Published by: city has on January 4, 2010 17:09

Tags: Database

Similar Questions

  • Select Update which returns no rows

    Y at - it no weird side effects that may occur if a select for update which returns no results is never hired? I don't think there is, but I do not know if there would be some sort of overhead or unintended consequences. This isn't a huge issue, but it has developed in some coding I did and I was not able to find documents addressing it.

    I would say that the only side effect: no other session can make DDL with the selected table.

  • How can we calll a package of Pro * C function, which returns a ROWTYPE?

    Hi all

    I did research on it, but have not met another example - maybe you can't do?

    We have a function in a PL/SQL package on our database, which returns a value of type % ROWTYPE. We call it successfully from within our application (Oracle Forms), but we must also be able to call from a Pro * C program. Has anyone else done this successfully?

    We use the Oracle 11 g, Pro * C 10.1.0.5.0 exit.

    We have a function in a PL/SQL package on our database, which returns a value of type % ROWTYPE. We call it successfully from within our application (Oracle Forms), but we must also be able to call from a Pro * C program.

    I guess you can do the following:

    -call the function from an embedded PL/SQL block

    -copy each of the Records of individual host variables attributes

    EXEC SQL EXECUTE
    DECLARE
      my_rec  my_table%rowtype;
    BEGIN
      my_rec := my_pkg.fun();
    
      :attr1 := my_rec.col1;
      :attr2 := my_rec.col2;
    END;
    END-EXEC;
    
  • Stupid old backpacker (me) cannot understand why this query returns 1 row

    Hi all

    In reference to {: identifier of the thread = 2456973}, why do
    select sum(count(decode(job, 'CLERK', 1, null))) CLERKS
    , sum(count(decode(job, 'SALESMAN', 1, null))) SALESMANS
    from emp group by job;
    only 1 rank and not 1 for each task? In fact, I had to test it myself to believe.

    It returns the data as if the query were
    select sum(CLERKS), sum(SALESMANS)
    from (select count(decode(job, 'CLERK', 1, null)) CLERKS, count(decode(job, 'SALESMAN', 1, null)) SALESMANS
             from emp group by job)
    Using only a single aggregate (count or sum) returns 1 row per job, as expected

    John Stegeman wrote:
    It returns the data as if the query were

    select sum(CLERKS), sum(SALESMANS)
    from (select count(decode(job, 'CLERK', 1, null)) CLERKS, count(decode(job, 'SALESMAN', 1, null)) SALESMANS
    from emp group by job)
    

    Exactly the point ;-)

    It seems that Oracle actually do, a group of 'double' in the same operation.
    Attend plans to explain in this example:

    SQL> select count(decode(job, 'CLERK', 1, null)) CLERKS
      2       , count(decode(job, 'SALESMAN', 1, null)) SALESMANS
      3  from scott.emp group by job;
    
        CLERKS  SALESMANS
    ---------- ----------
             0          0
             0          0
             0          0
             0          4
             4          0
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 1697595674
    
    ---------------------------------------------------------------------------
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |      |     5 |    40 |     4  (25)| 00:00:01 |
    |   1 |  HASH GROUP BY     |      |     5 |    40 |     4  (25)| 00:00:01 |
    |   2 |   TABLE ACCESS FULL| EMP  |    14 |   112 |     3   (0)| 00:00:01 |
    ---------------------------------------------------------------------------
    

    And compare it to the one with the double aggregates:

    SQL> select sum(count(decode(job, 'CLERK', 1, null))) CLERKS
      2       , sum(count(decode(job, 'SALESMAN', 1, null))) SALESMANS
      3  from scott.emp group by job;
    
        CLERKS  SALESMANS
    ---------- ----------
             4          4
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 417468012
    
    ----------------------------------------------------------------------------
    | Id  | Operation           | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------
    |   0 | SELECT STATEMENT    |      |     1 |     8 |     4  (25)| 00:00:01 |
    |   1 |  SORT AGGREGATE     |      |     1 |     8 |     4  (25)| 00:00:01 |
    |   2 |   HASH GROUP BY     |      |     1 |     8 |     4  (25)| 00:00:01 |
    |   3 |    TABLE ACCESS FULL| EMP  |    14 |   112 |     3   (0)| 00:00:01 |
    ----------------------------------------------------------------------------
    

    There are GROUP BY hash and SORT GLOBAL times.

    It is really unnecessary to an aggregate on an aggregate - if two aggregates are used "in the same group level.
    Sum() aggregates are used on an already aggregated value, so it doesn't look like Oracle which actually cures like 'first do the internal aggregate using the group specified by and then do the external aggregation on the result with any group.'

    Look at this example where I combine aggregates "double" with "single" aggregates:

    SQL> select sum(count(decode(job, 'CLERK', 1, null))) CLERKS
      2       , sum(count(decode(job, 'SALESMAN', 1, null))) SALESMANS
      3       , count(decode(job, 'SALESMAN', 1, null)) SALESMANS2
      4       , count(*) COUNTS
      5  from scott.emp group by job;
    
        CLERKS  SALESMANS SALESMANS2     COUNTS
    ---------- ---------- ---------- ----------
             4          4          1          5
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 417468012
    
    ----------------------------------------------------------------------------
    | Id  | Operation           | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------
    |   0 | SELECT STATEMENT    |      |     1 |     8 |     4  (25)| 00:00:01 |
    |   1 |  SORT AGGREGATE     |      |     1 |     8 |     4  (25)| 00:00:01 |
    |   2 |   HASH GROUP BY     |      |     1 |     8 |     4  (25)| 00:00:01 |
    |   3 |    TABLE ACCESS FULL| EMP  |    14 |   112 |     3   (0)| 00:00:01 |
    ----------------------------------------------------------------------------
    

    When you mix "doubles" and "single" aggregates, Oracle decides that unique aggregates belong to the 'outer' aggregation
    SALESMAN2 did a count on the aggregated work column which is the result of the 'internal' group by - so only 1.
    The count (*) is also the result of the aggregation of the 'internal '.

    I don't know if it's documented or if it is an 'effect' of internal code used for GROUPING SETS or the internal code used to enable the analytical functions like this:

    SQL> select count(decode(job, 'CLERK', 1, null)) CLERKS
      2       , count(decode(job, 'SALESMAN', 1, null)) SALESMANS
      3       , sum(count(decode(job, 'CLERK', 1, null))) over () CLERKS2
      4       , sum(count(decode(job, 'SALESMAN', 1, null))) over () SALESMANS2
      5  from scott.emp group by job;
    
        CLERKS  SALESMANS    CLERKS2 SALESMANS2
    ---------- ---------- ---------- ----------
             0          0          4          4
             4          0          4          4
             0          0          4          4
             0          0          4          4
             0          4          4          4
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 4115955660
    
    ----------------------------------------------------------------------------
    | Id  | Operation           | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------
    |   0 | SELECT STATEMENT    |      |     5 |    40 |     4  (25)| 00:00:01 |
    |   1 |  WINDOW BUFFER      |      |     5 |    40 |     4  (25)| 00:00:01 |
    |   2 |   SORT GROUP BY     |      |     5 |    40 |     4  (25)| 00:00:01 |
    |   3 |    TABLE ACCESS FULL| EMP  |    14 |   112 |     3   (0)| 00:00:01 |
    ----------------------------------------------------------------------------
    

    Personally, I think that I would have preferred if Oracle has raised an error on this "double aggregation" and therefore require me to write this way (if it's the result I wanted):

    select sum(CLERKS), sum(SALESMANS)
    from (select count(decode(job, 'CLERK', 1, null)) CLERKS, count(decode(job, 'SALESMAN', 1, null)) SALESMANS
             from emp group by job)
    

    I don't really see a good use case for aggregations of 'double'-, but rather that he could give you undetected bugs in your code, if you happen to do double aggregation without noticing.

    Interesting thing to know ;-)

  • Interactive report that returns 0 rows on the initial screen of forcing

    How can I get the initial display of my interactive to have 0 rows (and quickly) reports on the initial display, so that the user can determine the lines they want without having to wait for the report view without much in the way of the filters?

    My reports many lines of 50-100 k with several joins of tables: so they are slow and the initial default result set is not useful for them, until they start of construction interactive filters themselves.

    I tried to add a default I / filter R which is never true, return 0 rows, but if I have good corrrectly, APEX will execute the sql 1, returning the default #of ranks backward, THEN that wraps like a subselect and applies to the i / R filters. So, I still have to wait for the report of 'run' before its filtered to 0 rows...

    I'm experimenting also with a flag of pxx_firsttime, intiall value, and according to my report SQL NVL(:Pxx_FIRSTTIME,'Y') = n and (rest of joins of tables)...
    the problem I have with this is, how can I get this option the value N as the user begins to use the interactive report filters, etc., which seem NOT to resubmit the page?

    Thank you

    Hello

    I tried to add a default I / filter R which is never true, return 0 rows, but if I have good corrrectly, APEX will execute the sql 1, returning back by default #of lines, THEN that wraps like a subselect and applies the > I / R filters. So, I still have to wait for the report of 'run' before its filtered to 0 rows...

    Yes, you are right.

    I assume that you already have using the paging Type as line from X to Y.

    the problem I have with this is, how can I get this option the value N as the user begins to use the interactive report filters, etc., which seem NOT to resubmit the page?

    Whenever the user do something with 'Actions', APEX IR will get updated. Thus, to create a dynamic Action that will be triggered before the refreshment of your IR, update the session state from P1_FIRSTTIME_FLAG to "n".

    Kind regards
    Hari

  • Attributes XML makes my query returns no rows

    Hi all

    I have a strange problem.

    I ask an XML, but the attributes in one of the tags my query will return no rows. If I delete the attributes, the query works as expected.

    The XML code is below; This is the Report tag attributes that cause problems:
    <result errorCode="0">
         <return>
              <Report
                   xsi:schemaLocation="Items_x0020_status_x0020_information http://******-****/ReportServer?%2FReports%2FContent%20Producer%20Reports%2FItems%20status%20information&amp;rs%3AFormat=xml&amp;rc%3ASchema=True"
                   Name="Items status information" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xmlns="Items_x0020_status_x0020_information">
                   <Tablix1>
                        <Details_Collection>
                             <Details ItemId="914P7" Username="test" user_role="IT"
                                  first_name="Barry" last_name="Donovan" organisation=""
                                  content_format="On_Screen" modified_date="26/05/2011 13:16:49"
                                  item_status="Draft" status_date="" component_name="" demand="" />
                        </Details_Collection>
                   </Tablix1>
              </Report>
         </return>
    </result>
    My query is:
         select
                a.item_id
               ,a.username
               ,a.user_role
               ,a.first_name
               ,a.last_name
               ,a.supplier_id
               ,a.format
               ,a.modified_date
               ,a.item_status
               ,a.completion_date
               ,a.component_code
    
             from   dual
                   ,xmltable
                    ('/result/return/Report/Tablix1/Details_Collection/Details'
                       passing p_xml
                       columns
                          item_id         varchar2(1000) path '@ItemId'
                         ,username        varchar2(1000) path '@Username'
                         ,user_role       varchar2(1000) path '@user_role'
                         ,first_name      varchar2(1000) path '@first_name'
                         ,last_name       varchar2(1000) path '@last_name'
                         ,supplier_id     varchar2(1000) path '@organisation'
                         ,format          varchar2(1000) path '@content_format'
                         ,modified_date   varchar2(1000) path '@modified_date'
                         ,item_status     varchar2(1000) path '@item_status'
                         ,completion_date varchar2(1000) path '@status_date'
                         ,component_code  varchar2(1000) path '@demand'
                    ) a;
    I tried to strip the attributes to the tag, which works, but some XML I look back are large enough (number of records), so that cause problems in itself. I would rather deal with it and don't mess with the XML itself if possible.

    Any help would be much appreciated!

    Thank you much in advance.

    Robin

    Published by: User_resU on April 12, 2012 14:50

    The element of report and its children belong to a default namespace.
    You have stated that in the request too:

    xmltable
    (
    xmlnamespaces('Items_x0020_status_x0020_information' as "ns0"),
    '/result/return/ns0:Report/ns0:Tablix1/ns0:Details_Collection/ns0:Details'
       passing
    
  • Fetch returns multiple rows

    Hello
    I have the following table:
    ID number, not null, unique
    fname varchar2(50),not null
    lname varchar2(50), not null
    email varchar2(200)not null, unique
    and the following procedure that queries the table:
    declare
    name varchar2(100);
    email varchar2(500);
    stmt varchar2(4000);
    nbr number;
    begin
    name:=substr('sam wilkins:[email protected]',1,(instr('sam wilkins:[email protected]',':')-1));
    email:=substr('sam wilkins:[email protected]',(instr('sam wilkins:[email protected]',':')+1));
    stmt:='select id from tbl where '
          || 'fname ||'' ''||'
          || 'lname='|| ''''||lower(name)||''''||' and email='||''''||lower(email)||''''||'';
    execute immediate stmt into nbr;
    select id into nbr from tbl where fname||' '||lname = name and email = email;
    dbms_output.put_line(stmt);
    dbms_output.put_line(nbr);
    end;
    When I run the procedure with just the immediate execution, the query returns a single id, but when I use select it in, I get the error "Fetch returns more rows". Why is this?

    Thank you.

    Hello

    natet wrote:
    Hello
    I have the following table:

    ID number, not null, unique
    fname varchar2(50),not null
    lname varchar2(50), not null
    email varchar2(200)not null, unique
    

    and the following procedure that queries the table:

    declare
    name varchar2(100);
    email varchar2(500);
    stmt varchar2(4000);
    nbr number;
    begin
    name:=substr('sam wilkins:[email protected]',1,(instr('sam wilkins:[email protected]',':')-1));
    email:=substr('sam wilkins:[email protected]',(instr('sam wilkins:[email protected]',':')+1));
    stmt:='select id from tbl where '
    || 'fname ||'' ''||'
    || 'lname='|| ''''||lower(name)||''''||' and email='||''''||lower(email)||''''||'';
    execute immediate stmt into nbr;
    select id into nbr from tbl where fname||' '||lname = name and email = email;
    dbms_output.put_line(stmt);
    dbms_output.put_line(nbr);
    end;
    

    When I run the procedure with just the immediate execution, the query returns a single id, but when I use select it in, I get the error "Fetch returns more rows". Why is this?

    Thank you.

    Give your local variable names that can be confused for column names.

    In this statement:

    select  id
    into      nbr
    from      tbl
    where      fname ||' '|| lname     = name
    and      email                      = email;
    

    e-mail (in two places) refers to the column in the table. Probably, you want to use the local variable in place of one of them.

  • Update returns multiple rows

    Basically, I have two tables:

    We have CUS_NO, AS_OF_DATE, AVG_AMT, CLOSING_BALANCE and DATE_JOINED
    In this table, AVG_AMT is empty

    Second table has CUS_NO, AS_OF_DATE and AVG_AMT

    The average amt can be + ve - ve or both.

    I do an update like this:

    Update table1 set AVG_AMT = (select AVG_AMT from table2 where table1. CUS_NO = table2. CUS_NO)

    With this, I get the error "single subquery returns more rows" which is just, because some customers have two EV - and + ve AVG_AMT

    How would you advise me to tackle this problem?
    For example: If Table1
    CUS_NO DATE_JOINED CLOSING_BALANCE AS_OF_DATE AVG_AMT
    123 10/10/09 12345 10/10/09 < NULL >

    and the table2

    CUS_NO AS_OF_DATE AVG_AMT
    123 10/10/09 2000
    123-10/10/09-400


    The end result should be

    CUS_NO DATE_JOINED CLOSING_BALANCE AS_OF_DATE AVG_AMT
    123 10/10/09 12345 10 / 10 / 0 2000
    123 10/10/09 12345 10/10/09-400

    Double Post.

    Kind regards.

    LOULOU.

    Published by: Satyaki_De on November 19, 2009 17:35

  • subquery returns no row in the main query, but hard returns the value of the master query

    Oracle 11g, Solaris SPARC 64-bit:

    This is the master query: its not to return all the lines

    Select count (*) in the sadmin.usr_mods where to_char (ts_id) in ((select to_char (rtrim (ltrim(TS_MODULES,','), ',')) in the sadmin.usr_rfc where TS_KINTANA_PACKAGE_NUMBER = '123' and ts_projectid = 3));

    COUNT (*)

    ----------

    0

    But wherever if I use subquery only returns he lines:

    SQL > select rtrim (ltrim(TS_MODULES,','), ',') from the sadmin.usr_rfc where TS_KINTANA_PACKAGE_NUMBER = '123' and ts_projectid = 3;

    RTRIM (LTRIM(TS_MODULES,','), ',')

    --------------------------------------------------------------------------------

    49,54

    If I use these values as hardcoded to a select master it will return 2 rows:

    SQL > select count (*) in the sadmin.usr_mods where to_char (ts_id) in ('49 ', ' 54');

    COUNT (*)

    ----------

    2

    TS_MODULES datatype is CLOB

    TS_ID datatype is set to number

    Help, please

    with

    usr_rfc as

    (select 3 ts_projectid, 123 ts_kintana_package_number, to_clob(',49,54,') ts_modules

    of the double

    ),

    usr_mods as

    (select ts_id 49 Union double all the)

    Select 50 in all double union

    Select double 54

    )

    Select count (*)

    of usr_mods

    where to_char (ts_id) in (select regexp_substr (to_char (rtrim (ltrim(TS_MODULES,','), ',')),'[^,] +', 1, level))

    of usr_rfc

    where TS_KINTANA_PACKAGE_NUMBER = '123'

    and ts_projectid = 3

    connect by level<= regexp_count(to_char(rtrim(ltrim(ts_modules,','),',')),',')="" +="">

    )

    COUNT (*)
    2

    Concerning

    Etbin

    Select count (*)

    of usr_mods

    where instr ((select ',' | to_char (rtrim (ltrim(TS_MODULES,','), ',')) |)) ','

    of usr_rfc

    where TS_KINTANA_PACKAGE_NUMBER = '123'

    and ts_projectid = 3

    ),

    ',' || TO_CHAR (TS_ID) | ','

    ) > 0

  • single line sub query returns multiple rows

    Hi, please help me to solve this, working with oracle 11g.


    Update t1 set t1.twyindex = twypoly (select twyindex from twyinfo where t1.id = t2.id t2);

    the error message is:
    *
    ERROR on line 1:
    ORA-01427: einreihig subquery returns multiple rows

    Thank you

    don123 wrote:
    Hi paul, thanks...

    duplicate existing due to the business logic data.

    can I use the SQL mentioned above for all cases?

    is it mandatory to remove duplicates?

    Please provide your suggestions...

    If the company says duplicates are allowed, you have to ask the person who wants what, of the different twyindexes, that they want to use
    updating twyinfo table...

    I use the SQL proposed until they tell you that twyindex to use.

  • query by returning no rows

    Hi all
    This query returns all rows, but ideally it should.below I enclose the query
    select * FROM SERIAL_NO WHERE  serialno not in (SELECT SERIALNO FROM COB_T_SERIAL_NO
                                                                                union select serialno from genealogy
                                                                                union select lastarchivedby from genealogy
                                                                                union select serialno from asset
                                                                                union select serialno from code_serial_number
                                                                                union select serialno from cost
                                                                                union select serialno from cost_detail
                                                                                union select serialno from disposition
                                                                                union select serialno from disposition_content
                                                                                union select serialno from disposition_line
                                                                                union select serialno from disposition_test_reason
                                                                                union select serialno from inventory_count_serial_no
                                                                                union select serialno from inventory_serial_no
                                                                                union select serialno from inventory_serial_transit
                                                                                union select serialno from material_order_serial_no
                                                                                union select serialno from material_content_serial_no
                                                                                union select serialno from resource_content
                                                                                union select serialno from receipt_container_serial_no
                                                                                union select serialno from resource_serial_no
                                                                                union select serialno from sequence_queue_item
                                                                                union select serialno from serial_no_hold
                                                                                 union select serialno from wip_order_content_serial
                                                                                 union select serialno from wip_serial_no
                                                                                 union select serialno from wip_serial_no_content
                                                                                 union
                                                                                 select a.serialno from resource_labor_detail a  inner join resource_labor_detail_approval b on b.resourcelabordetailid=a.id
                                                                                  union
                                                                                  select c.serialno from labor_detail c inner join labor_detail_approval d on d.labordetailid = c.id
                                                                                   union 
                                                                                   select e.serialno from disposition_reading e  inner join disposition_resource f on f.dispositionreadingid = e.id                              
                                                                                   union select g.serialno from quality_defect g 
                                                                                    inner join   quality_defect_location h on h.qualitydefectid=g.id 
                                                                                    inner join quality_defect_loc_dimension i on i.qualitydefectlocationid=h.id )                          
                                                                                    
                                                                                                                 
                                                                                                                 

    Hello

    964145 wrote:
    right... I understand that it is difficult for you to help without data... it is syntactically correct?

    Yes, the syntax is very well. The fact that it runs (no matter how many rows it returns, if any) tells you that there is no syntax error.

    also, I want only distinct values, so I used the union rather than union all the

    Why do you want only the distinct values? The reulsts will be the same if there are duplicates or not.

    can I use like this? Please suggest

    with union_data as (SELECT SERIALNO FROM COB_T_SERIAL_NO
    union select serialno from genealogy
    ...
    inner join quality_defect_loc_dimension i on i.qualitydefectlocationid=h.id )           
    
    DELETE serial_no where serialno not in  (SELECT  serialno
    FROM    union_data
    WHERE   serialno    IS NOT NULL
    ) ;
    

    What happens when try you it?

    A query can start with the keyword WITH.
    A DELETE statement cannot.
    You can do soemthing like this:

    DELETE  serial_no
    WHERE     serialno   NOT IN  (
                                 WITH    union_data   AS
                          (
                              SELECT  serialno   FROM  cob_t_serial_no   UNION
                           SELECT  serialno   FROM  genealogy            UNION ...
                          )
                                 SELECT  serialno
                                  FROM    union_data
                                  WHERE   serialno    IS NOT NULL
                               ) ;
    

    Published by: Frank Kulash, November 12, 2012 16:22

  • Calling a database procedure which returns the array as output parameters

    Hello


    I wanted to call a procedure that returns "T_Disponibilidad_Diaria".

    Type T_Disponibilidad_Diaria is Table of the R_Disponibilidad_Diaria
    INDEX OF DIRECTORY;


    Type R_Disponibilidad_Diaria is {Record

    }

    Please suggest me the best way to convert this type of array complex java object
    Thanks in advance


    Concerning
    Vidya

    But what you can do...

    Try to create a new stored procedure, which returns the type of the database object.
    In this procedure, you can call the original procedure.
    Take what it returns and make the type object. That's what you need to retrieve your procedure ;-) (.. .huh?)

  • Oracle Text multi column index based query returns no rows

    Hello

    I have a MAH_KERESES_MV table with 3 columns OBJEKTUM_NEV, KERESES_SZOVEG_1, KERESES_SZOVEG_2. I create the following Oracle multi column text index:

    ctx_ddl.create_preference exec ('MAH_SEARCH', 'MULTI_COLUMN_DATASTORE');
    ctx_ddl.set_attribute exec ('MAH_SEARCH', 'COLUMNS', 'OBJEKTUM_NEV, KERESES_SZOVEG_1, KERESES_SZOVEG_2');

    create index MAX_KERES_CTX on MAH_KERESES_MV (OBJEKTUM_NEV)
    indexType is ctxsys.context
    parameters ("DATASTORE MAH_SEARCH");
    But the query returns no rows, although if I make the query with the 'like' operator, and then I get the results as expected:

    SELECT id, OBJEKTUM_NEV
    OF MAH_KERESES_MV
    WHERE CONTAINS (OBJEKTUM_NEV, "C") > 0;

    Can some body please help? TIA,

    Tamas

    You can do it in Oracle Text, well it is not necessarily desirable.

    You can search the

    WHERE CONTAINS(OBJEKTUM_NEV, '%C%')>0;
    

    And it will probably work in a simple test. However, using a leader like this wildcard prevents them the index on the table "list of words" used, so such a request can be very slow on a large system.
    You can improve this by using SUBSTRING_INDEX, but making your much bigger index. And you could always hit the 'expansions too' problem if %C % expansion is more than about 15,000 words (depending on version and different settings).

    Also be aware of differences in case - %C % will match 'fact' or 'FACT', as part of a CONTAINS, but not part of a TYPE.

  • Max returns two rows

    select BOND_SCHED_ID,bond_id,earnings_proceeds,max(s.effective_date) as effective_date
    from XXDL.xxdl_cd_bond_schedk_p2b  s
    Group by BOND_SCHED_ID,bond_id,earnings_proceeds
    Table has two rows it returns two rows. I need to have a single folder
    Actual
    
    10020     7     200     01-FEB-11
    10000     7     100     01-JAN-11
    
    Expected
    10020     7     200     01-FEB-11
    What is the best application I can write

    893185 wrote:

    Table has two rows it returns two rows. I need to have a single folder

    According to what criteria? I'll assume last effective_date for the connection id. If so:

    select  bond_sched_id,
            bond_id,
            effective_date
      from  (
             select  s.*,
                     row_number() over(partition by bond_id order by effective_date desc) rn
               from  XXDL.xxdl_cd_bond_schedk_p2b s
            )
      where rn = 1
    /
    

    SY.

  • ORA-01422 exactly fetch returned more rows than expected

    Hi all

    Some1 can you please suggest what is the difference between "ORA-01422 exactly fetch returned more rows than expected" and too many errors of lines.

    Concerning
    Arpit

    TOO_MANY_ROWS is a predefined exception that allows to capture the ORA-01422. It simply means that we don't need to declare our own exception to cope.

    SQL> DECLARE
      2
      3      lv_Dummy        dual.dummy%TYPE;
      4
      5  BEGIN
      6
      7      SELECT
      8          dummy
      9      INTO
     10          lv_Dummy
     11      FROM
     12          (   SELECT dummy FROM DUAL UNION ALL
     13              SELECT dummy FROM DUAL
     14          );
     15  END;
     16  /
    DECLARE
    *
    ERROR at line 1:
    ORA-01422: exact fetch returns more than requested number of rows
    ORA-06512: at line 7
    
    SQL> set serveroutput on
    SQL> DECLARE
      2
      3      lv_Dummy        dual.dummy%TYPE;
      4
      5  BEGIN
      6
      7      SELECT
      8          dummy
      9      INTO
     10          lv_Dummy
     11      FROM
     12          (   SELECT dummy FROM DUAL UNION ALL
     13              SELECT dummy FROM DUAL
     14          );
     15  EXCEPTION
     16      WHEN TOO_MANY_ROWS THEN
     17          dbms_output.put_line('TOO_MANY_ROWS is built in exception to allow us to capture ORA-01422');
     18
     19  END;
     20  /
    TOO_MANY_ROWS is built in exception to allow us to capture ORA-01422
    
    PL/SQL procedure successfully completed.
    
    SQL> DECLARE
      2
      3      lv_Dummy        dual.dummy%TYPE;
      4      lex_TooManyRows EXCEPTION;
      5
      6      PRAGMA EXCEPTION_INIT(lex_TooManyRows, -1422);
      7  BEGIN
      8
      9      SELECT
     10          dummy
     11      INTO
     12          lv_Dummy
     13      FROM
     14          (   SELECT dummy FROM DUAL UNION ALL
     15              SELECT dummy FROM DUAL
     16          );
     17  EXCEPTION
     18      WHEN lex_TooManyRows THEN
     19          dbms_output.put_line('lex_TooManyRows is our exception to allow us to capture ORA-01422');
     20
     21  END;
     22  /
    lex_TooManyRows is our exception to allow us to capture ORA-01422
    
    PL/SQL procedure successfully completed.
    

    HTH

    David

Maybe you are looking for