Same query returning different result set

hi all,
i am using db 10g.
i have a query like below
  SELECT SUM(EID_AMOUNT)amt,EID_INCR_CODE,EIH_EFF_DATE
     FROM EMP_INC_HEADER,EMP_INC_DETAILS
    WHERE EIH_EMP_CODE = EID_EMP_CODE
      AND EIH_EFF_DATE = EIH_EFF_DATE
      AND EIH_STATUS   = 'P'
      AND EID_EMP_CODE = '003848'
GROUP BY EID_INCR_CODE,EIH_EFF_DATE
ORDER BY EID_INCR_CODE,EIH_EFF_DATE;which is leading to the output
      AMT EID_INCR_CODE   EIH_EFF_D
     2000 BASIC           21-SEP-10
     2000 BASIC           23-SEP-10
     2000 BASIC           15-OCT-10
     2000 BASIC           21-OCT-10
     1200 HTRAN           21-SEP-10
     1200 HTRAN           23-SEP-10
     1200 HTRAN           15-OCT-10
     1200 HTRAN           21-OCT-10
      800 OTHERS          21-SEP-10
      800 OTHERS          23-SEP-10
      800 OTHERS          15-OCT-10
      800 OTHERS          21-OCT-10i have query
SELECT SUM(EID_AMOUNT)amt,EID_INCR_CODE,EID_EFF_DATE
FROM EMP_INC_HEADER,EMP_INC_DETAILS
WHERE EIH_EMP_CODE = EID_EMP_CODE
AND EIH_EFF_DATE = EID_EFF_DATE
AND EIH_STATUS = 'P'
AND EID_EMP_CODE = '003848'
GROUP BY EID_INCR_CODE,EID_EFF_DATE
ORDER BY EID_INCR_CODE,EID_EFF_DATE;
leading to
      AMT EID_INCR_CODE   EID_EFF_D
      500 BASIC           21-SEP-10
      500 BASIC           23-SEP-10
      500 BASIC           15-OCT-10
      500 BASIC           21-OCT-10
      300 HTRAN           21-SEP-10
      300 HTRAN           23-SEP-10
      300 HTRAN           15-OCT-10
      300 HTRAN           21-OCT-10
      200 OTHERS          21-SEP-10
      200 OTHERS          23-SEP-10
      200 OTHERS          15-OCT-10
      200 OTHERS          21-OCT-10
12 rows selected.what second query is returning is correct. as per the table.
but my question what is the difference between my first and second query.
in what way it is different(i am not getting any idea).
if any one is having any clue please share with me.
Thanks..

what is the difference between my first and second queryLook like there's no difference.
I think you really meant something like
SELECT SUM(EID_AMOUNT) amt,EID_INCR_CODE,EIH_EFF_DATE
  FROM EMP_INC_HEADER EIH,
       EMP_INC_DETAILS EID
WHERE EIH.EMP_CODE = EID.EMP_CODE
   AND EIH.EFF_DATE = EIH.EFF_DATE
   AND EIH.STATUS   = 'P'
   AND EID.EMP_CODE = '003848'
GROUP BY EID.INCR_CODE,EIH.EFF_DATE
ORDER BY EID.INCR_CODE,EIH.EFF_DATERegards
Etbin

Similar Messages

  • Same Query returning different result (Different execution plan)

    Hi all,
    To day i have discovered a strange thing: a query that return a different result when using a different execution plan.
    The query :
    SELECT  *
      FROM schema.table@database a
    WHERE     column1 IN ('3')
           AND column2 = '101'
           AND EXISTS
                  (SELECT null
                     FROM schema.table2 c
                    WHERE a.column3 = SUBSTR (c.column1, 2, 12));where schema.table@database is a remote table.
    when executed with the hint /*+ ordered use_nl(a c) */ these query return no result and its execution plan is :
    Rows     Row Source Operation
          0  NESTED LOOPS  (cr=31 r=0 w=0 time=4894659 us)
       4323   SORT UNIQUE (cr=31 r=0 w=0 time=50835 us)
       4336    TABLE ACCESS FULL TABLE2 (cr=31 r=0 w=0 time=7607 us)
          0   REMOTE  (cr=0 r=0 w=0 time=130536 us)When i changed the execution plan with the hint /*+ use_hash(c a) */
    Rows     Row Source Operation
       3702  HASH JOIN SEMI (cr=35 r=0 w=0 time=497839 us)
      22556   REMOTE  (cr=0 r=0 w=0 time=401176 us)
       4336   TABLE ACCESS FULL TABLE2 (cr=35 r=0 w=0 time=7709 us)It seem that when the execution plan have changed the remote query return no result.
    It'is a bug or i have missed somthing ?
    PS: The two table are no subject to insert or update statement.
    Oracle version : 9.2.0.2.0
    System version : HP-UX v1
    Thanks.

    H.Mahmoud wrote:
    Oracle version : 9.2.0.2.0
    System version : HP-UX v1Hard to say. You're using a very old and deprecated version of the database, and one that was known to contain bugs.
    9.2.0.7 was really the lowest version of 9i that was considered to be 'stable', but even so, it's old and lacking in many ways.
    Consider upgrading to the latest database version at your earliest opportunity. (or at least apply patches up to the latest 9i version before querying if there is bugs in your really low buggy version)

  • Same query returns differenent result sets in oracle 9i and 10g

    Could anyone please clarify the issue i am having on a query. I have query that is returning around 2000 records in oracle db 9.2.0.8.0, at the same time with same data if run on 10.2.0.1.0 is returning only 12 records.
    what might be the reason for this descrepancy, is something in 9i is considered differently in 10g?
    Here is the query.
    SELECT
    0
    ,ot_req_head.rh_sys_id
    ,ot_req_head.rh_comp_code
    ,ot_req_head.rh_txn_code
    ,ot_req_head.rh_no
    ,ot_req_head.rh_appr_uid
    ,'Action to be taken' action
    ,ot_req_head.rh_appr_dt
    ,NULL AUTH_TO_UID
    ,NULL
    ,NULL
    ,NULL from_remarks
    ,NULL
    ,NULL
    ,'REQ'
    ,ot_req_head.rh_amd_no
    ,ot_req_head.rh_amd_dt
    ,ot_req_head.rh_cr_uid
    ,DECODE(ot_req_head.rh_charge_area_num,6,ot_req_head.rh_locn_code,1,ot_req_head.rh_charge_code,NULL)
    ,ot_req_head.rh_cr_dt
    ,NULL
    FROM
    orioni.om_txn_setup,
    orioni.ot_req_head,
    iscoit.isco_txn_auth,
    SELECT DISTINCT rh_sys_id
    FROM orioni.pending_mr
    )pending_mr
    WHERE
    ot_req_head.rh_txn_code=txns_txn_code
    AND
    auth_comp_code(+)=ot_req_head.rh_comp_code
    AND
    auth_action_to_type(+) IS NULL
    AND
    auth_head_sys_id(+)=ot_req_head.rh_sys_id
    AND
    auth_txn_code(+)=ot_req_head.rh_txn_code
    AND
    ot_req_head.rh_clo_status IS NULL
    AND
    ot_req_head.rh_comp_code='001'
    AND
    txns_txnp_code='PURREQ'
    AND
    txns_values='N'
    AND
    ot_req_head.rh_appr_status=3
    AND
    ot_req_head.rh_sys_id = pending_mr.rh_sys_id
    AND NOT EXISTS
    SELECT 'X'
    FROM
    iscoit.isco_txn_auth A
    WHERE
    a.auth_head_sys_id = isco_txn_auth.auth_head_sys_id
    AND
    a.auth_action_from_uid = ot_req_head.rh_appr_uid
    AND
    a.auth_action_from_type = 'Action to be taken'
    AND
    a.auth_action_from_dt = ot_req_head.rh_appr_dt
    AND
    NVL(a.auth_txn_amend_no,0) = NVL(ot_req_head.rh_amd_no,0)
    AND
    a.auth_action_to_type = 'REJECT'
    AND
    ot_req_head.rh_cr_dt > TO_DATE('16-MAR-2008','DD-MON-YYYY')
    Edited by: unus on Oct 19, 2009 3:56 AM
    Edited by: unus on Oct 19, 2009 4:18 AM

    Here's what I got on 9i and 10G:
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.8.0 - Production
    SQL> CREATE TABLE T_1(VAL1 NUMBER,VAL2 VARCHAR2(10));
    Table created.
    SQL> CREATE TABLE T_2(VAL1 NUMBER,VAL2 VARCHAR2(10));
    Table created.
    SQL> INSERT INTO T_1 VALUES(1,'FIRST');
    1 row created.
    SQL> INSERT INTO T_1 VALUES(2,'SECOND');
    1 row created.
    SQL> INSERT INTO T_2 VALUES(1,'FIRST');
    1 row created.
    SQL> INSERT INTO T_2 VALUES(2,'SECOND');
    1 row created.
    SQL> INSERT INTO T_1 VALUES(3,'THIRD');
    1 row created.
    SQL> INSERT INTO T_1 VALUES(4,'FOURTH');
    1 row created.
    SQL> INSERT INTO T_1 VALUES(5,'FIFTH');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> SELECT A.VAL1,B.VAL1 FROM
      2  T_1 A,T_2 B
      3  WHERE A.VAL1=B.VAL1;
         VAL1      VAL1
            1         1
            2         2
    SQL> SELECT A.VAL1,B.VAL1 FROM
      2  T_1 A,T_2 B
      3  WHERE A.VAL1=B.VAL1(+);
         VAL1      VAL1
            1         1
            2         2
            3
            4
            5
    SQL> SELECT A.VAL1,B.VAL1 FROM
      2  T_1 A,T_2 B
      3  WHERE A.VAL1=B.VAL1(+)
      4  AND
      5  NOT EXISTS (SELECT 'X' FROM t_2 C WHERE c.val1=b.val1);
         VAL1      VAL1
            3
            4
            5
    SQL> select name, value from v$parameter where name like '%optimizer%' or name like '%cursor_sharing
    NAME                                                             VALUE
    cursor_sharing                                                   EXACT
    optimizer_features_enable                                        9.2.0
    optimizer_mode                                                   CHOOSE
    optimizer_max_permutations                                       2000
    optimizer_index_cost_adj                                         100
    optimizer_index_caching                                          0
    optimizer_dynamic_sampling                                       1
    -- 10G
    Verbonden met:
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    SQL> SELECT A.VAL1,B.VAL1 FROM
      2  T_1 A,T_2 B
      3  WHERE A.VAL1=B.VAL1;
          VAL1       VAL1
             1          1
             2          2
    SQL> SELECT A.VAL1,B.VAL1 FROM
      2  T_1 A,T_2 B
      3  WHERE A.VAL1=B.VAL1(+);
          VAL1       VAL1
             1          1
             2          2
             5
             4
             3
    SQL> SELECT A.VAL1,B.VAL1 FROM
      2  T_1 A,T_2 B
      3  WHERE A.VAL1=B.VAL1(+)
      4  AND
      5  NOT EXISTS (SELECT 'X' FROM t_2 C WHERE c.val1=b.val1);
          VAL1       VAL1
             3
             4
             5( Please use the tag before and after your example, so we're sure we're looking at your complete example )                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Same query giving different results

    Hi
    I m surprised to see the behaviour of oracle. I have two different sessions for same scheema on same server. In both sessions same query returns different results. The query involves some calculations like sum and divisions on number field.
    I have imported this data from another server using export / import utility available with 9i server. Before export every thing was going fine. Is there some problem with this utility.
    I m using Developer 6i as the front end for my client server application. The behaviour of my application is very surprizing as once it shows the correct data and if I close the screen and reopen, it shows wrong data.
    I m really stucked with the abnormal behaviour. Please tell me the possiblities and corrective action for these conditions.
    Regards
    Asad.

    There is nothing uncommitted in both the sessions. But still different results are returned.
    I m sending u the exact query and result returned in both sessions.
    Session 1:
    SQL> rollback;
    Rollback complete.
    SQL> SELECT CC.CREDIT_HRS,GP.GRADE_PTS
    2 FROM GRADE G, COURSE_CODE CC, GRADE_POLICY GP
    3 WHERE G.COURSE_CDE=CC.COURSE_CDE
    4 AND G.SELECTION_ID=45 AND G.GRADE_TYP=GP.GRADE_TYP
    5 AND G.TERM_PROG_ID=17 AND GP.TERM_ID=14
    6 /
    CREDIT_HRS GRADE_PTS
    3 4
    4 3.33
    4 3.33
    3 4
    3 4
    3 4
    3 4
    7 rows selected.
    SQL>
    SESSION 2:
    SQL> rollback;
    Rollback complete.
    SQL> SELECT CC.CREDIT_HRS,GP.GRADE_PTS
    2 FROM GRADE G, COURSE_CODE CC, GRADE_POLICY GP
    3 WHERE G.COURSE_CDE=CC.COURSE_CDE
    4 AND G.SELECTION_ID=45 AND G.GRADE_TYP=GP.GRADE_TYP
    5 AND G.TERM_PROG_ID=17 AND GP.TERM_ID=14
    6 /
    CREDIT_HRS GRADE_PTS
    3 4
    4 3.33
    3 4
    3 4
    3 4
    3 4
    6 rows selected.
    SQL>
    U can see in session 1, seven rows are returned while in session 2 six rows are returned. I have issued a rollback before query to be sure that data in both sessions is same.

  • Oracle function and query return different results

    Hi, I am using oracle 10g database.
    Function is :
    create or replace FUNCTION FUNC_FAAL(myCode number,firstDate date
    *, secondDate date)*
    RETURN INTEGER as
    rtr integer;
    BEGIN
    select count() into rtr*
    from myschema.my_table tbl where tbl.myDateColumn between firstDate and
    secondDate and tbl.kkct is null and tbl.myNumberColumn  = myCode ;
    return (rtr);
    END FUNC_FAAL;
    This function returns 117177 as result.
    But if I run same query in the function seperately ;
    select count()*
    from myschema.my_table tbl
    where tbl.myDateColumn between firstDate and secondDate
    and tbl.kkct is null and tbl.myNumberColumn  = myCode ;
    I get different result 11344 (which is the right one).
    Table and function are in the same schema.
    What can be the problem ?
    Thanks.

    1. i think ur parameter name and Column names are same Firstdate and seconddate try to choose different name
    2. try using Trunc function around your dates
    where trunc(tbl.myDateColumn) between trunc(firstDate) and trunc(secondDate)then compare the result....sometimes time elements comes into play.
    Baig
    [My Oracle Blog|http://baigsorcl.blogspot.com/]

  • Query returning wrong result set

    I am running the following query on 8.1.7 database. The query is
    SELECT Y.*, TEVStatus.lEndStatusFlag ENDSTATUSFLAG
    FROM
    (SELECT ROWNUM RANK, X.* FROM (SELECT lExceptionID ID,
    TEVException.sMonitorName MONNAME, sExcpStatus STATUS
    FROM TEVException WHERE (TEVException.lExceptionID IN
    (SELECT lExceptionID FROM TEVException WHERE
    sUserName_AssignedTo = 'vadmin')) ORDER BY
    TEVException.lExceptionID DESC) X)
    Y, TEVStatus WHERE (Y.RANK > 0 AND Y.RANK < 0 + 51 + 1) AND
    (STATUS = TEVStatus.sStatusName);
    The result is
    RANK ID MONNAME STATUS ENDSTATUSFLAG
    51 29 Type09B Open 0
    50 30 Type09A Open 0
    49 31 Type09E Open 0
    48 32 Type09F Open 0
    47 33 Type09G Open 0
    46 34 Type09I Open 0
    45 35 Type09C Open 0
    44 36 Type10A Open 0
    43 37 Type04A Open 0
    39 41 Type08A Open 0
    38 42 Type08C Open 0
    RANK ID MONNAME STATUS ENDSTATUSFLAG
    37 43 Type10B Open 0
    36 44 Type10E Open 0
    35 45 Type10C Open 0
    34 46 Type10F Open 0
    33 47 Type10D Open 0
    32 48 Type08B Open 0
    31 49 Type04B Open 0
    29 51 Type08D Open 0
    28 52 Type11E Open 0
    27 53 Type11A Open 0
    26 54 Type11D Open 0
    RANK ID MONNAME STATUS ENDSTATUSFLAG
    25 55 Type11C Open 0
    24 56 Type11B Open 0
    23 57 Type12A Open 0
    22 58 Type12B Open 0
    21 59 Type12C Open 0
    20 60 Type12E Open 0
    19 61 Type12A Open 0
    18 62 Type12B Open 0
    17 63 Type12E Open 0
    16 64 Type12C Open 0
    15 65 Type12D Open 0
    RANK ID MONNAME STATUS ENDSTATUSFLAG
    14 66 Type12D Open 0
    4 80 Type01A_Ravi Open 0
    3 83 Type01A_Ravi Open 0
    2 84 Type01A_Ravi Open 0
    1 87 Type01A_Ravi Open 0
    42 38 Type06E Closed 8500
    41 39 Type06A Closed 8500
    40 40 Type06B Closed 8500
    30 50 Type06C Closed 8500
    13 68 Type01A Closed 8500
    12 69 Type01A Closed 8500
    RANK ID MONNAME STATUS ENDSTATUSFLAG
    11 70 Type01A Closed 8500
    10 71 Type01A Closed 8500
    9 72 Type01A Closed 8500
    8 73 Type01A Closed 8500
    7 75 Type01A Closed 8500
    6 77 Type01A Closed 8500
    5 78 Type01A Closed 8500
    51 rows selected.
    In the above result, the RANK is not sorted properly and I
    expected ID in descending order. The table which I was querying
    had only about 100 records. I ran the same query on a larger
    record set and the result is fine. I get ID in descending order
    which I was expecting.
    Could someone please tell me whether any bug in this case or
    something wrong in the query

    Hi...
    Took a quick look at tour SQL and....
      SELECT Y.*
           , TEVStatus.lEndStatusFlag ENDSTATUSFLAG
        FROM ( SELECT ROWNUM RANK
                    , X.*
                 FROM ( SELECT lExceptionID ID
                             , TEVException.sMonitorName MONNAME
                             , sExcpStatus STATUS
                          FROM TEVException
                         WHERE ( TEVException.lExceptionID IN
                                 ( SELECT lExceptionID
                                      FROM TEVException
                                    WHERE sUserName_AssignedTo
                                          = 'vadmin'
                         ORDER BY TEVException.lExceptionID DESC
                      ) X
             ) Y
           , TEVStat us
       WHERE ( Y.RANK > 0
               AND
               Y.RANK < 0 + 51 + 1
         AND STATUS = TEVStatus.sStatusName ;
    Should "FROM ( SELECT ROWNUM RANK" be "FROM ( SELECT ROWNUM,
    RANK"?
    RANK is a reserved word, an analytic function.
    Is "ORDER BY TEVException.lExceptionID DESC" doing anything?  I
    would drop it..
    Hope this helps. Good Luck.

  • Does row_number() returns different result set every time?

    Hi,
    I have a query somewhat like the example:
    select /*+ parallel (ftstm,4) */
    ftstm. term,
    sum(ftstm.revenue) revenue,
    sum(ftstm.searches) searches,
    row_number() over (order by sum(ftstm.revenue)desc) as depth_rank
    from
    fact_terms
    group by
    ftstm.term
    ORDER BY
    revenue DESC
    where
    depth_rank <= 100000
    I have run this query 2-3 times and surprisingly- when I do MINUS on the result sets, I got few records.
    Is that possible or am I doing some mistake with this query? Please help...

    Nandini wrote:
    Hi,
    I have a query somewhat like the example:
    select /*+ parallel (ftstm,4) */
    ftstm. term,
    sum(ftstm.revenue) revenue,
    sum(ftstm.searches) searches,
    row_number() over (order by sum(ftstm.revenue)desc) as depth_rank
    from
    fact_terms
    group by
    ftstm.term
    ORDER BY
    revenue DESC
    where
    depth_rank <= 100000
    I have run this query 2-3 times and surprisingly- when I do MINUS on the result sets, I got few records.well what are you MINUSing from it?
    You need to provide us with your database version, example data and expected output (or show us what you are getting)...
    {message:id=9360002}

  • Returning a result set/record from a dynamic query

    There seems to be plenty of examples for using Native Dynamic Sql to formulate and execute a dynamic query, however there are no examples of returning a result set or records which contain the rows of data that are retrieved by executing the query. Could someone give us an example?

    Welcome to the Oracle forum....
    CREATE OR REPLACE PACKAGE curspkg_join AS
    TYPE t_cursor IS REF CURSOR ;
    Procedure open_join_cursor1 (n_EMPNO IN NUMBER, io_cursor IN OUT t_cursor);
    END curspkg_join;
    Create the following Oracle package body on the Oracle server:
    CREATE OR REPLACE PACKAGE BODY curspkg_join AS
    Procedure open_join_cursor1 (n_EMPNO IN NUMBER, io_cursor IN OUT t_cursor)
    IS
    v_cursor t_cursor;
    BEGIN
    IF n_EMPNO <> 0
    THEN
    OPEN v_cursor FOR
    SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME
    FROM EMP, DEPT
    WHERE EMP.DEPTNO = DEPT.DEPTNO
    AND EMP.EMPNO = n_EMPNO;
    ELSE
    OPEN v_cursor FOR
    SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME
    FROM EMP, DEPT
    WHERE EMP.DEPTNO = DEPT.DEPTNO;
    END IF;
    io_cursor := v_cursor;
    END open_join_cursor1;
    END curspkg_join;
    Dim Oraclecon As New OracleConnection("Password=pwd;" & _
    "User ID=uid;Data Source=MyOracle;")
    Oraclecon.Open()
    Dim myCMD As New OracleCommand()
    myCMD.Connection = Oraclecon
    myCMD.CommandText = "curspkg_join.open_join_cursor1"
    myCMD.CommandType = CommandType.StoredProcedure
    myCMD.Parameters.Add(New OracleParameter("io_cursor", OracleType.Cursor)).Direction = ParameterDirection.Output
    myCMD.Parameters.Add("n_Empno", OracleType.Number, 4).Value = 123
    Dim myReader As OracleDataReader
    Try
    myCMD.ExecuteNonQuery()
    Catch myex As Exception
    MsgBox(myex.Message)
    End Try
    myReader = myCMD.Parameters("io_cursor").Value
    Dim x, count As Integer
    count = 0
    Do While myReader.Read()
    For x = 0 To myReader.FieldCount - 1
    Console.Write(myReader(x) & " ")
    Next
    Console.WriteLine()
    count += 1
    Loop
    MsgBox(count & " Rows Returned.")
    myReader.Close()
    Oraclecon.Close()
    The above code is working in one of our application; which is using ref cursor as result set and get from procedure. I hope you can found more code by google and/or search in this forum as well; if above code is not useful to you.
    HTH
    Girish Sharma

  • Design a procedure which returns a result set of a select Query

    Hi...
    Can some one help me out with a brief design or work around for creating a stored procedure which runs a select Query and Returns a result set...
    If not a stored procedure, at least a function which makes the job simple....
    Awaiting help in this regard ........

    Hi...
    I am sorry for providing insufficient Info...
    Actually I am using Oracle 10G DB...
    I have a select Query..
    Since I am a part of team which is building a Complete Data Driven site, Even an SQL Query and a PL/SQL function body was stored in the Table itself to bring in some kind of Dynamism in the site.... But the master table was loaded with a lot of data and hence Now we decided to Store everythin in a generic package..
    I used REF CURSORS to store a result set of a simple SELECT Query.... and declaring it as an out parameter in my Procedure body so that the JAVA team can directly access the Procedure from the JAVA layer....
    Now I want to know can I do anything more efficient to carry out the above operation....

  • Interactive Reporting Reports - Same Rpt Format, but Different Result Set

    I have created a report using result set 1. I've saved that, but want to copy it & use the same format/columns to create a new report using a different result set (the result sets have the same data, but one is filtered). Is there an easy way to change the name of the result set being used w/o re-creating the entire report columns & all?
    Terri

    I am in the Dashboard Studio - Optimize Utility. When I select that report (or any of the others), the Reparent button is grayed out on the toolbar. I've also tried right-clicking on the report and it's grayed out there as well. Any ideas?

  • To_char(adate,'dd.mm.yyyy')   returns different results  from  two oracle clients !!! Is it  possible?

    Dear all;
    We have only one Database server with some IIS's   as web servers on front . Each web server has own oracle client software in order connect to central database..
    The same following query used in C#  code  returns different results on each IIS server.(3 row, or  not data found )
    why?
    select     *    from    aTable    where        to_char( adate ,  'dd.mm.yyyy' )  =   :search_date
    regards
    Siya

    1006237 wrote:
    If adate is of DATE datatype, it will most likely has the time component. Therefore your SQL below is unlikely to return any data.
    select * from aTable where adate = to_date(:search_date, 'dd.mm.yyyy')
    Perhaps.....
    select * from aTable where TRUNC(adate) = to_date(:search_date, 'dd.mm.yyyy')
    Hi,
    not having any sample data from you I could not understand that you wanted to select the range 00:00:00 - 23:59:59 on search_date.
    Your method might not be efficient if you have an index on adate.
    Maybe something like this will be more efficient
    select * from aTable
    where adate >= to_date(:search_date, 'dd.mm.yyyy')
      and adate <  to_date(:search_date, 'dd.mm.yyyy') + 1;
    If you search_date is 30-Aug-2013 it will get records where adate >= 30-Aug-2013 00:00:00 and adate < 31-Aug-2013 00:00:00, so any time of date 30-Aug-2013.
    Try like this and let us know if you still have 2 different results.
    Regards.
    Alberto

  • The statement did not return a result set in ireport

    Hi,
        I am Building a Report in iReport(Jasper Reports). I called a stored procedure from iReport by passing a parameter in Query Editor. I am getting an exception saying "The statement did not return a result set". When
    i use Temp Tables in stored procedure i am getting the exception.
    If there is no temptable in Stored procedure there wont be any exception.
    This is my Stored procedure
    Create PROCEDURE [XUSP_REPORT_SOPRINT] @BNUM VARCHAR(20) AS
    BEGIN
    DECLARE @FQTY BIGINT
    DECLARE @ITNAME VARCHAR(100)
    DECLARE @COUNT INT=0
    DECLARE @COUNT1 INT=0
    CREATE TABLE #BILL_PRINT(
        [BNUM] [varchar](20) NOT NULL,
        [CNAME] [varchar](30) NOT NULL,
        [CNUM] [int] NOT NULL,
        [ITNAME] [varchar](100) NOT NULL,
        [ITEM#] [int] NOT NULL,
        [QTY] [int] NOT NULL DEFAULT 0,
        [UNIT] [varchar](5) NOT NULL,
        [PRICE] [float] NOT NULL DEFAULT 0,
        [BASIC] [float] NOT NULL DEFAULT 0,
        [DISCOUNT] [float] NOT NULL DEFAULT 0,
        [FRQTY] [int] NOT NULL DEFAULT 0,
        [BADDR] [varchar](300) NULL,
        [CADDR] [varchar](300) NOT NULL,
        [BDATE] [datetime] NULL DEFAULT (sysdatetime()),
        [BILLBY] [varchar](50) NOT NULL,
        [ROUTE] [varchar](200) NULL,
        [AMT] [float] NOT NULL DEFAULT 0,
        [VAT] [float] NOT NULL DEFAULT 0,
        [VAT AMT] [float] NOT NULL DEFAULT 0,
        [AMT_AF_DISC] [float] NOT NULL DEFAULT 0,
        [AMT_AF_VAT] [float] NOT NULL DEFAULT 0,
        [TOT_DISC] [float] NOT NULL DEFAULT 0,
        [ROUND_OFF] [float] NOT NULL DEFAULT 0,
        [TOT_VAT] [float] NOT NULL DEFAULT 0,
        [AMT_UNDER_VAT] [float] NOT NULL DEFAULT 0,
        [NETT] [float] NOT NULL DEFAULT 0,
        [TOS] [varchar](30) NULL DEFAULT 0,
        [CDISC] [float] NOT NULL DEFAULT 0,
        [SDISC] [float] NOT NULL DEFAULT 0
    insert into #BILL_PRINT SELECT [BNUM]
          ,[CNAME]
          ,[CNUM]
          ,[ITNAME]
          ,[ITEM#]
          ,[QTY]
          ,[UNIT]
          ,[PRICE]
          ,[BASIC]
          ,[DISCOUNT]
          ,[FRQTY]
          ,[BADDR]
          ,[CADDR]
          ,[BDATE]
          ,[BILLBY]
          ,[ROUTE]
          ,[AMT]
          ,[VAT]
          ,[VAT AMT]
          ,[AMT_AF_DISC]
          ,[AMT_AF_VAT]
          ,[TOT_DISC]
          ,[ROUND_OFF]
          ,[TOT_VAT]
          ,[AMT_UNDER_VAT]
          ,[NETT]
          ,[TOS]
          ,[CDISC]
          ,[SDISC]
      FROM [SALES_DETAILS] WHERE BNUM=@BNUM
    CREATE TABLE #ITNAME_0
    ITEM VARCHAR(100) NOT NULL,
    FREE BIGINT NOT NULL
    INSERT INTO #ITNAME_0 SELECT ITNAME,FRQTY FROM SALES_DETAILS WHERE FRQTY<>0 AND BNUM=@BNUM
    --SELECT * FROM #ITNAME_0
    SET @COUNT=(SELECT COUNT(*) FROM #ITNAME_0)
    WHILE @COUNT!=0
    BEGIN
    SET @FQTY=(SELECT TOP(1) FREE FROM #ITNAME_0)
    SET @ITNAME=(SELECT TOP(1) ITEM FROM #ITNAME_0)
    SET @COUNT1=(SELECT COUNT(*) FROM #BILL_PRINT WHERE ITNAME=@ITNAME AND BNUM=@BNUM)
    IF @COUNT1=2
    BEGIN
        UPDATE #BILL_PRINT
        SET FRQTY+=@FQTY
        WHERE ITNAME=@ITNAME AND QTY<>0
        DELETE FROM #ITNAME_0 WHERE ITEM=@ITNAME AND FREE=@FQTY
        DELETE FROM #BILL_PRINT WHERE  ITNAME=@ITNAME AND QTY=0
    END
    SET @COUNT=@COUNT-1
    END
    --SELECT *FROM sales_details
    SELECT *FROM #BILL_PRINT where bnum=@bnum
    DROP TABLE #BILL_PRINT
    DROP TABLE #ITNAME_0
    END
    Please help me out in this.
    Thanks,
    Shreyas M

    This is a forum for Reporting Services (SSRS). If you're using Jasper reports then you should be posting in relevenat forums. I'm not sure there would be enough people with Jasper report experience here to help you out!
    Anyways in SSRS when  we use Temp tables in procedure it will throw exception in editor but when you save and run it will still work fine. Did you try saving it and executing report? Did the error still persisted?
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Please Help Urgent:Fast Search returning wrong result sets

    Hi All,
    We are facing below issue with fast search.
    Currently in My project  when  we are searching  for a phrase it is returning wrong result sets.
    For example if we search for “Endura”, It is returning documents related to
    Endura  as well as Centura.
    But the expected results are only Endura documents.
    When we look in to the documents we didn’t find the search term (“Endura” ) either inside document content or in its meta data.
    In order to resolve the issue we tried the below steps
    1-     
    We manually edited and saved the document, to ensure the appropriate Guid association to metadata.
    2-     
    Index reset
    3-     
    Full crawl
    But no luck  so far.
    Please help.Thanks in advance.
    Regards
    Subrat

    Subrat,
    This may be related to spellchecking or may be synonym. Spellcheck is based on indexed terms.
    The best test would be to run the queries from qrserver (13280) and then look at the spellcheck query transformations. If spellchecking is not doing it, then you must have a synonym setup .Check your keyword/synonyms from the SharePoint side. 

  • Returning Different Results Based on Input Criteria

    I have a complex nested select statement. Based on selection criteria I want to return different results. Say for instance I had an input parameter Called Products which could contain a Yes/No Flag. If the Flag was Yes then I would want the "top" select, statement to be The following:
    Select Product, Time_ID, Amt
    From
    My Complex Nested Select
    But if Product was set to "No", I would want the following:
    Select Time_ID, Amt
    From
    My Complex Nested Select
    I know, or course that I can have two COMPLETE set of SQL which are invoked based upon testing the value of the PRODUCT Parameter, but If I duplicate the "inner nested select" then I have 2 sets of select staments to maintain. Is there an alternative to this? Could I make the inner portion which does not change a function of some sort so that my code would look something like this?
    Select Product, Time_ID, Amt
    From
    Execute myNestedSelectFunction
    But if Product was set to "No", I would want the following:
    Select Time_ID, Amt
    From
    Execute myNestedSelectFunction
    This would atleast ensure that I only have to go one place to maintain the logic of the "static Nested Select" statement.
    Just want to make sure I do not have a real viable alternative to "duplicating code"
    Thanks

    Hi,
    Look in TFM for PIPELINED functions which will allow you to:SELECT Product, Time_ID, Amt FROM TABLE(myPipelinedFunctionReturningSelectResult()) T;
    SELECT Time_ID, Amt FROM TABLE(myPipelinedFunctionReturningSelectResult()) T;There are samples if you look on AskTom too.
    Regards,
    Yoann.

  • How to Create a new column from two different result sets

    How to Create a new column from two different result sets, both the result set uses the different date dimensions.

    i got solutions for this is apply filters in column formula it self, based on the requirement.

Maybe you are looking for