Return two queries with cfreturn

Hello All,
I know I've seen it done somewhere, but I can't seem to find
the example. I need to return two queries like:
<cfreturn getCurrentProjects and
getProjectRequestByStatus/>
Something like that... not getting the right syntax or
something. Any clues?
Thanks!

You can't!!!! You can only return one value with
<cfreturn...>
But of course there is nothing preventing that one value to
be a
structure or array contain two query record sets.
I.E.
<cfset var myReturn = strunctNew()>
<cfset myReturn.getCurrentProjects =
getCurrentProjects>
<!--- getCurrentProjects is scoped as a local variable
with VAR,
correct? --->
<cfset myReturn.getProjectRequestByStatus =
getProjectRequestByStatus>
<!--- getProjectRequest is scoped as a local variable with
Var, correct?--->
<cfreturn myReturn>

Similar Messages

  • Joining two queries with Visual Composer

    Hallo,
    I was working with visual composer to join two queries with the distinct operator. But on my table view, when i linked it with the distinct operator, i get only the key element customer (customer, customer_ext_key, customer_key). These are the queries that i want join:
    Query 1:
    Customer
    Net Sales
    Query 2:
    Customer
    Billed Quantity
    What i want to see is the following result:
    Customer
    Net Sales
    Billed Quantity
    Can anybody help me with this problem?
    Greeting,
    Murat.

    Hallo,
    I was working with visual composer to join two queries with the distinct operator. But on my table view, when i linked it with the distinct operator, i get only the key element customer (customer, customer_ext_key, customer_key). These are the queries that i want join:
    Query 1:
    Customer
    Net Sales
    Query 2:
    Customer
    Billed Quantity
    What i want to see is the following result:
    Customer
    Net Sales
    Billed Quantity
    Can anybody help me with this problem?
    Greeting,
    Murat.

  • Returning two rows with one column containing only one place

    Dear all;
    I have a query that returns two rows similar to this below
    ID      PLACE            PROGRAM
    A       NEWYORK      PROGRAM A
    A       NEWYORK      PROGRAM B
    I would like this instead
    ID      PLACE             PROGRAM
    A       NEWYORK       PROGRAM A
                                   PROGRAM  B
    All help is appreciated. Thank you.Edited by: user13328581 on Mar 22, 2011 11:52 AM

    user13328581 wrote:
    WOW...THanks a lot Solomon, I have never used partitions and row_number in such a manner...can you please explain your logic.Sure:
    row_number() over(partition by id order by place,program)This will take all rows returned by the query andsplit them into buckets (partitions) by id. Inside each bucket it will order rows by place and program and assign them row numbers. So for each ID row number 1 will be row with first (alphabetically) place first programt. And this is the row where we want ID to show up. That is why we wrap the above analytic function in CASE statement which will do exactly that. Now:
    row_number() over(partition by id,place order by program)does pretty much the same just bucket is ID and PLACE combination. So for each such combination we want to show only for the first (alphabetically) programt.
    Now notice in ORDER BY clause I prefix ID and PLACE with table alias. You must do it since otherwise query alias ID and PLACE will take precedence resulting in wrong sort order (remember we nulled all ID and PLACE except for row number 1).
    SY.

  • Comparing two queries with VBA macro

    Hi,
    I have a workbook woth 2 sheets. Every sheet has a BEx query (so 2 queries).
    I need, for every column in the first query, to check if it is present in the second query, to generate a list with the NOT PRESENT values (or simply, marking the not present values).
    I tried with Searching excel functions by column, but every query hs more that 30.000 rows, so it takes a long time.
    I think I have to use an excel macro. I have been lookong for in the forum but my doubt is that I have to execute when the two queries has been refreshed.
    How can I know when the two queries has been refreshed?
    Is there any other way to do it?
    Any idea of how to reference a query from the other?
    I think the code shoud be in this way:
    for every row in the first colum of 1st query
    look in every row in the first column of 2nd query
    mark in first query if not present.
    If I put the macro in 1st query, how can I reference the 2nd one?

    Hi Oscar, there are several ways to do this.
    The easiest way would be:
    1.  in the SAPBEXonRefresh subroutine (which you will find in the SAPBEX Module attached to your query-containing workbook), add code that looks something like this:
    Set ws = resultArea.parent
    if ws is nothing then exit sub
    resultArea.name = ws.codename & "_results"
    ws.Range("D2") = Date
    if queryID = "SAPBEXq0002" then Call CompareQueries(queryID)
    'make the query ID that of the second query
    This will create named ranges in Excel so that you can easily locate the result tables later.  And, ensure that you know the date that each query was refreshed.  And, after the second query is refreshed, it will call your query comparison routine.
    2.  In the comparison routine, you will need something like this:
    set ws1 = Query1 'assuming that you have set the code name of the first query sheet as Query1
    set ws2 = Query2 'assuming that you have set the code name of the second query sheet as Query2
    'set ranges for the two result tables
    set Range1 = ws1.codename & "_results"
    set Range2 = ws2.codename & "_results"
    'locate first and last Row and Column for result tables
    firstRow1 = Range1.cells(1).row
    firstCol1 = Range1.cells(1).column
    numCells = Range1.cells.count
    lastRow1 = Range1.cells(numCells).row
    lastCol1 = Range1.cells(numCells).column
    'do same for Range2
    'locate the columns you want to compare
    searchCol = 0
    for j = firstCol1 to lastCol1
        if cells(firstRow1, j) like "some text here" then
            searchCol = j
            exit for
        end if
    next j
    if searchCol = 0 then
        msgbox "Did not find ""some text here"".", vbCritical
        exit sub
    Else:
        set SearchRange = ws1.cells(1, searchCol).entireColumn
    end if
    for j = firstCol2 to lastCol2
        if cells(firstRow2, j) like "some text here" then
            searchCol = j
            exit for
        end if
    next j
    'do the search
    for i = firstRow2 to lastRow2
        searchFor = cells(i, searchCol)
        matchRow = 0
        on error resume next
        matchRow = Application.worksheetfunction.match(searchFor, SearchRange, 0)
        if matchRow > 0 then
            cells(i, lastCol2+1) = "match found on row " & matchRow
        Else:
            cells(i, lastCol2+1) = "NOT PRESENT"
        End if
    next i
    - Pete

  • 0PA_C01  different results from two queries on the same cube ....

    HI
    Can you please help with this  problems ...
    i am running a two queries with the same restrictions e.g
    Sep 08 for employee 22345 ,
    In one report it shows the Pay Scale level as A1 , then in the other report it shows Pay scale Scale level as A2  ,
    looking  at the master data in 0employee  , the first report is right ... this is how the data looks like in 0employee
    Employee  Valid from      To                Pay scale Level
    222345       2007-11-03   2008-09-30     A1
    222345       2008-10-01   9999-12-31     A2
    Can someone please shed some light on this , im thinking it has something to do with update rule but even that is supposed to use last date of the month , not 1st day of the following month. The Cube is a stndard cube 0PA_C01 and the update rule aswell .....

    Hi,
    Please check in the cube whether the data for the Employee is getting with two values like shown in your question:
    Employee Valid from To Pay scale Level
    222345 2007-11-03 2008-09-30 A1
    222345 2008-10-01 9999-12-31 A2
    and also check whether when the data loaded to the cube.
    There may be some change in the report structure where the difference is getting may in the column wise or row wise restriction may present.
    Please check on the structure of the report also.
    With Regards,
    Ravi Kanth

  • 2 queries with same technical name

    Hi,
    I have just opened this <b>QA</b> system. I find that there are two queries with the same technical name. The query definition is also the same. But it shows twice when I search for them.
    I thought the system only allows a single technical name to be created once.
    Please help me understand how this may have happned? And also how I can delete one of them without effecting the web templates and workbooks where this query is used.
    Thanks
    NEWBW

    You can use the ABAP Program RENAME_DUPLICATE_ELEMENTS to rename the duplicate queries.
    The system tracks query objects using the 25 char UID and not the technical name of the query. In some cases you will end up with 2 queries with the same technical name usually with transports from multiple systems.
    You can also use the report ANALYZE_RSZ_TABLES to proactiveley analyze these kinds of issues in the system.
    Thanks

  • How to delete queries with identical technical name in BEx

    Hi everyone,
    How do I delete query which is assigned to Roles in BEx.The problem is that there are two queries with the same technical name. And both queries are assigned to the same Role.Can anyone help me out in deleting both those queries.
    Thanks in advance.
    Regards,
    Jayasree.

    Hi,
    When you do Changes in Dev and do the Transporting to Production, the Same Query which is already exist in Production is not overwritten. For that reason Queries will show as two. Check the note: 541024.
    Check with your Basis team also.
    You have to identify the UID Component of that Particular Query, which want to delete in production. Check the Queries as Date wise, you will find.
    Delete these by using RSZDELETE tcode with UID Component of that particular Query in Production.
    Let us know if you still have any issues.
    Reg
    Pra

  • Report with Two Queries -- Really need your Help Guys

    I might be posting duplicate thread but i couldnt found the Q&A that i am looking for.
    I am trying to create a report where i have to use two query. Also, with this query i am passing parameter where i ask user to enter Report Month so they can run report by what ever month they want to see data.
    Now my Q_2 is duplicate or Q_1 because in my final report layout i have to display fields where i have to compare current_month_data to Previous_month_data. so basically i want user to in put current month date and previous month date and layout look like.
    Company_Name Currentmonth_sale previousMonth_Sales ....
    Honda $1423.42 $324.42
    Toyota $3433 $4255.45
    so on....
    Now so far i create report manualy and drop two query in to the report but when i trying to create Report Wizard and group by each Company.. it is not giving me the out put that i want. Instead of giving me above out put its give me my Q_! result with each company group and then under that result i have Q_2 result.
    so HOW CAN I DISPLAY FIELDS FROM MY Q_2 WITH MY REST OF THE FIELD ON Q_1?????????????????????????
    Thank You guys.

    Actually, I tried to use Data Link but i am not able to success.
    Let me know if I am doing anything wrong . i click on left hand side tool panel where its says DATA LINK. then i click on Q_1 field and then drag the mouse over to Q_2 query with same field name. but its give me an error that Can not link it because of Group data and i have option to choose Yes, NO or Cancel.
    Let me know what are the step i need to take in order to link this two queries.
    Thank You
    keyun

  • Issue with IN parameter of Oracle Procedure returning two RefCursors...

    Hi all,
    I'm having a nightmare with an Oracle procedure that takes one input parameter and returns two RefCursors as outputs. I recently got help in this forum getting a procedure to work that took no inputs but returned two refcursors and that's still working fine. So, for my current issue I have a procedure defined as follows:
    PROCEDURE getQueueInfo(domainKey char, importQueues OUT ODPNet.refcur, exportQueues OUT ODPNet.refcur) IS
      BEGIN
        OPEN importQueues FOR SELECT
        source_key, source_applid,
        import_status(source_key) as status,
        time_added, time_processed
        FROM wm_import_source_header
        WHERE source_id = domainKey
        ORDER BY source_key DESC;
        OPEN exportQueues FOR SELECT
        h.source_key, d.source_applid,
        export_status(h.source_key) as status,
        d.source_wire_code, d.destination_wire_code, h.time_added,
        h.time_transmitted
        FROM wm_export_source_header h, wm_export_source_data d
        WHERE h.source_key = d.source_key
          and d.source_id = domainKey
        ORDER BY h.source_key DESC;
      END getQueueInfo;This is defined within a package called ODPNet as with my previous procedure and all works fine (I can execute within Oracle SQL Developer and it returns the expected results). Within my .NET application my code is as follows:
                try
                    using (OracleConnection conn = new OracleConnection(connString))
                    using (OracleCommand comm = new OracleCommand())
                        comm.CommandText = "ODPNet.getQueueInfo";
                        comm.CommandType = CommandType.StoredProcedure;
                        comm.Connection = conn;
                        OracleParameter domainKey = new OracleParameter();
                        OracleParameter importQueues = new OracleParameter();
                        OracleParameter exportQueues = new OracleParameter();
                        domainKey.OracleDbType = OracleDbType.Char;
                        importQueues.OracleDbType = OracleDbType.RefCursor;
                        exportQueues.OracleDbType = OracleDbType.RefCursor;
                        domainKey.Value = "UKBD72";
                        domainKey.Direction = ParameterDirection.Input;
                        importQueues.Direction = ParameterDirection.Output;
                        exportQueues.Direction = ParameterDirection.Output;
                        comm.Parameters.Add(domainKey);
                        comm.Parameters.Add(importQueues);
                        comm.Parameters.Add(exportQueues);
                        conn.Open();
                        comm.ExecuteNonQuery();
                        OracleDataReader dr1 = ((OracleRefCursor)importQueues.Value).GetDataReader();
                        OracleDataReader dr2 = ((OracleRefCursor)exportQueues.Value).GetDataReader();
                        if (dr1.HasRows)
                            while (dr1.Read())
                                result6 += dr1["source_applid"].ToString() + "<br>";
                        else
                            result6 += "No Rows";
                        if (dr2.HasRows)
                            while (dr2.Read())
                                result7 += dr2["source_applid"].ToString() + "<br>";
                        else
                            result7 += "No Rows";
                catch (Exception ex)
                    result6 = ex.ToString();
                }The value I want to submit as the IN parameter of the procedure is "UKBD72". but I'm really not sure how to apply this and then return my two refcursors into separate datareaders (except for the input parameter stuff the code above is exactly what I did with the other procedure that returned two ref cursors and still works fine). When I run this code I get no errors, I just get told that each DataReader has no rows returned, which shouldn't be right.
    Any help with this would be hugely appreciated.
    Cheers,
    Seb

    Sorry folks, after staring at this over and over, eventually going to sleep and coming back to it with some fresh eyes I realised I was just being a complete idiot - I was feeding the procedure different data in the .NET app than I was when testing in Oracle SQL Developer. Low and behold once I gave it the right data it worked!
    Silly me...

  • Two methods with same name but different return type?

    Can I have two methods with same name but different return type in Java? I used to do this in C++ (method overloading or function overloading)
    Here is my code:
    import java.io.*;
    public class Test{
    public static void main(String ar[]){
    try{          
    //I give an invalid file name to throw IO error.
    File file = new File("c:/invalid file name becasue of spaces");
    FileWriter writer = new FileWriter(file ,true);
    writer.write("Test");
    writer.close();     
    } catch (IOException IOe){
         System.out.println("Failure");
    //call first method - displays stack trace on screen
         showerr(NPe);
    //call second method - returns stack trace as string
            String msg = showerr(NPe);
            System.out.println(msg);
    } // end of main
    public static void showerr(Exception e){
         StringWriter sw = new StringWriter();
         PrintWriter pw = new PrintWriter(sw);
         e.printStackTrace(pw);
         try{
         pw.close();
         sw.close();
         catch (IOException IOe){
         IOe.printStackTrace();     
         String stackTrace = sw.toString();
         System.out.println("Null Ptr\n" +  stackTrace );
    }//end of first showerr
    public static String showerr(Exception e){
         StringWriter sw = new StringWriter();
         PrintWriter pw = new PrintWriter(sw);
         e.printStackTrace(pw);
         try{
         pw.close();
         sw.close();
         catch (IOException IOe){
         IOe.printStackTrace();     
         return sw.toString();
    }//end of second showerr
    } // end of class
    [\code]

    Overloading is when you have multiple methods that have the same name and the same return type but take different parameters. See example
    public class Overloader {
         public String buildError(Exception e){
              java.util.Date now = new java.util.Date() ;
              java.text.DateFormat format = java.text.DateFormat.getInstance() ;
              StringBuffer buffer = new StringBuffer() ;
              buffer.append(format.format(now))
                   .append( " : " )
                   .append( e.getClass().getName() )
                   .append( " : " )
                   .append( e.getMessage() ) ;
              return buffer.toString() ;
         public String buildError(String msg){
              java.util.Date now = new java.util.Date() ;
              java.text.DateFormat format = java.text.DateFormat.getInstance() ;
              StringBuffer buffer = new StringBuffer() ;
              buffer.append(format.format(now))
                   .append( " : " )
                   .append( msg ) ;
              return buffer.toString() ;
         public String buildErrors(int errCount){
              java.util.Date now = new java.util.Date() ;
              java.text.DateFormat format = java.text.DateFormat.getInstance() ;
              StringBuffer buffer = new StringBuffer() ;
              buffer.append(format.format(now))
                   .append( " : " )
                   .append( "There have been " )
                   .append( errCount )
                   .append( " errors encountered.")  ;
              return buffer.toString() ;
    }Make sense ???
    Regards,

  • These two queries return same data?

    select * from voucher where (unit = 'TIA4M' or unit = 'TIAFM' or unit = 'TIAWM' or unit = 'TIATW' or unit = 'TIAPA' )
    and invoice_dt >= TO_DATE('01/01/2006', 'MM/DD/YYYY')
    select * from voucher where unit in ('TIA4M', 'TIAFM', 'TIAWM', 'TIATW', 'TIAPA')
    and invoice_dt >= TO_DATE('01/01/2007', 'MM/DD/YYYY')
    Also the first is much faster right?

    The first query is using a date of Jan 1, 2006. The second query is using a date of Jan 1, 2007.
    Assuming that is a typo, the two queries are semantically identical. Since Oracle can easily transform an IN-list to a series of OR's, though, I would doubt that there would be any performance difference between them absent the 2006/2007 change.
    Justin

  • Confused on syntax-combine two queries

    I have two queries that I'm trying to combine, but can't figure out how to combine them ... successfully!?! The first query is pretty simple in that I'm looking at several fields from two different tables, no big deal.
    The second query calculates the years, months, days between two dates that are used in the first query. I'm stumped on how to combine the queries so that they place nice with each other and return results.
    Here's the first query ...
    select
    RTRIM(RTRIM(vpi.LastName) + ', ' + RTRIM(ISNULL(vpi.FirstName,''))) Employee,
    convert(varchar,vpi.FromEffectiveDate,101) PositionStart,      
    convert(varchar,vpi.ToEffectiveDate,101) PositionChange,
    convert(varchar,vpi.PositionStartDate,101) PositionStartDate,
    vpi.PositionReason, vpi.PositionCode, vpc.PositionCodeDescription
    from vhrl_positioninfo vpi
    inner join position_codes vpc on vpi.PositionCode = vpc.PositionCode
    Here's the second query ...
    select
    [Age] = convert(varchar, [Years]) + ' Years ' +
              convert(varchar, [Months]) + ' Months ' +
              convert(varchar, [Days]) + ' Days',     *
    from
         select
              [Years] = case     when BirthDayThisYear <= Today
                        then datediff(year, BirthYearStart, CurrYearStart)
                        else datediff(year, BirthYearStart, CurrYearStart) - 1
                        end,
              [Months]= case     when BirthDayThisYear <= Today
                        then datediff(month, BirthDayThisYear, Today)
                        else datediff(month, BirthDayThisYear, Today) + 12
                        end,
              [Days]= case     when BirthDayThisMonth <= Today
                        then datediff(day, BirthDayThisMonth, Today)
                        else datediff(day, dateadd(month, -1, BirthDayThisMonth), Today)
                        end,
              Birth = convert(varchar(10) ,Birth, 121),
              Today = convert(varchar(10), Today, 121)
         from
              select     BirthDayThisYear =
                   case     when     day(dateadd(year, datediff(year, BirthYearStart, CurrYearStart), Birth)) <> day(Birth)
                        then     dateadd(day, 1, dateadd(year, datediff(year, BirthYearStart, CurrYearStart), Birth))
                        else     dateadd(year, datediff(year, BirthYearStart, CurrYearStart), Birth)
                        end,
                   BirthDayThisMonth =
                   case      when      day(dateadd(month, datediff(month, BirthMonthStart, CurrMonthStart), Birth)) <> day(Birth)
                        then     dateadd(day, 1, dateadd(month, datediff(month, BirthMonthStart, CurrMonthStart), Birth))
                        else     dateadd(month, datediff(month, BirthMonthStart, CurrMonthStart), Birth)
                        end,
              from
                   select     BirthYearStart = dateadd(year, datediff(year, 0, Birth), 0),
                        CurrYearStart = dateadd(year, datediff(year, 0, Today), 0),
                        BirthMonthStart = dateadd(month, datediff(month, 0, Birth), 0),
                        CurrMonthStart = dateadd(month, datediff(month, 0, Today), 0),
                   from          
                        select birth = convert(datetime, fromeffectivedate) ,
                        Today = case when convert(datetime, toeffectivedate) = '3000-01-01'
                                       THEN convert(datetime, convert(int,getdate()))
    else vpi.toeffectivedate
    end
         from vHRL_PositionInfo vpi inner join position_codes vpc
                        on vpi.PositionCode = vpc.PositionCode
                   ) aaaa
              ) aaa
         ) aa
    )a
    Here's the sample data ...
    vpi table ...
    LastName FirstName FromEffectDate ToEffectDate PosStartDate PosReason PosCode
    Doe John 2001-10-15 3000-01-01 10-15-2001 Transfer OperPack
    Smith Tom 1994-11-28 2001-10-14 1994-11-28 New Hire OperDC
    vpc table ...
    PosCode PosDescription
    OperPack Pack Line Operator
    OperDC Descaler Operator
    This is what the results should look like ...
    John, Doe 2001-10-15 3000-01-01 10-15-2001 Transfer OperPack Pack Line Operator 6 Years 11 Months 16 Days
    John, Doe 1994-11-28 2001-10-14 1994-11-28 New Hire OperDC Descaler Operator 6 Years 6 Months 19 Days
    I know the date calculation piece adds 5 additional fields to the end, but they are not needed for the final report. Any help would be greatly appreciated! Thank you! Jena

    Your query suggests you're not using Oracle. Please post in your relevant database forum.

  • Why are two queries better than one

    I'm trying to help out our developers who are struggling with the performance of a very simple select statmenent that for some reason is exhibiting some very inexplicable results.
    I'll show the SQL as a single statement first.....
    select * from transaction1 t where t.hid in (select distinct h.hid from history1 h,filter1 f where h.fid = f.fid and f.match='value');
    transaction 1 has 250k records, history1 has about 100k as does filter1. We know generally the subselect will only return a total of half a dozen or less records (only 1 in our testing here).
    Running the above query takes around 7 seconds.
    Changing this to a with clause.....
    WITH a as (select distinct h.hid from history1 h,filter1 f where h.fid = f.fid and f.match='value') select * from transaction1 t where t,hid in (select a.hid from a);
    and the runtime drops to 3 seconds. But then re-running the first statement again also now takes 3 seconds (so I guess there's some caching going on there).
    Now what really puzzles is if we split this into two queries.....
    select distinct h.hid from history1 h,filter1 f where h.fid = f.fid and f.match='value';
    This takes .1 of a second,
    select * from transaction1 t where t.hid in (12345);
    And this takes .1 of a second.
    So why when run seperately are they so fast, yet combined they take so long. I'm a bit baffled by this. We've rewritten the same SQL in half a dozen different ways with the same result and also done the same thing with other tables as well. Is it an optimisation issue?

    Appologies for not following protocol, my first time posting on here.
    Oracle 10g clustered.
    We have limited access as it's a customers server, but the explain plan comes back as....
    PLAN_TABLE_OUTPUT
    Plan hash value: 898894568
    | Id  | Operation            | Name              | Rows  | Bytes | Cost (%CPU)|Time     |
    PLAN_TABLE_OUTPUT
    |   0 | SELECT STATEMENT     |                   | 49553 |    37M|  7075   (2)|00:01:25 |
    |*  1 |  HASH JOIN RIGHT SEMI|                   | 49553 |    37M|  7075   (2)|00:01:25 |
    |   2 |   VIEW               | VW_NSO_1          | 26131 |   331K|   476   (4)|00:00:06 |
    |*  3 |    HASH JOIN         |                   | 26131 |   791K|   476   (4)|00:00:06 |
    PLAN_TABLE_OUTPUT
    |*  4 |     TABLE ACCESS FULL| FILTER1           | 26131 |   484K|   246   (4)|00:00:03 |
    |   5 |     TABLE ACCESS FULL| HISTORY1          |   104K|  1225K|   227   (3)|00:00:03 |
    |   6 |   TABLE ACCESS FULL  | TRANSACTION1      |   199K|   150M|  6593   (1)|00:01:20 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       1 - access("T"."TID"="$nso_col_1")
       3 - access("H"."HID"="F"."ID")
       4 - filter("F"."MATCH"='value')
    20 rows selectedI'll admit, I'm not completely clear on what I'm reading here, other than the fact there are some big differences in the timing values
    We don't have privaleges to run trace, so I'm a bit stuffed there as I'm on the clients site, however I will get my developers to try this on our local server.
    Edited by: user1410957 on 15-Sep-2009 06:14

  • Query works as two queries, but not as one

    I am beating my head against the wall trying to figure out why a query will not return, yet when I break it up into two queries, they both return successfully.
    There is a text index on the text_a field.
    This is my query:
    select distinct /*+ */ table_c.rec_id
    from table_d, table_n, table_c
    where ( ((create_date >='2006-03-16T00:00:00Z')
    and (misc_field='abcd')
    and (contains( text_a,'ABC or DEF or GHI or JKL or MNP') > 0 ))
    /* and (rownum <=2000) */)
    and table_c.rec_id = table_d.rec_id
    and table_c.create_date = table_d.create_date
    and table_c.rec_id = table_n.rec_id
    and table_c.create_date = table_n.create_date
    This query will not return data. I get an ora-1555 every time I let it run. The longest I let it run before getting the 1555 error was 1 hr and 50 min.
    Tests suspecting a text data problem:
    Now, here's what's puzzling. The query will run if 'JKL' is taken out. So, I thought this value may be the problem, so I ran the query with just the 'JKL' value in the "contains" clause and it did not return a value.
    Tests suspecting a date problem:
    Now, even more strange: When I ran the query (with all 5 conditions for misc_field) and looked from 2006-03-17T00:00:00Z, it returned records in less than 5 minutes. Then I queries just the 16th (create_date>='2006-03-16T00:00:00Z' and create_date < '2006-03-17T00:00:00Z' and it returned rows in less than 1 minute. So, I looked at the tokens for those dates, and there are values for all of them for each of the dates from the 16th to the present (the 21st). However, when I put them together in the query above, the query just seems to hang.
    The total number of rows that should be returned is around 650 (adding the two results that worked).
    Any suggestions? The indexes are valid, syncing is up-to-date, optimizing has no errors,a nd there are token_counts for the tokens in the $I table for the text_a field.
    This problem has crossed into a second day and the same value of the 16th (as in the query above) is still used and still does not return rows. What else should I be looking at?
    In advance, thanks for any suggestions/assistance.
    - Jenny

    I believe the 1555 error is an obscure response to (i.e. a result of) another problem.
    The create_date column is a date datatype. The NLS format matches at the session, instance and database level (nls_session_parameters, and instance, and database). The NLS_DATE_FORMAT is set to YYYY-MM-DD"T"HH24:MI:SS"Z" in each of those views. Would this still cause a potential problem?
    I neglected to say that we are on version 9.2.0.7 (both the data dictionary and the binaries).
    The response from raford suggests that the optimizer is causing the text index to be called in "functional lookup" mode. I tried testing it, forcing it to use an index. The query ran in 3.5 minutes. Then I tested the original query and received the same results. After checking with the other DBAs, one of them was updating statistics on partitions for previous days' data. The statistics were only being run on current data partitions for the current day, but apparently the method that the application uses to "update" data (which could be for previous days) is to delete it and then insert it. I am suspecting that this is the root cause of all our evil! We are currently working with the developers to get this design changed. In the meantime, I REALLY appreciate all the help/suggestions. If we see the problem occur again, we will add the hint to test and verify whether or not that is the cause. I suspect it will be. Thank you raford.
    Darn that optimizer!!!! ;-)
    Oh, just a hint: Using set autotrace traceonly explain will NOT show that each of the text index partitions is being scanned. This was what we were using for our explain plans. But, when another query, with a similar problem, was finally run, we used EM and the "Long Ops" tab to finally see that each partition was being scanned for the token, whether it needed it or not. I think I'll go back to Tom Kyte's website and look for that article on the set autotrace traceonly explain not giving a totally accurate explain plan.
    Thanks again.
    - Jenny

  • Requirement wherein I want to call two queries in parallel using ABAP Prg

    We are using RSCRM_BAPI to run a query in background and write the results to a table. We later read this table and create a file. I have a requirement u2013 wherein I want to call two queries in parallel using an ABAP program.
    For our discussion assume:
    1) Program : ZCALL_RCRMBAPI  is a program that calls RSCRM_BAPI in background and takes the query name as input
    2) Program: ZMAIN_PROGRAM  this is the main program
    The requirement is to call the ZCALL_RCRMBAPI in a loop. Also within the loop call it in parallel. Basically we have an ODS that stores ; FISCPER. So I call the two queries for a list of FISCPER.
    ZMAIN_PROGRAM - A program that reads a table (ODS ) in our case and call the two programs in a loop and both should run in parallel .
    Now if it was sequential u2013 it was easy u2013 I would just say
    Loop at L_T_FISCPER .
    Update Z_FISCPER with L_T_FISCPER-FISCPER u201C Assume Z_FISCPER is a Z table . The VARIABLE in the query Q1 and Q2 use a customer exit to read this table.
    A)       SUBMIT ZCALL_RCRMBAPI with P_QUERy = Q1 and return .
    B)      SUBMIT ZCALL_RCRMBAPI with P_QUERy = Q2 and return .
    Endloop .
    Question: How do I make these calls in parallel u2013 yet retain control in the main program?
    A)       SUBMIT ZCALL_RCRMBAPI with P_QUERy = Q1 and return .
    B)      SUBMIT ZCALL_RCRMBAPI with P_QUERy = Q2 and return .

    Instead of RSCRM BAPI you can use the RRW3_QUERY_VIEW_DATA function module for greater control over program execution...
    /people/arun.varadarajan/blog/2009/07/29/make-the-most-out-of-query-execution--part-1
    will give you pointers as to how this can be done...

Maybe you are looking for