MAX Function not returning MAX

I have a query that is pulling in EDI 214 status codes, and want to pull in the last received status for status type "AG". To do this, I'm using the MAX function on the INSERT_DATE field of the status code AG, but the query keeps returning both AG status codes. I've tried this in a single query (Query 1) but it did not work so I also attempted it in a much smaller query to be used as a subquery, but that still did not work. Can anyone identify what the issue is with what I'm attempting to do?
Query 1 (All Inclusive):
SELECT BS.SHIPMENT_GID AS BUY_SHIPMENT_GID,
AGSS.EVENTDATE AS AG_EVENT,
D1SS.EVENTDATE AS D1_EVENT,
BS.START_TIME AS BUY_START_TIME,
AGSS.STATUS_CODE_GID AS AG,
D1SS.STATUS_CODE_GID AS D1,
BS.DOMAIN_NAME AS BUY_DOMAIN,
MAX(AGSS.INSERT_DATE) AS AG_INSERT_DATE,
MAX(D1SS.INSERT_DATE) AS D1_INSERT_DATE,
BS.START_TIME,
BS.DOMAIN_NAME,
SHIPSTAT.STATUS_VALUE_GID
FROM V_ROD_SHIPMENT BS
INNER JOIN V_ROD_SS_STATUS_HISTORY AGSH
ON (BS.SHIPMENT_GID = AGSH.SHIPMENT_GID)
INNER JOIN V_ROD_IE_SHIPMENTSTATUS AGSS
ON (AGSH.I_TRANSACTION_NO = AGSS.I_TRANSACTION_NO)
INNER JOIN V_ROD_SS_STATUS_HISTORY D1SH
ON (BS.SHIPMENT_GID = D1SH.SHIPMENT_GID)
INNER JOIN V_ROD_SHIPMENT_STATUS SHIPSTAT
ON (BS.SHIPMENT_GID = SHIPSTAT.SHIPMENT_GID)
INNER JOIN V_ROD_IE_SHIPMENTSTATUS D1SS
ON D1SH.I_TRANSACTION_NO = D1SS.I_TRANSACTION_NO
WHERE BS.START_TIME > '18/MAY/12'
AND BS.DOMAIN_NAME = 'UPS/CP/HDMB'
AND AGSS.STATUS_CODE_GID = 'AG'
AND D1SS.STATUS_CODE_GID = 'D1'
AND (SHIPSTAT.STATUS_VALUE_GID = BS.DOMAIN_NAME
|| '.SECURE RESOURCES_ACCEPTED'
OR SHIPSTAT.STATUS_VALUE_GID = BS.DOMAIN_NAME
|| '.SECURE RESOURCES_PICKUP NOTIFICATION')
GROUP BY BS.SHIPMENT_GID,
AGSS.EVENTDATE,
D1SS.EVENTDATE,
BS.START_TIME,
AGSS.STATUS_CODE_GID,
D1SS.STATUS_CODE_GID,
BS.DOMAIN_NAME,
SHIPSTAT.STATUS_VALUE_GID
Query 2 (to be used as a sub-query if I cannot pull MAX insert date in previous query):
SELECT DISTINCT BS.SHIPMENT_GID AS BUY_SHIPMENT_GID,
AGSS.EVENTDATE AS AG_EVENT,
AGSS.STATUS_CODE_GID AS AG,
MAX(AGSS.INSERT_DATE) AS AG_INSERT_DATE
FROM V_ROD_SHIPMENT BS
INNER JOIN V_ROD_SS_STATUS_HISTORY AGSH
ON (BS.SHIPMENT_GID = AGSH.SHIPMENT_GID)
INNER JOIN V_ROD_IE_SHIPMENTSTATUS AGSS
ON (AGSH.I_TRANSACTION_NO = AGSS.I_TRANSACTION_NO)
WHERE AGSS.STATUS_CODE_GID = 'AG'
AND BS.SHIPMENT_GID = 'UPS/CP/HDMB.HDM-1000203768'
GROUP BY BS.SHIPMENT_GID,
AGSS.EVENTDATE,
AGSS.STATUS_CODE_GID
Results of query 2 (similar issue as query 1, query doesn't return MAX insert date):
BUY_SHIPMENT_GID     AG_EVENT     AG     AG_INSERT_DATE
UPS/CP/HDMB.HDM-1000203768     5/25/2012 6:00:00 PM     AG     5/21/2012 3:10:36 PM
UPS/CP/HDMB.HDM-1000203768     6/1/2012 5:00:00 PM     AG     5/20/2012 2:36:18 PM
I appreciate any help.
Thanks,
-Adam

Hi, Adam,
Welcome to the forum!
Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved.
Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
Simplify the problem as much as possible. Remove all tables and columns that play no role in this problem.
If you can show what the problem is using commonly available tables (such as those in the scott schem) then you don't have to psot any sample data; just the results and the explanation.
Always say which version of Oracle you're using.
See the forum FAQ {message:id=9360002}
MAX (insert_date) returns the latest insert_date. I think, in this problem, you don't really want the latest insert_date; you want the status code that's related to the last insert_date. One way to get that is the aggregate FIRST (or LAST) function.
Consider this query, using the scott.emp table:
SELECT       ename
,       hiredate
FROM       scott.emp
ORDER BY  hiredate
,            ename
;Output:
ENAME      HIREDATE
SMITH      17-Dec-1980
ALLEN      20-Feb-1981
WARD       22-Feb-1981
JONES      02-Apr-1981
BLAKE      01-May-1981
CLARK      09-Jun-1981
TURNER     08-Sep-1981
MARTIN     28-Sep-1981
KING       17-Nov-1981
FORD       03-Dec-1981
JAMES      03-Dec-1981
MILLER     23-Jan-1982
SCOTT      19-Apr-1987
ADAMS      23-May-1987Say we're only interested in seeing the last hiredate, and the name of the person hired on that date:
LAST_ENAME LAST_HIREDA
ADAMS      23-May-1987Here's how to get those results using the aggregate LAST function:
SELECT       MIN (ename) KEEP (DENSE_RANK LAST ORDER BY hiredate) AS last_ename
,       MAX (hiredate)                                              AS last_hiredate
FROM       scott.emp
;What if there's a tie for the latest hiredate? For example, say we're only looking at people hired before 1982. In that case, the latest hiredate is December 3, 1981, and there happen to be two people hired on that date. This query
SELECT       MIN (ename) KEEP (DENSE_RANK LAST ORDER BY hiredate) AS last_ename
,       MAX (hiredate)                                              AS last_hiredate
FROM       scott.emp
WHERE         hiredate     < DATE '1982-01-01'
;produces only 1 row of output:
LAST_ENAME LAST_HIREDA
FORD       03-Dec-1981Why did it show FORD rather than JAMES? Because of the MIN function. When there happens to be a tie for the latest hiredate, MIN says to return the first ename (in normal sort order) of the rows that have that hiredate.
FIRST and LAST work with GROUP BY, too.
In the example above, we were only looking at one column related to the latest hiredate. If we neede to see several columns, it would be simpler to use the analytic ROW_NUMBER function:
WITH     got_r_num     AS
     SELECT  emp.*
     ,     ROW_NUMBER () OVER ( ORDER BY  hiredate  DESC
                               ,            ename
                       ) AS r_num
     FROM    scott.emp
     WHERE     hiredate     < DATE '1982-01-01'
SELECT     *
FROM     got_r_num
WHERE     r_num     = 1
I hope this answers your question.
If not, post a more complete explanation of what you want to do. if you have to use your own tables, then post CREATE TABLE and INSERT statements for a little sample data. Post the results you want from that data, and explain how you get those results from that data.

Similar Messages

  • XMLTABLE function not returning any values if xml has attribute "xmlns"

    Hi,
    XMLTABLE function not returning any values if xml has attribute "xmlns". Is there way to get the values if xml has attribute as "xmlns".
    create table xmltest (id number(2), xml xmltype);
    insert into xmltest values(1,
    '<?xml version="1.0"?>
    <emps>
    <emp empno="1" deptno="10" ename="John" salary="21000"/>
    <emp empno="2" deptno="10" ename="Jack" salary="310000"/>
    <emp empno="3" deptno="20" ename="Jill" salary="100001"/>
    </emps>');
    insert into xmltest values(2,
    '<?xml version="1.0"?>
    <emps xmlns="http://emp.com">
    <emp empno="1" deptno="10" ename="John" salary="21000"/>
    <emp empno="2" deptno="10" ename="Jack" salary="310000"/>
    <emp empno="3" deptno="20" ename="Jill" salary="100001"/>
    </emps>');
    commit;
    SELECT a.*
    FROM xmltest,
    XMLTABLE (
    'for $i in /emps/emp
    return $i'
    PASSING xml
    COLUMNS empno NUMBER (2) PATH '@empno',
    deptno NUMBER (3) PATH '@deptno',
    ename VARCHAR2 (10) PATH '@ename',
    salary NUMBER (10) PATH '@salary') a
    WHERE id = 1;
    The above query returning results but below query is not returning any results because of xmlns attribute.
    SELECT a.*
    FROM xmltest,
    XMLTABLE (
    'for $i in /emps/emp
    return $i'
    PASSING xml
    COLUMNS empno NUMBER (2) PATH '@empno',
    deptno NUMBER (3) PATH '@deptno',
    ename VARCHAR2 (10) PATH '@ename',
    salary NUMBER (10) PATH '@salary') a
    WHERE id = 1;
    how to get rid out of this problem.
    Thanks,
    -Mani

    Added below one in xmltable, its working now.
    XmlNamespaces(DEFAULT 'http://emp.com')

  • TABLE(CAST()) function not returning the correct results in few scenarios.

    I am using TABLE(CAST()) operation in PL/SQL and it is returning me no data.
    Here is what I have done:
    1.     Created Record type
    CREATE OR REPLACE TYPE target_rec AS OBJECT
    target__id          NUMBER(10),
    target_entity_id NUMBER(10),
    dd           CHAR(3),
    fd           CHAR(3),
    code      NUMBER(10),
    target_pct      NUMBER,
    template_nm VARCHAR2(50),
    p_symbol      VARCHAR2(10),
    pm_init          VARCHAR2(3),
    target_name     VARCHAR2(20),
    targe_type     VARCHAR2(30),
    target_caption     VARCHAR2(30),
    sort_order      NUMBER (4)
    2.     Created Table type
    CREATE OR REPLACE TYPE target_arr AS TABLE OF target_rec
    3.     Created Stored procedure which accepts parameter of type target_arr and runs the Table(Cast()) function on it.
         Following is the simplified form of my procedure.
         PROCEDURE get_target_weights
         p_in_template_target IN target_arr,
         p_out_count          OUT NUMBER,
         IS
         BEGIN
              SELECT count(*) into p_out_count
         FROM TABLE(CAST(p_in_template_target AS                     target_arr)) arr;
         END;
    I am calling get_target_weights from my java code and passing p_in_template_target with 10140 records.
    Scenario 1: If target_pct in the last record is 0, p_out_count returned from the procedure is 0.
    Scenario 2: If target_pct in the last record is any other value(say 0.01), p_out_count returned from the procedure is 10140.
    Please help me understand why the Table(Cast()) is not returning the correct results in Scenario 1. Also adding or deleting any record from the test data returns the correct results (i.e. if keep target_pct in the last record as 0 but add or delete any record).
    Let me know how can I attach the test data I am using to help you debugging as I don’t see any Attach file button on Post Message screen on the forum.

    I am not able to reproduce this problem with a small data set. I can only reproduce with the data having 10140 records.
    I am not sure if this is the memory issue as adding a new record also solves the problem.
    This should not be the error because of wrong way of filling the records in java as for testing purpose I just saved the records which I am sending from java in a table. I updated the stored procedure as well to read the data from the table and then perform TABLE(CAST()) operation. I am still getting 0 as the output for scenario 1 mentioned in my last mail.
    Here is what I have updated:
    1.     Created the table target_table
    CREATE Table target_table
    target_id          NUMBER(10),
    target_entity_id NUMBER(10),
    dd           CHAR(3),
    fd           CHAR(3),
    code      NUMBER(10),
    target_pct      NUMBER,
    template_nm VARCHAR2(50),
    p_symbol      VARCHAR2(10),
    pm_init          VARCHAR2(3),
    target_name     VARCHAR2(20),
    target_type     VARCHAR2(30),
    target_caption     VARCHAR2(30),
    sort_order      NUMBER (4)
    2.     Inserted data into the table : The script has around 10140 rows. Pls let me know how can I send it to you
    3.     Updated procedure to read data from table and stored into variable of type target_arr. Run Table(cast()) operation on target_arr and get the count
    PROCEDURE test_target_weights
    IS
         v_target_rec target_table%ROWTYPE;
         CURSOR wt_cursor IS
         Select * from target_table;
         v_count NUMBER := 1;
         v_target_arr cws_target_arr:= target_arr ();
         v_target_arr_rec target_rec;
         v_rec_count NUMBER;
         BEGIN
         OPEN wt_cursor;
         loop
              fetch wt_cursor into v_target_rec; -- fetch data from table into local           record.
              exit when wt_cursor%notfound;
              --move data into target_arr
              v_target_arr_rec :=                     cws_curr_pair_entity_wt_rec(v_target_rec target_id,v_target_rec. target_entity_id,
                        v_target_rec.dd,v_target_rec.fd,v_target_rec.code,v_target_rec.target_pct,
         v_target_rec.template_nm,v_target_rec.p_symbol,v_target_rec.pm_init,v_target_rec.template_name,
         v_target_rec.template_type,v_target_rec.template_caption,v_target_rec.sort_order);
              v_target_arr.extend();
              v_target_arr(v_count) := v_target_arr_rec;
              v_count := v_count + 1;
         end loop;
         close wt_cursor;
         -- run table cast on target_arr
         SELECT count(*) into v_rec_count
         FROM TABLE(CAST(v_target_arr AS target_arr)) arr;
         DBMS_OUTPUT.enable;
         DBMS_OUTPUT.PUT_LINE('p_out_count ' || v_rec_count);
         DBMS_OUTPUT.PUT_LINE('v_count ' || v_count);
    END;
    Output is
    p_out_count 0
    v_count 10140
    Expected output
    p_out_count 10140
    v_count 10140

  • Function not returning database rows properly in non-database item

    Hi,
    I have 3 database items that I'd like to concatenate into one field and display it in a non-database item. I have setup two different methods to do this for testing purposes. First, I created three separate database items (SECTION, ROW, & SEAT_NUM) and a non-database item (SEAT). I created a formula (in SEAT) to do the concatenation and this way works fine. For my second method, I created a function where I selected the 3 fields and performed a concatenation into a single value to be returned in a seperate non-database item (SEAT_TEST).
    Here's my function:
    FUNCTION SeatLocation(p_id IN event.id%TYPE)
    RETURN VARCHAR2 IS
    CURSOR a IS
    (SELECT ltrim(rtrim(event.section,' '),' ')||' '||
    ltrim(rtrim(event.row,' '),' ')||' '||
    ltrim(rtrim(event.seat_num,' '),' ') seat
    FROM event
    WHERE event.id = p_id);
    BEGIN
    FOR rec IN a LOOP
    IF rec.seat IS NOT NULL THEN
    RETURN rec.seat;
    ELSE
    RETURN ' ';
    END IF;
    END LOOP;
    END SeatLocation;
    And I'm calling it in a POST_QUERY trigger with the following: :event.seat_test := SeatLocation(:event.id);
    I put both non-database items side-by-side, run the form, and the first method works fine. I doesn't quite work for the function to display in SEAT_TEST. For my program, an ID can have multiple seat locations and I'd like to display all those seats as I scroll through the form (for a given ID). What the function is returning is only the first records seat location even though there are two more locations (from the remaining two records) that need to be displayed, but are not. It works fine for the formula method. Is there a work around this within my function code and/or the SEAT_TEST item? I'd like to keep my function instead because I could use the code elsewhere. I thought that since there is more than one record retrieved for a particular ID, the for loop would return one value each loop iteration and display the different value seat locations as I scroll/arrow down through the form. I didn't know if you had to call the POST-QUERY trigger multiple times for the number or records you retrieve in the cursor. I hope this makes sense.
    Any advice would be greatly appreciated.
    Thank you,
    Eric

    Even though your function is written to loop through multiple records, as soon as it hits the first one inside the FOR loop, it returns that value. The Return command is an exit, so the function is done, and you cannot expect it to magically run a second time just because the cursor found more than one row.
    You need to pass the function all the parameters to form a unique key into the row you are looking up. ID is not unique.

  • Stored function not returning result set unless recompiled

    Hi,
    I have a strange situation going on with a basic Java (1.6.0.17) application talking to an Oracle 11g (11.2.0.1.0) database. Basically what is happening is that sometimes a stored function's return value (a result set) is not making it as far as JDBC/Java, unless I recompile the stored function (with absolutely no changes to the application or function's code). I am always able to successfully see the result set if I call the function directly from within SQL Developer, just not on the Java app/JDBC side.
    I've tried running with 3 different physical Oracle 11g servers and tried running the app on a couple of machines. I'm wondering if this is either some kind of caching issue or perhaps a JDBC bug/misconfiguration.
    Any help would be greatly appreciated. Attached to this message:
    1. stored function code
    2. snippet of Java app code
    3. ODBC trace output when returned a empty result set (ie failure scenario)
    4. ODBC trace out when returned the correct result set (ie success scenario)
    * it's helpful if you compare the texts of 3 & 4 with Vim diff or WinMerge etc.
    ** as they're large I've just extracted the sections that had differences. Leave a message here and I can send you the full ones if necessary.
    1. stored function code
    ===============
    FUNCTION getRecordSet (
    ActionId Number
    RETURN CallingList.ref_cursor
    IS
    myDataCursor CallingList.ref_cursor;
    ActionId_ Number;
    BEGIN
    ActionId_ := ActionId;
    IF isActionExpired(ActionId) <= 0 THEN
    ActionId_ := 0;
    END IF;
    OPEN myDataCursor FOR
    SELECT
    C.ID,
    C.CUSTOMER_ID,
    C.CAMPAIGN_ID,
    c.phone,
    C.TRANSFERDN,
    (SELECT
    TTS_MESSAGE
    FROM CAMPAIGN CMP
    WHERE CMP.CAMPAIGN_ID = C.CAMPAIGN_ID) "TTS"
    FROM
    CALLING_LIST C
    WHERE
    C.ACTION_ID = ActionId_
    AND
    C.CALL_STATUS = 1
    AND
    C.CALLCOUNT > 0
    And rownum <=5;
    RETURN myDataCursor;
    EXCEPTION
    WHEN CURSOR_ALREADY_OPEN THEN
    RETURN NULL;
    WHEN INVALID_CURSOR THEN
    RETURN NULL;
    WHEN NO_DATA_FOUND THEN
    RETURN NULL;
    END getRecordSet;
    ....and the isActionExpired function that is called from within getResultSet is (but for all my testing it's been returning 1 with no problems)
    FUNCTION isActionExpired (
    ActionId number
    ) RETURN number
    AS
    Today varchar2(12);
    myCount number(6);
    BEGIN
    myCount := 0;
    today := to_char(sysdate, 'dd.mm.yyyy');
    SELECT
    count(*)
    INTO
    myCount
    FROM
    ACTION A
    where
    ACTION_ID = ActionId
    AND
    SYSDATE BETWEEN ACTION_STARTDATETIME
    AND
    ACTION_STOPDATETIME
    and
    SYSDATE BETWEEN to_date(today || ' ' || A.STARTTIME, 'dd.mm.yyyy HH24:MI:SS') and to_date(today || ' ' || A.ENDTIME, 'dd.mm.yyyy HH24:MI:SS')
    AND
    ACTION_STATUS = 1;
    return myCount;
    END isActionExpired;
    2. snippet of Java app code
    =================
    ... db connect logic...
    javax.management.MBeanServer mbs = null;
    javax.management.ObjectName name = null;
    try {
    String loader = Thread.currentThread().getContextClassLoader().toString().replaceAll("[,=:\"]+", "");
    name = new javax.management.ObjectName("com.oracle.jdbc:type=diagnosability,name="+loader);
    mbs = java.lang.management.ManagementFactory.getPlatformMBeanServer();
    mbs.setAttribute(name, new javax.management.Attribute("LoggingEnabled", true));
    } catch (Exception e) {
    System.out.println("ORACLE TRACE ERROR: " + e.getStackTrace());
    try {
    String query = "begin ? := CALLINGLIST.getRecordSet(?); end;";
    CallableStatement stmt = conn.prepareCall(query);
    stmt.registerOutParameter(1, OracleTypes.CURSOR);
    stmt.setInt(2, actionId);
    stmt.execute();
    ResultSet rs = (ResultSet) stmt.getObject(1); // So, here it works.
    // print the results
    int count=0;
    while (rs.next()) {
    count++;
    stmt.close();
    System.out.println("rs count was: " + count);
    } catch (SQLException e) {
    System.out.println("Exception occurred: " + e.getMessage());
    3. ODBC trace output when returned a empty result set (ie failure scenario)
    ===============================================
    Jul 1, 2010 3:30:47 PM oracle.net.ns.Packet receive
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.net.ns.Packet receive
    TRACE_20: Debug: type=6, length=121, flags=0
    00 79 00 00 06 00 00 00 |.y......|
    00 00 06 22 01 06 00 01 |..."....|
    0A 00 00 00 07 03 C2 04 |........|
    0E 04 C3 5E 22 03 02 C1 |...^"...|
    2A 04 33 30 30 32 03 37 |*.3002.7|
    37 37 05 48 65 6C 6C 6F |77.Hello|
    08 01 06 00 00 01 02 00 |........|
    00 00 00 00 00 04 01 05 |........|
    01 01 02 05 7B 00 00 01 |....{...|
    02 00 03 00 00 00 00 00 |........|
    00 00 00 00 00 00 00 00 |........|
    00 01 01 00 00 00 00 19 |........|
    4F 52 41 2D 30 31 34 30 |ORA-0140|
    33 3A 20 6E 6F 20 64 61 |3:.no.da|
    74 61 20 66 6F 75 6E 64 |ta.found|
    0A |. |
    Jul 1, 2010 3:30:47 PM oracle.net.ns.Packet receive
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
    TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 1, [I@1315d34, 20
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
    TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 1, 871, [I@1315d34, 20, oracle-character-set-830, oracle-character-set-2000, oracle-character-set-871, false
    Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
    TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 1, [I@1315d34, true, 20
    Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
    TRACE_16: return: 4
    Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
    TRACE_16: return: 4
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
    TRACE_16: return: 4
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
    TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 211, [I@1de256f, 10
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
    TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 211, 871, [I@1de256f, 10, oracle-character-set-830, oracle-character-set-2000, oracle-character-set-871, false
    Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
    TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 211, [I@1de256f, true, 10
    Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
    TRACE_16: return: 3
    Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
    TRACE_16: return: 3
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
    TRACE_16: return: 3
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
    TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 321, [I@16bd8ea, 2000
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
    TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 321, 871, [I@16bd8ea, 2000, oracle-character-set-830, oracle-character-set-2000, oracle-character-set-871, false
    Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
    TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 321, [I@16bd8ea, true, 2000
    Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
    TRACE_16: return: 5
    Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
    TRACE_16: return: 5
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
    TRACE_16: return: 5
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CConnection updateSessionProperties
    TRACE_16: Enter: [Loracle.jdbc.internal.KeywordValue;@16e1fb1
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CConnection updateSessionProperties
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CStatement fetch
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement checkValidRowsStatus
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement checkValidRowsStatus
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl <init>
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CResultSetAccessor getCursor
    TRACE_16: return: oracle.jdbc.driver.OracleResultSetImpl@e2cb55
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CResultSetAccessor getCursor
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.ResultSetAccessor getObject
    TRACE_16: return: oracle.jdbc.driver.OracleResultSetImpl@e2cb55
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.ResultSetAccessor getObject
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleCallableStatement getObject
    TRACE_1: return: oracle.jdbc.driver.OracleResultSetImpl@e2cb55
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleCallableStatement getObject
    TRACE_1: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleCallableStatementWrapper getObject
    TRACE_30: return: oracle.jdbc.driver.OracleResultSetImpl@e2cb55
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleCallableStatementWrapper getObject
    TRACE_30: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl next
    TRACE_1: Public Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl next
    TRACE_20: Debug: closed=false, statement.currentRow=-1, statement.totalRowsVisited=0, statement.maxRows=0, statement.validRows=1, statement.gotLastBatch=true
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl next
    TRACE_1: return: true
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl next
    TRACE_1: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl next
    TRACE_1: Public Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl next
    TRACE_20: Debug: closed=false, statement.currentRow=0, statement.totalRowsVisited=1, statement.maxRows=0, statement.validRows=1, statement.gotLastBatch=true
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl internal_close
    TRACE_16: Enter: false
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.BaseResultSet close
    TRACE_16: Public Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.BaseResultSet close
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection registerHeartbeat
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection registerHeartbeat
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection needLine
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection needLineUnchecked
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection needLineUnchecked
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection needLine
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CStatement closeQuery
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CConnection assertLoggedOn
    TRACE_16: Enter: "oracle.jdbc.driver.T4CStatement.closeQuery"
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CConnection assertLoggedOn
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CStatement closeQuery
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement endOfResultSet
    TRACE_16: Enter: false
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement prepareForNewResults
    TRACE_16: Enter: false, false
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement clearWarnings
    TRACE_16: Public Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement clearWarnings
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl internal_close
    TRACE_16: Enter: true
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl internal_close
    TRACE_16: return:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl internal_close
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement prepareForNewResults
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CStatement clearDefines
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement clearDefines
    TRACE_16: Public Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement freeLine
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement freeLine
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement cleanupDefines
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection cacheBuffer
    TRACE_16: Enter: [B@8e32e7
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.BufferCache put
    TRACE_16: Enter: [B@8e32e7
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.BufferCache put
    TRACE_30: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection cacheBuffer
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection cacheBuffer
    TRACE_16: Enter: [C@1b000e7
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.BufferCache put
    TRACE_16: Enter: [C@1b000e7
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.BufferCache put
    TRACE_30: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection cacheBuffer
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement cleanupDefines
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement clearDefines
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CStatement clearDefines
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement endOfResultSet
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl internal_close
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl next
    TRACE_1: return: false
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl next
    TRACE_1: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleCallableStatementWrapper close
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OraclePreparedStatementWrapper close
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatementWrapper close
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement close
    TRACE_1: Public Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement closeOrCache
    TRACE_16: Enter: null
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection isStatementCacheInitialized
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection isStatementCacheInitialized
    4. ODBC trace out when returned the correct result set (ie success scenario)
    ===============================================
    TRACE_16: Enter:
    Jul 1, 2010 3:30:07 PM oracle.net.ns.Packet receive
    TRACE_20: Debug: type=6, length=82, flags=0
    00 52 00 00 06 00 00 00    |.R......|
    00 00 08 01 06 00 00 01    |........|
    02 00 00 00 00 00 00 04    |........|
    01 05 00 02 05 7B 00 00    |.....{..|
    01 02 00 03 00 00 00 00    |........|
    00 00 00 00 00 00 00 00    |........|
    00 00 01 01 00 00 00 00    |........|
    19 4F 52 41 2D 30 31 34    |.ORA-014|
    30 33 3A 20 6E 6F 20 64    |03:.no.d|
    61 74 61 20 66 6F 75 6E    |ata.foun|
    64 0A                      |d.      |
    Jul 1, 2010 3:30:07 PM oracle.net.ns.Packet receive
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CConnection updateSessionProperties
    TRACE_16: Enter: [Loracle.jdbc.internal.KeywordValue;@1fa1bb6
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CConnection updateSessionProperties
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CStatement fetch
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleResultSetImpl internal_close
    TRACE_16: Enter: false
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.BaseResultSet close
    TRACE_16: Public Enter:
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.BaseResultSet close
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection registerHeartbeat
    TRACE_16: Enter:
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection registerHeartbeat
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection needLine
    TRACE_16: Enter:
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection needLineUnchecked
    TRACE_16: Enter:
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection needLineUnchecked
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection needLine
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CStatement closeQuery
    TRACE_16: Enter:
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CConnection assertLoggedOn
    TRACE_16: Enter: "oracle.jdbc.driver.T4CStatement.closeQuery"
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CConnection assertLoggedOn
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CStatement closeQuery
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement endOfResultSet
    TRACE_16: Enter: false
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement prepareForNewResults
    TRACE_16: Enter: false, false
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement clearWarnings
    TRACE_16: Public Enter:
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement clearWarnings
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement prepareForNewResults
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CStatement clearDefines
    TRACE_16: Enter:
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement clearDefines
    TRACE_16: Public Enter:
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement freeLine
    TRACE_16: Enter:
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement freeLine
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement cleanupDefines
    TRACE_16: Enter:
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection cacheBuffer
    TRACE_16: Enter: [B@8e32e7
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.BufferCache put
    TRACE_16: Enter: [B@8e32e7
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.BufferCache put
    TRACE_30: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection cacheBuffer
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection cacheBuffer
    TRACE_16: Enter: [C@1b000e7
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.BufferCache put
    TRACE_16: Enter: [C@1b000e7
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.BufferCache put
    TRACE_30: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection cacheBuffer
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement cleanupDefines
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement clearDefines
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CStatement clearDefines
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement endOfResultSet
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleResultSetImpl internal_close
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleResultSetImpl <init>
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CResultSetAccessor getCursor
    TRACE_16: return: oracle.jdbc.driver.OracleResultSetImpl@1315d34
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CResultSetAccessor getCursor
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.ResultSetAccessor getObject
    TRACE_16: return: oracle.jdbc.driver.OracleResultSetImpl@1315d34
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.ResultSetAccessor getObject
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleCallableStatement getObject
    TRACE_1: return: oracle.jdbc.driver.OracleResultSetImpl@1315d34
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleCallableStatement getObject
    TRACE_1: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleCallableStatementWrapper getObject
    TRACE_30: return: oracle.jdbc.driver.OracleResultSetImpl@1315d34
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleCallableStatementWrapper getObject
    TRACE_30: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleResultSetImpl next
    TRACE_1: Public Enter:
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleResultSetImpl next
    TRACE_20: Debug: closed=true, statement.currentRow=-1, statement.totalRowsVisited=0, statement.maxRows=0, statement.validRows=0, statement.gotLastBatch=false
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleResultSetImpl next
    Edited by: user9376621 on Jul 1, 2010 1:07 AM
    Edited by: user9376621 on Jul 1, 2010 1:13 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         

    Please ignore this, it was a non-issue in the end.

  • Why does my function not return anything when I create as a schema object

    I have user ABC who owns several tables some of which have foreign key constraints.
    I have user XYZ that has been granted access to all tables owned by user ABC.
    When I create a function as user XYZ using following I get no return when I issue:
    select XYZ.ztm_tables_depended_on('ABC', 'A_TABLE_OWNED_BY_ABC') from dual :
    Please see after function definition.
    CREATE OR REPLACE FUNCTION ZTM_TABLES_DEPENDED_ON(p_Owner VARCHAR2, p_Table_Name VARCHAR2) RETURN VARCHAR2 IS
      CURSOR C1 IS
      SELECT OWNER, CONSTRAINT_NAME, R_OWNER, R_CONSTRAINT_NAME
      FROM   ALL_CONSTRAINTS
      WHERE  OWNER           = p_Owner
      AND    TABLE_NAME      = p_Table_Name
      AND    CONSTRAINT_TYPE = 'R'
      ORDER  BY OWNER, CONSTRAINT_NAME, R_OWNER, R_CONSTRAINT_NAME;
      v_Referenced_Owner       VARCHAR2(31);
      v_Ret_Val                VARCHAR2(4000);
      FUNCTION CONSTRAINT_TABLE_NAME(p_Owner VARCHAR2, p_Constraint_Name VARCHAR2) RETURN VARCHAR2 IS
        CURSOR C1 IS
        SELECT TABLE_NAME
        FROM   ALL_CONSTRAINTS
        WHERE  OWNER           = p_Owner
        AND    CONSTRAINT_NAME = p_Constraint_Name;
        v_Ret_Val ALL_CONSTRAINTS.TABLE_NAME%TYPE;
      BEGIN
        OPEN  C1;
        FETCH C1 INTO v_Ret_Val;
        CLOSE C1;
        RETURN v_Ret_Val;
      END;
    BEGIN
      FOR R IN C1 LOOP
        IF (R.OWNER <> R.R_OWNER) THEN v_Referenced_Owner := R.R_OWNER || '.';
        ELSE                           v_Referenced_Owner := NULL;
        END IF;
        v_Ret_Val := v_Ret_Val || ', ' || v_Referenced_Owner || CONSTRAINT_TABLE_NAME (R.R_OWNER, R.R_CONSTRAINT_NAME);
      END LOOP;
      RETURN LTRIM(v_Ret_Val, ', ');
    END;
    But, if I embed the function within an anonymous block as follows, I get results:
    DECLARE
      CURSOR C1 IS
      select owner, table_name
      FROM   all_tables where owner = 'ABC';
      FUNCTION ZTM_TABLES_DEPENDED_ON(p_Owner VARCHAR2, p_Table_Name VARCHAR2) RETURN VARCHAR2 IS
        CURSOR C1 IS
        SELECT OWNER, CONSTRAINT_NAME, R_OWNER, R_CONSTRAINT_NAME
        FROM   ALL_CONSTRAINTS
        WHERE  OWNER           = p_Owner
        AND    TABLE_NAME      = p_Table_Name
        AND    CONSTRAINT_TYPE = 'R'
        ORDER  BY OWNER, CONSTRAINT_NAME, R_OWNER, R_CONSTRAINT_NAME;
        v_Referenced_Owner       VARCHAR2(31);
        v_Ret_Val                VARCHAR2(4000);
        FUNCTION CONSTRAINT_TABLE_NAME(p_Owner VARCHAR2, p_Constraint_Name VARCHAR2) RETURN VARCHAR2 IS
          CURSOR C1 IS
          SELECT TABLE_NAME
          FROM   ALL_CONSTRAINTS
          WHERE  OWNER           = p_Owner
          AND    CONSTRAINT_NAME = p_Constraint_Name;
          v_Ret_Val ALL_CONSTRAINTS.TABLE_NAME%TYPE;
        BEGIN
          OPEN  C1;
          FETCH C1 INTO v_Ret_Val;
          CLOSE C1;
          RETURN v_Ret_Val;
        END;
      BEGIN
        FOR R IN C1 LOOP
          IF (R.OWNER <> R.R_OWNER) THEN v_Referenced_Owner := R.R_OWNER || '.';
          ELSE                           v_Referenced_Owner := NULL;
          END IF;
          v_Ret_Val := v_Ret_Val || ', ' || v_Referenced_Owner || CONSTRAINT_TABLE_NAME (R.R_OWNER, R.R_CONSTRAINT_NAME);
        END LOOP;
        RETURN LTRIM(v_Ret_Val, ', ');
      END;
    BEGIN
      FOR R IN C1 LOOP
        DBMS_OUTPUT.PUT_LINE(ztm_tables_depended_on(R.Owner, R.Table_Name));
      END LOOP;
    END;
    Any ideas what is happening here?

    Any ideas what is happening here?
    Justin explained the probable reason.
    See the 'How Roles Work in PL/SQL Blocks' section of the database security doc for the details
    http://docs.oracle.com/cd/E25054_01/network.1111/e16543/authorization.htm#i1007304
    How Roles Work in PL/SQL Blocks
    The use of roles in a PL/SQL block depends on whether it is an anonymous block or a named block (stored procedure, function, or trigger), and whether it executes with definer's rights or invoker's rights.
    Roles Used in Named Blocks with Definer's Rights
    All roles are disabled in any named PL/SQL block (stored procedure, function, or trigger) that executes with definer's rights. Roles are not used for privilege checking and you cannot set roles within a definer's rights procedure.
    The SESSION_ROLES view shows all roles that are currently enabled. If a named PL/SQL block that executes with definer's rights queries SESSION_ROLES, then the query does not return any rows.
    Roles Used in Named Blocks with Invoker's Rights and Anonymous PL/SQL Blocks
    Named PL/SQL blocks that execute with invoker's rights and anonymous PL/SQL blocks are executed based on privileges granted through enabled roles. Current roles are used for privilege checking within an invoker's rights PL/SQL block. You can use dynamic SQL to set a role in the session.
    See that line starting with 'All roles are disables in any named PL/SQL block'?

  • Function not returning right value

    I have this following function, based on the return value from this function, I am inserting a row into the GROUP_MAP table.
    This function is returning a value greater than zero even though constrains would not let it select any rows.
    It looks as if it is not applying the "AND STRING_CODE = String_Code" constraint to the result set. If there are two records matching the groupOID I passed it is returning two as the count(*). I checked by executing the query directly and I got 0 as the result. I sounds so strange. Is there any thing I am doing wrong ?
    Thanks in Advance,
    -Bhasker
    FUNCTION FIND_CODE_GROUP (groupOID IN NUMBER, String_Code IN VARCHAR2)
                   RETURN NUMBER
              AS
                        RETURN_VAL NUMBER(10);
                   BEGIN
                        RETURN_VAL := 0;
                        SELECT
                             COUNT(*)
                        INTO
                             RETURN_VAL
                        FROM
                             GROUP_MAP
                        WHERE
                             STRING_GROUP = groupOID AND STRING_CODE = String_Code;
                        DBMS_OUTPUT.PUT_LINE('RETURN_VAL:'|| RETURN_VAL || ' String code : ' || STRING_CODE);
                        RETURN(RETURN_VAL);
                        EXCEPTION
                             WHEN OTHERS THEN
                                  RETURN(0);
                   END FIND_CODE_GROUP;

    FUNCTION FIND_CODE_GROUP (groupOID IN NUMBER, String_Code IN VARCHAR2)
                   RETURN NUMBER
              AS
                        RETURN_VAL NUMBER(10);
                   BEGIN
                        RETURN_VAL := 0;
                        SELECT
                             COUNT(*)
                        INTO
                             RETURN_VAL
                        FROM
                             GROUP_MAP
                        WHERE
                             STRING_GROUP = groupOID AND STRING_CODE = String_Code;The second parameter to your function has the same name as the column name "STRING_CODE" in your table. You should change
    the name of your second parameter to something other than "STRING_CODE".

  • Table-Valued Function not returning any results

    ALTER FUNCTION [dbo].[fGetVendorInfo]
    @VendorAddr char(30),
    @RemitAddr char(100),
    @PmntAddr char(100)
    RETURNS
    @VendorInfo TABLE
    vengroup char(25),
    vendnum char(9),
    remit char(10),
    payment char(10)
    AS
    BEGIN
    insert into @VendorInfo (vengroup,vendnum)
    select ks183, ks178
    from hsi.keysetdata115
    where ks184 like ltrim(@VendorAddr) + '%'
    update @VendorInfo
    set remit = r.remit
    from
    @VendorInfo ven
    INNER JOIN
    (Select ksd.ks188 as remit, ksd.ks183 as vengroup, ksd.ks178 as vendnum
    from hsi.keysetdata117 ksd
    inner join @VendorInfo ven
    on ven.vengroup = ksd.ks183 and ven.vendnum = ksd.ks178
    where ksd.ks192 like ltrim(@RemitAddr) + '%'
    and ks189 = 'R') r
    on ven.vengroup = r.vengroup and ven.vendnum = r.vendnum
    update @VendorInfo
    set payment = p.payment
    from
    @VendorInfo ven
    INNER JOIN
    (Select ksd.ks188 as payment, ksd.ks183 as vengroup, ksd.ks178 as vendnum
    from hsi.keysetdata117 ksd
    inner join @VendorInfo ven
    on ven.vengroup = ksd.ks183 and ven.vendnum = ksd.ks178
    where ksd.ks192 like ltrim(@PmntAddr) + '%'
    and ks189 = 'P') p
    on ven.vengroup = p.vengroup and ven.vendnum = p.vendnum
    RETURN
    END
    GO
    Hi all,
    I'm having an issue where my Table-Valued Function is not returning any results.
    When I break it out into a select statement (creating a table, and replacing the passed in parameters with the actual values) it works fine, but with passing in the same exact values (copy and pasted them) it just retuns an empty table.
    The odd thing is I could have SWORN this worked on Friday, but not 100% sure.
    The attached code is my function.
    Here is how I'm calling it:
    SELECT * from dbo.fGetVendorInfo('AUDIO DIGEST', '123 SESAME ST', 'TOP OF OAK MOUNTAIN')
    I tried removing the "+ '%'" and passing it in, but it doesn't work.
    Like I said if I break it out and run it as T-SQL, it works just fine.
    Any assistance would be appreciated.

    Why did you use a proprietary user function instead of a VIEW?  I know the answer is that your mindset does not use sets. You want procedural code. In fact, I see you use an “f-” prefix to mimic the old FORTRAN II convention for in-line functions! 
    Did you know that the old Sybase UPDATE.. FROM.. syntax does not work? It gives the wrong answers! Google it. 
    Your data element names make no sense. What is “KSD.ks188”?? Well, it is a “payment_<something>”, “KSD.ks183” is “vendor_group” and “KSD.ks178” is “vendor_nbr” in your magical world where names mean different things from table to table! 
    An SQL programmer might have a VIEW with the information, something like:
    CREATE VIEW Vendor_Addresses
    AS
    SELECT vendor_group, vendor_nbr, vendor_addr, remit_addr, pmnt_addr
      FROM ..
     WHERE ..;
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Function not returning any rows

    If I run this code with a standard SQL statement it will return (1) row - which is correct. But when I try to use a function it is not returning any records. Could someone point what I'm doing wrong?
    Also, if a use BindByName if get Oracle error: ORA-06550: line 1, column 50: PLS-00103: Encountered the symbol ">". If I comment out BindByName I will not get this error . Thanks!
    C# code:
    string domainuser = 'brockj';
    string ConnectString = ConfigurationSettings.AppSettings["ConnectString"];
    OracleConnection dbconn = new OracleConnection(ConnectString);
    OracleCommand cmd = new OracleCommand("access_admin",dbconn);
    cmd.CommandType = CommandType.StoredProcedure;
    //cmd.BindByName = true;
    OracleParameter p_username = new OracleParameter();
    OracleParameter p_retval = new OracleParameter();
    p_username.OracleDbType = OracleDbType.Varchar2;
    p_retval.OracleDbType = OracleDbType.Int16;
    p_username.Direction = ParameterDirection.Input;
    p_retval.Direction = ParameterDirection.ReturnValue;
    p_username.Value = domainuser;
    cmd.Parameters.Add(p_username);
    cmd.Parameters.Add(p_retval);
    dbconn.Open();
    cmd.ExecuteScalar();
    lblResponse.Text = p_retval.Value.ToString(); -- prints '0', should print '3'
    ********FUNCTION************
    Function access_admin
    p_username IN varchar2
    RETURN number
    IS
    l_accesscode users.access_admin%TYPE; -- number(1)
    cursor c1 IS
         SELECT access_admin
         FROM users
         WHERE username = p_username
         AND active=1
         AND rownum=1;
    BEGIN
    open c1;
    fetch c1 into l_accesscode;
    if c1%NOTFOUND then
         l_accesscode := 0;
    end if;
    close c1;
    RETURN l_accesscode;
    END access_admin;

    Turn the function call into a standard SQL statement:
    SELECT access_admin FROM dual;
    Here's how you use BindByName:
    adapter = new OracleDataAdapter();
    adapter.SelectCommand = new OracleCommand("SELECT * FROM emp WHERE sal >= :SAL OR empno = :EMPNO", conn);
    adapter.SelectCommand.BindByName = true;
    adapter.SelectCommand.Parameters.Add(new OracleParameter("EMPNO", OracleDbType.Int32, 0));
    adapter.SelectCommand.Parameters["EMPNO"].Value = 7788;
    adapter.SelectCommand.Parameters.Add(new OracleParameter("SAL", OracleDbType.Int32, 0));
    adapter.SelectCommand.Parameters["SAL"].Value = 2000;
    -- Tom

  • Function not returning table object correctly

    Instead of returning a table, my function is returning this:
    SCHEMA_OWNER.TBL_SUMS([SCHEMA_OWNER.SUMS_OBJ])
    Does anyone see a syntax error in my function or the ddl of my table and object types?
    This is a stripped down, simplified version of my function:
    create or replace FUNCTION "F_TEST" (p_skey number, p_start_date date, p_end_date date)
    RETURN tbl_sums
    IS
    tmp_A NUMBER;
    tmp_B NUMBER;
    l_tbl tbl_sums := tbl_sums();
    BEGIN
    SELECT SUM(FieldA), SUM(FieldB)
    into tmpA, tmpB
    from myTable where SKEY = p_skey
    and DATE_VALUE >= p_start_date
    and DATE_VALUE < p_end_date;
    l_tbl.extend;
    l_tbl(l_tbl.count()) := sums_obj(p_start_date, p_end_date, p_skey, tmpA, tmpB);
    return l_tbl;
    END;
    My types are:
    create or replace type sums_obj is object (start_date DATE, end_date DATE, skey NUMBER, SumA NUMBER, SumB NUMBER);
    create or replace type tbl_sums is table of sums_obj;
    Thanks!

    >
    RETURN tbl_kpi
    >
    What is 'tbl_kpi'? That isn't defined anywhere. Your original post said this:
    >
    RETURN tbl_sums
    >
    We can't help you if you don't post what you are really using. Cut & Paste is ok but you have to paste the correct code.
    Your funtion is returning a TABLE but it is NOT PIPELINED. So if you query the function from DUAL you will get a DATASET as the result.
    If you query the function AS A TABLE you will get the 'contents' of the table.
    If you make your function a PIPELINED function then you use PIPE ROW to return each row but the function is still declared to return a TABLE. Maybe that is what is confusing you.
    Try the following sample code to see what the difference is.
    Here are two SQL types based on the EMP table in the scott schema.
    -- type to match emp record
    create or replace type emp_scalar_type as object
      (EMPNO NUMBER(4) ,
       ENAME VARCHAR2(10),
       JOB VARCHAR2(9),
       MGR NUMBER(4),
       HIREDATE DATE,
       SAL NUMBER(7, 2),
       COMM NUMBER(7, 2),
       DEPTNO NUMBER(2)
    -- table of emp records
    create or replace type emp_table_type as table of emp_scalar_type
    /Now - here is a function (similar to yours) that returns that EMP_TABLE_TYPE. NOTE: the function IS NOT PIPELINED
    CREATE OR REPLACE function SCOTT.get_emp1( p_deptno in number )
      return emp_table_type
      as
    tb emp_table_type;
    BEGIN
      select emp_scalar_type(empno, ename, job, mgr, hiredate, sal, comm, deptno)
        bulk collect into tb from emp where deptno = p_deptno;
      return tb;
    end;
    /If I just select the function itself from DUAL I get this:
    select get_emp1(20) from dual
    GET_EMP1(20)
    (DATASET)I can use TOAD or sql developer to examine that dataset and see the records.
    But I can actually query the records by using the TABLE function:
    select * from table(get_emp1(20))
    EMPNO     ENAME     JOB     MGR     HIREDATE     SAL     COMM     DEPTNO
    7369     SMITH     CLERK     7902     12/17/1980     800          20
    7566     JONES     MANAGER     7839     4/2/1981     2975          20
    7788     SCOTT     ANALYST     7566     4/19/1987     3000          20
    7876     ADAMS     CLERK     7788     5/23/1987     1100          20
    7902     FORD     ANALYST     7566     12/3/1981     3000          20This is a similar function. It returns the same EMP_TABLE_TYPE but it is a PIPELINED function.
    -- pipelined function
    create or replace function get_emp( p_deptno in number )
      return emp_table_type
      PIPELINED
      as
       TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE;
        emp_cv EmpCurTyp;
        l_rec  emp%rowtype;
      begin
        open emp_cv for select * from emp where deptno = p_deptno;
        loop
          fetch emp_cv into l_rec;
          exit when (emp_cv%notfound);
          pipe row( emp_scalar_type( l_rec.empno, LOWER(l_rec.ename),
              l_rec.job, l_rec.mgr, l_rec.hiredate, l_rec.sal, l_rec.comm, l_rec.deptno ) );
        end loop;
        return;
      end;
      /The ONLY way I can query this function is by using the TABLE function:
    select * from table(get_emp(20))
    EMPNO     ENAME     JOB     MGR     HIREDATE     SAL     COMM     DEPTNO
    7369     smith     CLERK     7902     12/17/1980     800          20
    7566     jones     MANAGER     7839     4/2/1981     2975          20
    7788     scott     ANALYST     7566     4/19/1987     3000          20
    7876     adams     CLERK     7788     5/23/1987     1100          20
    7902     ford     ANALYST     7566     12/3/1981     3000          20The query of the PIPELINED function is the same and the result set is the same.
    The difference is that the PIPELINED function returns ONE ROW at a time and does NOT need to accumulate a lot of data in a collection before returning it. That collection uses expensive PGA memory and the more data you have the more memory it uses.
    Your function (and my similar one) doesn't return ANY data until it has produced ALL of it. And it uses that expensive PGA memory. What is the point of creating your collection one row at a time and waiting until you have it all before you return it?
    You could easily modify your function and add PIPELINED to the declaration. Then use the PIPE ROW clause to return each row as it is produced. That will eliminate the need for the collection (and memory) within the function.
    You can also then chain the function calls together if you need to.
    See 'Using Pipelined and Parallel Table Functions' in the Data Cartridge Developer's Guide
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28425/pipe_paral_tbl.htm
    There is little use for your function that is not pipelined but returns a table type unless you were storing that table-type in an object column of a table.
    There are many uses for PIPELINED functions.

  • Need help with MAX function to return values

    I am trying to create a report to return slow moving inventory data. One of the requests is that it return only the latest date that an item transacted upon. One sheet will show the last receipt date for a part, another will show the last time a part was issued or shipped on a sales order.
    The hiccup is that it is returning every single last time that an item was received, and every single last issuance of the material (on the second sheet) of items on hand.
    Could someone help me to define the max value function? As listed below, and many variations, the sheet comes up with no data or corrupt dates.
    MAX(Transaction Date MAX) OVER(PARTITION BY Material Transactions.Item ORDER BY Material Transactions.Item )
    Still returns both the following when in reality I just want the one with the most recent date (April 2010).
    100034     BNDSCE-105 - QUALITY BEARINGS OR EQUIVILANT     A400M     AB01D..     $0.00     WIP component issue     11-Sep-2009     -3
    100034     BNDSCE-105 - QUALITY BEARINGS OR EQUIVILANT     A400M     AD01D..     $0.00     WIP component issue     13-Apr-2010     -16
    Thank you for your assistance.
    Becka

    Hi Becka
    It does look correct. When I look at your data I can see 2 different items:
    100034 BNDSCE-105 - QUALITY BEARINGS OR EQUIVILANT A400M AB01D.. $0.00 WIP component issue 11-Sep-2009 -3
    100034 BNDSCE-105 - QUALITY BEARINGS OR EQUIVILANT A400M AD01D.. $0.00 WIP component issue 13-Apr-2010 -16
    One is AB01D and the other being AD01D. Is this expected?
    To get the right date you might want to PARTITION BY the BNDSCE-105 which might be the Item Number?
    If you can get your calculation to return the correct date then you next need to put in a new condition where the Transaction Date = MAX Transaction Date
    One part of the function that I would question is the use of MAX in both parts like this: MAX(Transaction Date MAX). You might be better just using MAX(Transaction Date) OVER ......
    Does this help?
    Best wishes
    Michael

  • MAX Function Not Giving Accurate Results

    Hello,
    I have the following sql
    select ename ,temp,max(ver) as rv from
    table
    WHERE id = 5000
    AND id2 = 8000
    group by ename ,tempProblem with the above is always gives two records, ideally it should give only one which should be max(ver).
    How can I resolve this issue?
    Regards

    I'm not sure whether you are looking this or not?
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    Elapsed: 00:00:00.02
    satyaki>
    satyaki>
    satyaki>with tt
      2  as
      3    (
      4      select 'THOMAS' ename, 'HR-022' temp, 2 ver from dual
      5      union all
      6      select 'EDWARD', 'FIN-011', 1 from dual
      7      union all
      8      select 'JOHN', 'IT-055', 3 from dual
      9      union all
    10      select 'JOHN', 'IT-055', 1 from dual
    11      union all
    12      select 'JOHN', 'IT-055', 2 from dual
    13    )
    14  select k.ename,
    15         k.temp,
    16         k.ver
    17  from (
    18          select m.*,
    19                 max(ver) over(partition by m.ename,m.temp order by m.ename,m.temp) rn
    20          from tt m
    21       ) k
    22  where k.ver = k.rn;
    ENAME  TEMP           VER
    EDWARD FIN-011          1
    JOHN   IT-055           3
    THOMAS HR-022           2
    Elapsed: 00:00:00.00
    satyaki>
    satyaki>Regards.
    Satyaki De.

  • Function not returning value in Discoverer report

    Hi All,
    I am using a PL/SQL function in a Discoverer Report to return a particular date. The way I am using is that I have created a PL/SQL function and registered the same in Discoverer Administatrator.
    My problem is that when i run the report this function returns NULL for one particular unit but when i run the same on toad as
    'select max_term_dt_pkg.max_term_dt_fn('703813','OM - AWAITING_SHIPPING - 1179628') from dual'
    it returns the date as 26-May-2009
    Actually it should return a value in the report also.
    Can anyone guide me what could be the problem.
    Regards,
    Shruti

    Hi Rod,
    There are no session variables to be set. I have myself created that and it is returning values for other units also.
    Below is the function :
    CREATE OR REPLACE PACKAGE BODY APPS.max_term_dt_pkg
    AS
    FUNCTION max_term_dt_fn (p_unit_num VARCHAR2, p_order_status VARCHAR2)
    RETURN DATE
    IS
    l_contract_number VARCHAR2 (20);
    --okc_k_headers_b.contract_number%TYPE;
    l_max_term_date DATE; --okc_k_lines_b.date_terminated%TYPE;
    BEGIN
    IF p_order_status IN ('RMA on Unit', 'OKS 30 Days Notice Given')
    THEN
    l_max_term_date := NULL;
    ELSE
    SELECT contract_number
    INTO l_contract_number
    FROM (SELECT DISTINCT okhb.sts_code, okhb.date_terminated,
    okhb.contract_number,
    oklb_ib.attribute15 unit, okhb.start_date,
    okhb.end_date, okhb.creation_date
    FROM apps.okc_k_headers_b okhb,
    apps.okc_k_lines_b oklb_ib --,
    WHERE okhb.ID = oklb_ib.dnz_chr_id
    AND lse_id = 9
    AND oklb_ib.attribute15 = p_unit_num
    ORDER BY okhb.start_date DESC,
    okhb.creation_date DESC)
    --ORDER BY okhb.start_date DESC)
    WHERE ROWNUM = 1;
    SELECT date_terminated
    INTO l_max_term_date
    FROM (SELECT oklb.dnz_chr_id, oklb.ID, oklb.date_terminated,
    oklb.sts_code, mic.category_concat_segs,
    mic.category_set_name
    FROM apps.okc_k_headers_b okhb,
    apps.okc_k_lines_b oklb,
    apps.okc_k_items oki,
    --apps.mtl_system_items_b msib,
    mtl_item_categories_v mic
    WHERE oklb.dnz_chr_id = okhb.ID
    AND okhb.contract_number = l_contract_number
    AND oklb.lse_id = 1
    AND oki.cle_id = oklb.ID
    -- AND msib.inventory_item_id = oki.object1_id1
    -- AND msib.organization_id = oki.object1_id2
    --AND segment1 = 'OKS-RNTL-MAINT-WH'
    --AND oklb.sts_code = 'TERMINATED'
    AND oklb.date_terminated IS NOT NULL
    AND mic.inventory_item_id = oki.object1_id1
    --msib.inventory_item_id
    AND mic.organization_id = oki.object1_id2
    --msib.organization_id
    AND mic.category_set_name = 'Product'
    AND mic.category_concat_segs = 'OKS-Base'
    ORDER BY oklb.date_terminated DESC)
    WHERE ROWNUM = 1;
    END IF;
    RETURN l_max_term_date;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    RETURN NULL;
    WHEN OTHERS
    THEN
    RETURN NULL;
    END;
    END;
    Regards,
    Shruti

  • Date function not returning any rows

    I am trying to pull back rows for data of people who were born in the 90s
         a.birthday >= to_date('01/01/90','dd/mm/yy')
         and     
              a.birthday <= to_date('31/12/90','dd/mm/yy')
    I know that there is definately users born in the 90s in my database but it returns 0 rows with the above ouptut Date format is like "05-FEB-93", have tried using dd/mon/yy but that gives an error

    user8652681 wrote:
    I am trying to pull back rows for data of people who were born in the 90s
         a.birthday >= to_date('01/01/90','dd/mm/yy')
         and     
              a.birthday <= to_date('31/12/90','dd/mm/yy')
    I know that there is definately users born in the 90s in my database but it returns 0 rows with the above ouptut Date format is like "05-FEB-93", have tried using dd/mon/yy but that gives an errorFirst off to_date('01/01/90','dd/mm/yy') is Jan 1, 2090. You need to use a four digit year.
    Secondly a.birthday >= to_date('01/01/1990','dd/mm/yyyy') and a.birthday <= to_date('31/12/1990','dd/mm/yyyy')
    is not everyone born in the 90's, it's everyone born in 1990. If you want everyone born in the 90's you need:
    a.birthday between to_date('01/01/1990','dd/mm/yyyy') and to_date('31/12/1999 23:59:59','dd/mm/yyyy hh24:mi:ss')I realize your birthdays are most likely trunc'ed so the time portion probably isn't necessary but I included it just to be safe.
    Edited by: kendenny on Jul 22, 2009 6:13 AM

  • Why does the "Format & Strip" function not return a number in the same format as "Format String"?

    I am using the "Format and String" function in a vi with the "string" input wired to a string of type "0.9998,0.9899,1.0003,0.9995, (etc)". I have wired the "format string" input to a string constant "%1.4f". Irrespective of the format string, I always get a number out that is rounded to 2 decimal places. I have tried different number formats in the format string, and I have wired a 4d.p. floating point number to "default". I have also set the precision of the format string to 4 d.p. with no effect. Any suggestions (or is the output always rounded to 2 d.p.)?

    Hi,
    If you are looking at the result in a numeric indicator, then the default setting is 2 places of decimal, that is displayed.
    You need to right click on the indicator and select Format & Precision then change the Digits of Precision value.
    Ray.
    Regards
    Ray Farmer

Maybe you are looking for

  • Sporadic Error in XLMP

    I get the following error (sporadically) when submitting a XML Publisher Report. Sometimes it works and other times it doesn't... totally random behavior. XML Report Publisher 5.0 Updating request description Waiting for XML request Retrieving XML re

  • How can i download photos from my imac to and iPad?

    How can i download photos to an Ipad 2?

  • PO Document type Authorizations

    All, Whether its possible to give authorizations based on PO Document types ? Authorization object is M_BEST_BSA. pLS ADVISE. REGARDS

  • Issue of Calculate Service Tax on Material

    Hi, I want to confirm one thing that Service Tax % will be calculated on Material or not during PO??? If yes then how it will show during MIRO, with Material Amount or separate line should be there for Service Tax. Please clarify....

  • Error encountered when Adding an Item style Flex in Search criteria

    Hi All, I am trying to add an Item style Flex in the Searchable region(search criteria region) ,then I have encountered an error saying Program error. Please inform your support representative that the descriptive flexfield in the application could n