Return the latest data of the transaction, based on the transaction dates.

Thank you I am a little dense here, and I've searched, read and tried out a few different solutions I've seen give around the place. However; I think I'm more fighting with the naming conventions and the logic of other persons requests you to mine understanding (hoping here!)

I have a huge table that contains a record for each transaction that has an effect on our inventory (yup - LARGE table!)

For a given transaction type "CHC" (fresh), I want to return the part code, the Transaction Date and the costs of Transaction for TWO LAST changes.

Because its to be used for tracking updates to the cost of the materials and further for the calculation of the continuous effect of these, I just need the two for now.

Thus,.

The table is I50F

The required columns are

I50PART - [Code part | http://forums.oracle.com/forums/]
I50TDAT - [Date of the Transaction | http://forums.oracle.com/forums/]
I50UCOST - [price changed to | http://forums.oracle.com/forums/]
I50TRNS - [Type of Transaction - we want just that CHC]

Examples of data (including columns fair that we are interested in)
I50PART              I50TDAT             I50UCOST         I50TRNS 

BACCA001             08/03/2006 07:34:51 0.08829          CHC     
BACCA001             25/07/2007 08:26:30 0.10329          CHC     
BACCA001             10/04/2008 16:29:02 0.10639          CHC     
BACCA003             20/06/2006 12:22:30 0.16814          CHC     
BACCA003             25/07/2007 08:26:54 0.17024          CHC     
BACCA003             10/04/2008 13:30:12 0.17535          CHC     
BACCA004             28/08/2007 15:46:03 0.06486          CHC     
BACCA004             28/08/2007 15:49:15 0.06328          CHC     
BACCA004             30/10/2008 09:22:40 0.06952          CHC     
BACCA004             13/01/2009 09:09:07 0.06867          CHC     
BACCA005             25/07/2007 08:27:24 0.06715          CHC     
BACCA005             10/04/2008 15:45:14 0.06916          CHC     
BACCA005             30/10/2008 09:05:17 0.07453          CHC     
BACCA005             13/01/2009 09:06:49 0.07275          CHC     
Take a part in isolation, BACCA005;

I am interested in two past reviews.

It is logical that there are two records by part of output at this stage, as it is possible that the power decide they want the last 3 or 4 or whatever (I'm sure everyone has similar experiences with beancouters)

Is this A) easy and B) relatively effective. There are 2.4 million records in the table.


If I was stupid and not included is not enough information, you please poke me [metaphorically] in my eyes, and I'm going to pad a little.

Thank you very much for reading - and even more so if you can help!

See you soon

J

Analytical functions FTW!

with I50F as (select 'BACCA001' I50PART, to_date('08/03/2006 07:34:51', 'dd/mm/yyyy hh24:mi:ss') I50TDAT, 0.08829 I50UCOST, 'CHC' I50TRNS from dual union all
              select 'BACCA001' I50PART, to_date('25/07/2007 08:26:30', 'dd/mm/yyyy hh24:mi:ss') I50TDAT, 0.10329 I50UCOST, 'CHC' I50TRNS from dual union all
              select 'BACCA001' I50PART, to_date('10/04/2008 16:29:02', 'dd/mm/yyyy hh24:mi:ss') I50TDAT, 0.10639 I50UCOST, 'CHC' I50TRNS from dual union all
              select 'BACCA003' I50PART, to_date('20/06/2006 12:22:30', 'dd/mm/yyyy hh24:mi:ss') I50TDAT, 0.16814 I50UCOST, 'CHC' I50TRNS from dual union all
              select 'BACCA003' I50PART, to_date('25/07/2007 08:26:54', 'dd/mm/yyyy hh24:mi:ss') I50TDAT, 0.17024 I50UCOST, 'CHC' I50TRNS from dual union all
              select 'BACCA003' I50PART, to_date('10/04/2008 13:30:12', 'dd/mm/yyyy hh24:mi:ss') I50TDAT, 0.17535 I50UCOST, 'CHC' I50TRNS from dual union all
              select 'BACCA004' I50PART, to_date('28/08/2007 15:46:03', 'dd/mm/yyyy hh24:mi:ss') I50TDAT, 0.06486 I50UCOST, 'CHC' I50TRNS from dual union all
              select 'BACCA004' I50PART, to_date('28/08/2007 15:49:15', 'dd/mm/yyyy hh24:mi:ss') I50TDAT, 0.06328 I50UCOST, 'CHC' I50TRNS from dual union all
              select 'BACCA004' I50PART, to_date('30/10/2008 09:22:40', 'dd/mm/yyyy hh24:mi:ss') I50TDAT, 0.06952 I50UCOST, 'CHC' I50TRNS from dual union all
              select 'BACCA004' I50PART, to_date('13/01/2009 09:09:07', 'dd/mm/yyyy hh24:mi:ss') I50TDAT, 0.06867 I50UCOST, 'CHC' I50TRNS from dual union all
              select 'BACCA005' I50PART, to_date('25/07/2007 08:27:24', 'dd/mm/yyyy hh24:mi:ss') I50TDAT, 0.06715 I50UCOST, 'CHC' I50TRNS from dual union all
              select 'BACCA005' I50PART, to_date('10/04/2008 15:45:14', 'dd/mm/yyyy hh24:mi:ss') I50TDAT, 0.06916 I50UCOST, 'CHC' I50TRNS from dual union all
              select 'BACCA005' I50PART, to_date('30/10/2008 09:05:17', 'dd/mm/yyyy hh24:mi:ss') I50TDAT, 0.07453 I50UCOST, 'CHC' I50TRNS from dual union all
              select 'BACCA005' I50PART, to_date('13/01/2009 09:06:49', 'dd/mm/yyyy hh24:mi:ss') I50TDAT, 0.07275 I50UCOST, 'CHC' I50TRNS from dual)
select I50PART, I50TDAT, I50UCOST, I50TRNS
from   (select I50PART, I50TDAT, I50UCOST, I50TRNS, row_number() over (partition by I50PART order by I50TDAT desc) rn
        from   I50F
        where  I50TRNS = 'CHC')
where  rn <= 2
order by I50PART, I50TDAT desc;

I50PART  I50TDAT               I50UCOST I50
-------- ------------------- ---------- ---
BACCA001 10/04/2008 16:29:02     .10639 CHC
BACCA001 25/07/2007 08:26:30     .10329 CHC
BACCA003 10/04/2008 13:30:12     .17535 CHC
BACCA003 25/07/2007 08:26:54     .17024 CHC
BACCA004 13/01/2009 09:09:07     .06867 CHC
BACCA004 30/10/2008 09:22:40     .06952 CHC
BACCA005 13/01/2009 09:06:49     .07275 CHC
BACCA005 30/10/2008 09:05:17     .07453 CHC

Tags: Database

Similar Questions

  • Download all packages or just the sound with the latest dates?

    Hi, maybe it's a stupid question, but when you go to the drivers and it shows are all pilots who are selected to download to your laptop you wanted to install only those with the latest dates or each package that is there?

    Hello:

    You must install the driver with the most recent date if you are sure this is a driver that you are interested in.

  • Get the latest data of Variable shared before disconnecting from the network

    Hello.

    I use Shared - published network variables for my communication between two PC's. Each LV software will pass the data to another.

    Sometimes the wireless connection to become really bad and the network connection stops.

    I want to get the latest data. Currently my VI will show the value '0' on the variable shared data once the connection is cut.

    I tried using shift, but she registers the same results.

    Can someone show me how I can stay past data when the network connection is disconnected.

    Thank you very much.

    Kind regards

    Hello Fan, Ravens

    It works! Thank you very much.

    Kind regards

  • How to configure a web service primavera to return the data in the second database?

    Hello world


    We have P6 with WS first deployment on a single weblogic domain server. The first WS returns the first instance of database data.

    Then deployed to the WS second tip on a weblogic domain server separated with a different port. Set up the second WS with < WS2_INSTALL_HOME > / bin/dbconfig.sh, creating a new branch a configuration that specifies one second instance of the database. However, this configuration is ignored, and the second web services return data from the database.

    We have a single domain, including notably the following servers:

    Name / host / Port / deployments

    P6 / localhost / 0001 / P6 (v8.3), p6ws1 (v8.3)

    p6ws2 / localhost / 0002 / p6ws2 (v8.3)

    We have now two different files BREBootstrap.xml.

    P6 BREBootstrap.xml:

    < database >

    < URL > JDBC:Oracle:thin:@db1:1521:db1 < / URL >

    < user name > pubuser < / name >

    password <>anycriptopass1 < / password >

    oracle.jdbc.OracleDriver < driver > < / driver >

    < PublicGroupId > 1 < / PublicGroupId >

    < / data >

    < CfgVersion > 8.330 < / CfgVersion >

    <>configurations

    < name BRE = 'P6 Config_DB1"instances ="1"logDir ="anydir, P6EPPM, p6, PrimaveraLogs"/ >

    < / configuration >

    p6ws2 BREBootstrap.xml:

    < database >

    < URL > JDBC:Oracle:thin:@DB2:1521:DB2 < / URL >

    < user name > pubuser < / name >

    password <>anycriptopass2 < / password >

    oracle.jdbc.OracleDriver < driver > < / driver >

    < PublicGroupId > 1 < / PublicGroupId >

    < / data >

    < CfgVersion > 8.330 < / CfgVersion >

    <>configurations

    < name BRE = 'P6 Config_DB2"instances ="1"logDir ="anydir, P6EPPM, ws2, PrimaveraLogs"/ >

    < / configuration >

    "P6 Config_DB1" and "P6 Config_DB2" including the property database for the database 1 and 2 respectively.

    How to set up a second web service to return the data to the second database?


    Thanks in advance!


    Kind regards

    Dmitry

    So, answer oracle support:

    Looks like it is in the documentation, Web Services cannot be configured in this way as the other modules. See the following topics:

    BUG 19516437 - Is it POSSIBLE TO hardcode a DEPLOYMENT of SERVICES WEB P6 to an INSTANCE of DATABASE? (ask if this is possible)

    BUG 19579735 - FOR BEING ABLE to hardcode A P6 WEB SERVICES DEPLOYMENT to A DATABASE INSTANCE (corresponding improvement because it can be done).

    The problem has been resolved by the following:

    1 create the WebLogic domain.

    2 P6 and p6ws deployed on managed servers.

    3 configuration P6 uses the second instance of database and P6 has not begun.

    4 result: the p6ws (from additional domain WebLogic) returns data for the second instance of the database.

    Kind regards

    Dmitry

  • I want to return the product to stop the renovation and to remove the data from credit card

    I want to return the product to stop the renovation and to remove the data from credit card

    To the link below, click on the still need help? option in the blue box below and choose the option to chat or by phone...
    Make sure that you are logged on the Adobe site, having cookies enabled, clearing your cookie cache.  If it fails to connect, try to use another browser.

    Creative cloud support (all creative cloud customer service problems)
    http://helpx.Adobe.com/x-productkb/global/service-CCM.html ( http://adobe.ly/19llvMN )

  • sys_refcursor do not fetch any data, even if the query returns the value

    I use sys_refcursor to return the columns and aid below the procedure to do. Although the data are there in table_1 and table_2.

    PROCEDURE test_pro (abc_date N, DATE,
    cur_get_data ON sys_refcursor
    )

    OPEN cur_get_data
    for
    Select A.col1, B.col2
    from table_1 A
    where A.dis_date = abc_date
    left outer join
    table_2 B
    on
    A.dis_date = B.dis_date;

    IF cur_get_data % rowcount = 0
    then
    raise e_error;
    END if;

    EXCEPTION
    When e_error
    then
    -no_data_found;
    while others
    then
    -(giving an error with the SQL error code);

    END test_pro;


    When running under sql in the sql pl/sql developer window pick
    data
    Select A.col1, B.col2
    from table_1 A
    where A.dis_date = abc_date
    left outer join
    table_2 B
    on
    A.dis_date = B.dis_date;

    But while testing the test_pro in the test of the pl/sql Developer window, it is
    do not fetch all data and raise e_error every time

    is there a problem arising from the use IF cur_get_data % rowcount = 0 whenever that happens in the exception block.

    so can someone please put a few ideas what cud be the reason for this?
    PROCEDURE test_pro(abc_date IN DATE,
                       cur_get_data OUT sys_refcursor
                      ) is
    BEGIN
    
      OPEN cur_get_data for select A.col1,B.col2
                              from table_1 A
                             where A.dis_date = abc_date
                                   left outer join
                                   table_2 B
                                on A.dis_date = B.dis_date;
    
    /* while testing let exceptions just pop out
    EXCEPTION
    
      when no_data_found
      then
    ------no_data_found;
      when others
      then
    --------(giving SQL error with error code);
    */
    END test_pro;
    

    then you test as something like

    declare
    
      my_date   date := to_date('20120621','yyyymmdd');
      my_cursor sys_refcursor;
      col1      ... ;
      col2      ... ;
    
    begin
    
      test_pro(my_date,my_cursor);
    
      loop
    
        fetch my_cursor into col1,col2;
        exit when my_cursor%notfound;
        dbms_output.put_line(col1 || ' ~ ' || col2);
    
      end loop;
    
    end;
    

    Concerning

    Etbin

  • Dynamic action - show/hide area based on LOV that returns the ID

    Hi people,

    This should be simple, so someone who works with dynamic actions.

    I have a LOV based on query below:
    select OBJECT_ID, KOD 
      from x_data x;
    
    retuns:
       ID          KOD
    ----------------------------
        492961 BMW
        492964 VOLVO
        492960 MERCEDES
        492963 VOLKSWAGEN
        492959 SKODA
    Agenda: P200_KOD is based on LOV that displays KOD and returns the ID.

    On my page, I have also 1 region called TEST_REGION.

    I want to put in place a testament of shich dynamic action SHOW/HIDE a TEST_REGION based on the value selected in the order of the day: P200_KOD (LOV). Region should be shown if displayed (KOD) selected ID value begins with '% V '.
    By other words, if following query returns any folder, then the SHOW, HIDE it on the other:
       select *
        from x_data x
      where x.kod like 'V%'
         and x.object_id = :P200_KOD;
    How can I define a condition of dynamic action fires, for article: P200_KOD?

    Thank you
    Tomas

    Hello

    One way:

    Create an advanced dynamic action.
    Name: Region to hide
    Event: change
    Selection type: item (s)
    Items (s): P200_KOD
    Condition: Expression of JavaScript
    Value:

    $(this.triggeringElement).children("option:selected").html().substring(0,1) !== "V"
    

    Action: hide
    Fire on the Page loading: true
    Hide all items on the page on the same line: No.
    Action of false: show
    Fire on the Page loading: true
    Display all items in the page on the same line: No.
    Selection type: region
    Region: TEST_REGION

    Kind regards
    Jari

    http://dbswh.webhop.NET/dbswh/f?p=blog:Home:0

  • How to return the value 0 for no data using the County?

    Hi all
    I used this query to count the number of records for each month of the year:

    SELECT DISTINCT COUNT (I.information_sid) COUNT, TO_DATE (TO_CHAR (INSERT_DATE, 'MM'), 'MM') MONTH

    INFORMATION I

    TO_DATE GROUP (TO_CHAR (INSERT_DATE, 'MM'), 'MM')

    ORDER BY TO_DATE (TO_CHAR (INSERT_DATE, 'MM'), 'MM')

    But this code returns no value for months without data
    I want to return the value '0' for any month of data. How, please?

    Note: I use reports 6i.

    Maybe this?

    SELECT SUM(CNT_REC) CNT_REC, MONTH
    FROM
    (
    SELECT COUNT(I.information_sid) CNT_REC, TO_DATE(TO_CHAR(INSERT_DATE,'MM'),'MM') MONTH
    FROM INFORMATIONS I
    GROUP BY TO_DATE(TO_CHAR(INSERT_DATE,'MM'),'MM')
    UNION ALL
    SELECT 0, LPAD(ROWNUM,2,0)
    FROM ALL_OBJECTS
    WHERE ROWNUM <= 12
    )
    GROUP BY MONTH
    ORDER BY MONTH
    

    No need to SEPARATE during the use of GROUP BY.

    -Clément

  • How can I return the data again to Flex my cfc

    I use a cfc by default CRUD built in Flex Builder 3 using activeRecord. I changed my cfc to return the query and access remotely, but I always event.result = null.

    What I am doing wrong? I just want to return the folder after I save it.

    I know I could create a new method in my manager to call a query that will get the record based on my values of form, but I want to return that same value without having to suddenly. Is this possible?

    Flex MXML

    < mx:RemoteObject

    ID = "roMyObject" destination = "ColdFusion" source = "CFCs. MyGateway"showBusyCursor ="true">

    < name mx:method = 'save' result = "MyHandler (event); "/ >

    < / mx:RemoteObject >

    Gateway CFC

    < cffunction = 'save' output name = "false" access = "remote" >

    < name cfargument = "obj" required = "true" / >

    < cfreturn obj.save () / >

    < / cffunction >

    CFC

    < cffunction = 'save' output name = "false" access = "public" returntype = "Cancel" >

    < cfscript >

    If (this.getClassifiedID (eq) 0)

    {

    Create();

    } else {}

    Update();

    }

    < / cfscript >

    < / cffunction >

    < name cffunction "crΘer" output = "false" returntype = access = "remote" = "query" >

    < cfargument name = "obj" required = "true" >

    < cfset var qCreate = "" >

    < cfset var qread read = "" >

    < cftransaction isolation = "read_committed" >

    < cfquery name = "qCreate" >

    Create folder

    < / cfquery >

    < cfquery name = "qGetID" >

    Select last_insert_id() as new_id;

    < / cfquery >

    < / cftransaction >

    < cfreturn qGetID >

    < / cffunction >

    Hello

    You gave the return type of function as zero economy. Try the following code.

    If (this.getClassifiedID (eq) 0)

    {

    result = create();

    } else {}

    result = update();

    }

    Hope this helped you

    concerning

  • get the latest dates

    Hello
    I have a simple question... .i do not know why I m brain dead today...

    I m trying to get the date limit for the id of each

    with test_data as(
    select '001'id, 'xyz'name, '1/1/2009'start_date from dual union all
    select '001',  'abc', '1/2/2099' from dual union all
    select '001',  'def', '1/3/2009' from dual union all
    select '001',  'ghi', '1/4/2009' from dual union all
    select '001',  'jkl', '1/5/2009' from dual 
    )
    
    The output i m looking for just one record with latest date
      with result as 
      (
         select '001',  'jkl', '1/5/2009' from dual  
       )
    
    i tried this 
    
     select id,name, greatest(start_date) from test_data
      group by id,name,start_date 
      
    It gives me output ...which i m not lookg for 
    
      with t as 
      (
         select '001',  'abc', '1/3/2009' from dual union all 
         select '001',  'ghi', '1/4/2009' from dual union all
         select '001',  'jkl', '1/5/2009' from dual 
       )select * from t
       
    I was wondering if we have any function in oracle PL/SQL to do this kind of things

    Any suggestion is greatly appreciated! Thanks much sio!

    Published by: user642297 on March 12, 2010 12:21
    SQL> with test_data as(
      2  select '001'id, 'xyz'name, '1/1/2009'start_date from dual union all
      3  select '001',  'abc', '1/2/2099' from dual union all
      4  select '001',  'def', '1/3/2009' from dual union all
      5  select '001',  'ghi', '1/4/2009' from dual union all
      6  select '001',  'jkl', '1/5/2009' from dual union all
      7  select '002',  'ghi', '1/4/2009' from dual
      8  )
      9  select id, max(start_date), max(name) keep (dense_rank first order by start_date desc)
     10  from test_data
     11  group by id;
    
    ID  MAX(STAR MAX
    --- -------- ---
    001 1/5/2009 jkl
    002 1/4/2009 ghi
    

    Max
    http://oracleitalia.WordPress.com

  • in which order will select * return the data?

    Hi guys,.

    (1) if we just do a select * from emp, it returns the data in the order data in the scope blocks. that is to return all the measurement data blocks 1, then from measure 2 and so on?
    (2) if we do a select * from emp and say half of the data blocks are already in the database buffer cache, how Oracle knows that the PEM data blocks are already in the database buffer cache? He kept a correspondence table?

    Thank you

    OracleGuy777 wrote:
    Hi guys,.

    (1) if we just do a select * from emp, it returns the data in the order data in the scope blocks. that is to return all the measurement data blocks 1, then from measure 2 and so on?

    I don't think that what this will be like in the same order. Hans's response is more appropriate, I think that it is the nucleus which decides the best way to access the oracle table.

    (2) if we do a select * from emp and say half of the data blocks are already in the database buffer cache, how Oracle knows that the PEM data blocks are already in the database buffer cache? He kept a correspondence table?

    Yes, indeed it is. The blocks are having a DBA (data block address) including the case number and the block #. This number is hashed and the key pair / generated value is used in a table comrising buckets, where each segment is the property of the value of a hash. When you say let me have access this table buffers, your server process analysis this table to see if there are already buffers for this available table. If so, it will access pads here otherwise access is reported to be done from the hard drive. To make space in the buffer cache, REPL (replace aka the LRU list) is used where the buffers are placed in the Middle using the algorithm of insertion of the median value.

    Hope that this somehow :).

    HTH
    Aman...

  • How to return the data type complex of a synchronous BPEL process

    Hi all
    I have created a synchronous BPEL process, so a partner customer link was automatically created in the project. Now the link partner of this client is to have input and output variable of type normal string where as my BPEL process finally returns a complex data type.
    In order to solve this problem, I took a processing activity and mapped the collection [variable returned by my BPEL process] to the chain of production of the customer but in this way I just get a single string to store the entire collection but I want that they separately.

    Can someone tell me, how to manage this scenario.

    Concerning
    Lokesh

    After creating the partner link and the invoke (to create the variables), change the element type of the response message to the complex type definition of your collection that appears in the XSD. You can do the same thing if you want to change the element type of the payload of the request message as well.

  • Return the record type


    Hello

    I have a requirement of the company, where I need to return a record type (OUT parameter) for environment call based on the given input value.

    Suppose that if the value is correct and corresponding record is found in the table then the return values for this key entry. If matching record is found, then return the exception to the calling environment.

    To do this, I created an example of test table and populated records.

    create table plch_test(dept_id number,dept_name varchar2(50),cost_centre number);
    insert into plch_test values(10,'SALES',1010);
    insert into plch_test values(20,'FINANCE',2010);
    insert into plch_test values(30,'MKTG',3010);
    
     
    SQL> select * from plch_test;
       DEPT_ID DEPT_NAME                                          COST_CENTRE
    ---------- -------------------------------------------------- -----------
            10 SALES                                                     1010
            20 FINANCE                                                   2010
            30 MKTG                                                      3010
    
     
     
    

    I wrote a simple block and gave a valid key dept_id (10 in this case) to display costcentre for this dept_id and dept_name I said tow types of records, one for valid record and another exception

    
    

    SQL> DECLARE 
      2  TYPE rec_dept IS RECORD(dept_name varchar2(50),cc number);
      3  l_rec_dept rec_dept;
      4  TYPE rec_exception IS RECORD(err_code number,error_message varchar2(300));
      5  l_rec_exception rec_exception;
      6  BEGIN
      7  SELECT dept_name,cost_centre
      8  INTO l_rec_dept
      9  FROM plch_test
     10  where dept_id=10;
     11  dbms_output.put_line('DEPT_NAME'||' '||l_rec_dept.dept_name||' '||'COSTCENTRE'||' '||l_rec_dept.cc);
     12  EXCEPTION WHEN NO_DATA_FOUND THEN
     13  l_rec_exception.err_code:=sqlcode;
     14  l_rec_exception.error_message:=sqlerrm;
     15  dbms_output.put_line(l_rec_exception.err_code||' '||l_rec_exception.error_message);
     16  END;
     17  .
    SQL> /
    DEPT_NAME SALES COSTCENTRE 1010
    PL/SQL procedure successfully completed.
    SQL> 
    
     
    

    Now for invalid dept_id and expose the message by using exception record type I stated.

    SQL> ed
    Wrote file afiedt.buf
      1  DECLARE
      2  TYPE rec_dept IS RECORD(dept_name varchar2(50),cc number);
      3  l_rec_dept rec_dept;
      4  TYPE rec_exception IS RECORD(err_code number,error_message varchar2(300));
      5  l_rec_exception rec_exception;
      6  BEGIN
      7  SELECT dept_name,cost_centre
      8  INTO l_rec_dept
      9  FROM plch_test
     10  where dept_id=40; --Invalid --data is not present
     11  dbms_output.put_line('DEPT_NAME'||' '||l_rec_dept.dept_name||' '||'COSTCENTRE'||' '||l_rec_dept.cc);
     12  EXCEPTION WHEN NO_DATA_FOUND THEN
     13  l_rec_exception.err_code:=sqlcode;
     14  l_rec_exception.error_message:=sqlerrm;
     15  dbms_output.put_line(l_rec_exception.err_code||' '||l_rec_exception.error_message);
     16* END;
    SQL> /
    100 ORA-01403: no data found
    PL/SQL procedure successfully completed.
    
    

    Now as you can see I need to include this point in a procedure with an input parameter and output must be a record types which will return

    rec_dept if it becomes a key input valid or an exception if she meets a key not valid.

    
    CREATE PROCEDURE test_prc IS(p_in_dept_id IN plch_test.dept_id,p_output ??????
    DECLARE 
    TYPE rec_dept IS RECORD(dept_name varchar2(50),cc number);
    l_rec_dept rec_dept;
    TYPE rec_exception IS RECORD(err_code number,error_message varchar2(300));
    l_rec_exception rec_exception;
    BEGIN
    BEGIN
    SELECT dept_name,cost_centre
    INTO l_rec_dept
    FROM plch_test
    where dept_id=p_ind_dept_id;
    RETURN l_rec_dept;
    EXCEPTION WHEN NO_DATA_FOUND THEN
    l_rec_exception.err_code:=sqlcode;
    l_rec_exception.error_message:=sqlerrm;
    RETURN l_rec_exception;
    END;
    dbms_output.put_line('DEPT_NAME'||' '||l_rec_dept.dept_name||' '||'COSTCENTRE'||' '||l_rec_dept.cc);
    END;
    

    Hope that the explanation above help in imposes the requirement

    Kind regards

    Claudy kotekal

    Return a record which can mean two things is complicated; I'm not an experienced myself pl/sql developer, but this looks like a craft.

    The idea of exceptions under Sir Thomas of Kyte, is that any treatment must be stopped; You should RAISE an exception to the appellant so that he can figure out what to do with it.  What you are saying, this is an exception, but is not a little, cos it's okay, I'll just keep but I will go back to the appellant in any way, but the appellant shall include this registration type is - would it be a record representing a row of the table, or it might be an exception... yuck.

    (a) is it really an exception

    (b) what do you do with it? You he could log into a table, you could write to a file, you can display an error message on the screen

    But really, it's weird to want to pass an exception as return value.

    These are all considerations of design, not really anything to do with the pl/sql language in itself.

    But hard, if you send a record type a successful being found, registration-based stick to it and don't use it to return a record; do not try to do double duty with her flipping something else.  Just save the message put in a table, or print it to the console, or what you want to do with; but as I said, the most important decision is, is this really an exception. And is based on the data model and the expectations of cleanliness of the data etc.

    Think about how you call built-in functions. If you send garbage to a built-in function it does not return successfully, leaving you to figure out whether he succeeded or not by inspecting the return value; It goes kaboom, something bad happened.  That's what your function should do if something bad happens, that is to say, if you get an exception, it should probably go kaboom.

  • XML - ORA-19025: EXTRACTVALUE returns the value of a single node

    Hello

    I'm new to XML DB. Can someone help me with the below XML

    I use the following XML... (I pasted a part only of it coz I need data only up to this article)

    XML
    --------------------

    <? XML version = "1.0" encoding = "UTF-8"? > < SOAP - ENV:Envelope xmlns:SOAP - ENV = "http://schemas.xmlsoap.org/soap/envelope/" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-."
    example"container ="http://www.w3.org/2001/XMLSchema"> < SOAP - ENV:Body >
    < ns:PicklistWS_GetPicklistValues_Output xmlns:ns = "urn: crmondemand/ws/list dropdown /" >
    < ListOfParentPicklistValue xmlns = "urn: / xml/crmondemand/list of choices" >
    < ParentPicklistValue >
    < language > ENU < / language >
    < ParentFieldName > plProduct_Team < / ParentFieldName >
    < ParentDisplayValue > Marketing On Demand < / ParentDisplayValue >
    < ParentCode > Marketing On Demand < / ParentCode >
    < Disabled > N < / disabled >
    < ListOfPicklistValue >
    < PicklistValue >
    Escalation of OCP/SME < code > < code >
    Escalation of OCP/SME < DisplayValue > < / DisplayValue >
    < Disabled > N < / disabled >
    < / PicklistValue >
    < PicklistValue >
    Ask fusion < code > < code >
    Merge request < DisplayValue > < / DisplayValue >
    < Disabled > N < / disabled >
    < / PicklistValue >



    Code
    ---------




    SELECT distinct
    EXTRACTVALUE (value (SR), ' / ParentPicklistValue/ListOfPicklistValue/PicklistValue/Code ','xmlns = "urn: / crmondemand/xml/list of choices"') AS display.
    Return EXTRACTVALUE (value (SR),'/ ParentPicklistValue/ListOfPicklistValue/PicklistValue/DisplayValue ',' xmlns = "urn: / crmondemand/XML/picklist"'),.
    EXTRACTVALUE (value (SR), '/ ParentPicklistValue/ParentDisplayValue','xmlns = "urn: / crmondemand/XML/picklist"') AS parent_display,
    EXTRACTVALUE (value (SR), '/ ParentPicklistValue/ParentCode','xmlns = "urn: / crmondemand/XML/picklist"') AS parent_return
    TABLE (XMLSEQUENCE ((EXCERPT)
    WEB_SERVICE (' <? xml version = "1.0" encoding = "UTF - 8" standalone = "no"? > < envelope soap: xmlns:soap = "http://schemas.xmlsoap.org/soap/envelope/")
    xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" container = "http://www.w3.org/2001/XMLSchema" >
    < soap: Body >
    < PicklistWS_GetPicklistValues_Input xmlns = "urn: crmondemand/ws/list dropdown /" >
    Type < FieldName > < / FieldName >
    Service request < RecordType > < / RecordType >
    < / PicklistWS_GetPicklistValues_Input >
    < / soap: Body >
    "< / envelope soap: >.
    (' document / urn: crmondemand/ws/list dropdown /: ' GetPicklistValues, Id_de_la_session).
    "/: soap envelope / soap: Body / * / * / * ',' xmlns:soap ="(http://schemas.xmlsoap.org/soap/envelope/'))) SR "


    ERROR
    ---------

    ORA-19025: EXTRACTVALUE returns the value of a single node


    UNDERSTANDING
    ---------------------------

    As my Xpath only points until the node - ParentPicklistValue and not the child nodes under it. That's why, when I try to interview the child nodes - / ParentPicklistValue/ListOfPicklistValue/PicklistValue/Code, I get the error mentioned above.

    REQUIREMENT
    -----------------------

    Can someone help me to receive the values of the mother and child values based on xml and query above.

    Hello

    It's a classic ;)

    You need a second XMLSequence who shreds the collection of PicklistValue in relational lines:

    select extractvalue(value(sr2), '/PicklistValue/Code', 'xmlns="urn:/crmondemand/xml/picklist"') AS Display
         , extractvalue(value(sr2), '/PicklistValue/DisplayValue', 'xmlns="urn:/crmondemand/xml/picklist"') AS Return
         , extractvalue(value(sr1), '/ParentPicklistValue/ParentDisplayValue', 'xmlns="urn:/crmondemand/xml/picklist"') AS parent_display
         , extractvalue(value(sr1), '/ParentPicklistValue/ParentCode', 'xmlns="urn:/crmondemand/xml/picklist"') AS parent_return
    from table(
           xmlsequence(
             extract( WEB_SERVICE( ... )
                    , '/soap:Envelope/soap:Body/ns:PicklistWS_GetPicklistValues_Output/ListOfParentPicklistValue/ParentPicklistValue'
                    , 'xmlns="urn:/crmondemand/xml/picklist"
                       xmlns:ns="urn:crmondemand/ws/picklist/"
                       xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' )
           )
         ) sr1
       , table(
           xmlsequence(
             extract( value(sr1)
                    , '/ParentPicklistValue/ListOfPicklistValue/PicklistValue'
                    , 'xmlns="urn:/crmondemand/xml/picklist"' )
           )
         ) sr2
    ;
    

    What is your version of the database BTW?
    10.2 and upward, you can use the XMLTable.

  • To return the rows

    Dear members
    I need a function to return the lines

    This is my sample data
    ID     DESC               UNI          CODE
    1     BO_USER               40352          A
    2     BO_USER1          40353          D
    3     BUSINESS_PARTNER1     40353          F
    4     BUSINESS_PARTNER2     40354          R
    5     BUSINESS_PARTNER3     40354          N
    If I pass the id and United as an input value, that I need to get all of the line as well

    Create or replace function ((ID en varchar2, UNI en varchar2))
    return
    l_val;


    Itry to serve table tpe
    and the type as object and call that function, but when I try to call this value, I am not able to
    use of the name of the function instead of this I need to use
    slect * form the name of the table function

    If somene post a few syntax how to I will follow

    regads

    Hello

    You can create the function with the return type as table % rowtype. And even you can call this function in a block anonymous plsql and display the desired value.
    But in sqlplus, you won't be able to use it as a sql statement since it is the unsupported data type.

    This was based on my understanding of the declared scénarion. Let us know if its different

    SBH

Maybe you are looking for