Need help to create a logic

Hi all
I need to make a logic to check the scenario below.
Could you please help me on this one.

Scenario:
There is a table of ABC. I need enable all purposes for the specified SBA.
OSR uses status Party_status
Address 123 A
123 Ship_to A
123 Install_at A
Address 125 A
Install_at 125A
200 Ship_to an A
Address 201 A I

Logic should be such that it checks all uses and must return the OSR whose use is not Active.

For example. I guess that 123,125,200,201,203 of OSR hard-coding in the query.
Output should be like
The SBA uses
All_usages_are_active 123
Ship_to 125
Address 200, Install_at
Address 201, Ship_to, Install_at
Address 203, Ship_to, Install_at

Here is the raw logic I created so dar.
Code:*.
Installation of ship of Bill
T T T
T T F
T F T
T F F
F T T
F T F
F F T
F F F

DECLARE
Cursor C1 is
Select the OSR, uses, statusm party_status
ABC;

BEGIN
Open c1;
Fetch c1 into x;
if(C1%NotFound) then
dbms_output.put_line (c1. OSR + ': ' + 'Address, Ship_to, Install_at');
"exit";
end if;
If (C1. Uses = 'Address' AND C1. STATE = 'A' AND C1. PARTY_STATUS = 'A') THEN
IF (C1. USE = "SHIP_TO" AND C1. STATE = 'A' AND C1. PARTY_STATUS = 'A') THEN
IF (C1. USE = "INSTALL_AT" AND C1. STATE = 'A' AND C1. PARTY_STATUS = 'A') THEN
dbms_output.put_line (C1. OSR + ': ' + 'All_usages_are_active');
END IF;
END IF;
END IF;
END;


Please help me with logic.
Thanks in advance.

Kind regards
Pankaj

Published by: Pankaj Arora on January 16, 2012 06:48

Something like:

with input as (
               select '123,125,200,201,203' osr_str from dual
              ),
  osr_list as (
               select  distinct to_number(regexp_substr(osr_str,'[^,]+',1,level)) osr
                 from  input
                 connect by level <= length(regexp_replace(osr_str || ',','[^,]'))
              ),
  template as (
               select  osr,
                       sum(power(2,lvl)) total_usage
                 from  osr_list,
                       (
                        select level lvl
                          from  dual
                          connect by level <= 3
                       )
                 group by osr
              ),
    active as (
               select  osr,
                       sum(
                           case usages
                             when 'Bill_to' then 2
                             when 'Ship_to' then 4
                             else 8
                           end
                          ) total_usage
                 from  abc
                 where status = 'A'
                   and party_status = 'A'
                 group by osr
              ),
  inactive as (
               select  a.osr,
                       a.total_usage - nvl(b.total_usage,0) total_usage
                 from      template a
                       left join
                           active b
                         on (
                             b.osr = a.osr
                            )
              )
select  osr,
        case total_usage
          when 0 then 'All_usages_are_active'
          when 2 then 'Bill_to'
          when 4 then 'Ship_to'
          when 6 then 'Bill_to,Ship_to'
          when 8 then 'Install_at'
          when 10 then 'Bill_to,Install_at'
          when 12 then 'Ship_to,Install_at'
          else 'Bill_to,Ship_to,Install_at'
        end usages
  from  inactive
  order by osr
/

       OSR     USAGES
----------     --------------------------
       123     All_usages_are_active
       125     Ship_to
       200     Bill_to,Install_at
       201     Bill_to,Ship_to,Install_at
       203     Bill_to,Ship_to,Install_at

SQL> 

SY.

Tags: Database

Similar Questions

  • Hi, I recently bought numbers in order to create a commercial newspaper. I'm the pen and paper. I need help to create a formula. A purchase column determines if the entry price column is subtracted from the price of output column or output subtracted

    Hi, I recently bought numbers in order to create a commercial newspaper. I'm the pen and paper. I need help to create a formula. A purchase column; Determines if the entry price column is subtracted from the price of output column (buy) or subtracted from (Sell) entry exit. Thank you for your help

    Hi B',.

    Buying and selling in column B

    Price of entry in column c.

    Exit in column D price

    Formula (and outcome) in column E

    If the column will B always contained 'Buy' or 'Sell', it works. It is default to a calculation of 'sell' if sale or has been specified.

    E2: = IF (B = "Buy", D - C, C - D)

    If you want to delay the calculation until the amounts entered in C and D, use this version:

    E2: = IF (OR (LEN (C) < 1, LEN (D) < 1,"", IF (B = "Buy", D - C, C - D) ")

    If you want to delay the calculation until all three ducks are on a line (B contains buy or sell, C and D contain both data), use this version:

    E2: = IF (OR (LEN (C) < 1, LEN (D) < 1,"", IF (B = "Buy", D - C, IF(B="Sell",C-D,) "" ")))

    Third version used in this table.

    Kind regards

    Barry

  • Hello all, I need help with creating a dynamic region in jdeveloper 11.1.2.3 version

    . Hello everyone, I need help with creating a dynamic region in jdeveloper 11.1.2.3 version

    What JDK you are using?

    You are probably using an old version of the JDK, that class while compiled under JDK 1.7.0

    http://java67.blogspot.com/2012/10/how-to-fix-javalangunsupportedclassversionerror-major-minor-version-49-50-51.html

    For example, work with the correct version, and it will be fine...

  • I need help to create actions.

    I need help to create actions.

    Hi andrewr,.

    Here are the tutorials that you can use to create actions:

    Record steps in Photoshop | Adobe Photoshop CC tutorials

    Create actions in Adobe Photoshop

    Kind regards

    Claes

  • Need help to create a workspace to keep my guides and leaders to a predefined dimension.

    Need help to create a workspace to keep my guides and leaders to a predefined dimension?

    Might be interesting to set up an action to do this.

    The next time that you create your folder of the workspace, an action, then you have this will define and at a click of a button you will have the same workspace each time.

  • Need help to create a count up animation

    Hello. I'm new (ish) FlashCS6 and need help to create a timing of the animation. I'm fine with a general flash animation, but have never really used action script, are not my hand holding a little. any help would be great.

    Basically, I have 12 scenes someone is going through their daily lives by buying items and at the end of each scene I have a small graph of cash that opens - I need then of numbers to animate quickly count for example, from £ 0 to £369 for a few seconds.

    Thanks in advance

    Chris

    The toFixed() method should do what you need.  By my previous code example...

    cashGraphic.cashDisplay.text = ' £' + cashValue.toFixed (2);

    The toFixed method returns a string value, so you don't have to cast one in coding as I showed earlier.

  • I need help on creating reports on the intranet.

    I need help on creating reports on the intranet.
    My level: Beginner cf.
    Y at - it a book for report design? And structures for reports?
    ------------------------------------------------requirements
    my form needs one

    · Date of the box you want. (from and to).
    · Option button to choose the csv and html
    · Run and throw out the results in a tabular format. (grids, cell)


    How many cfm pages do need me for this? E.g. display, action.
    What called what?
    What else do I need?

    I suggest that you put your project on hold for a little everything and get and read the chapters appropriate Web Application Construction Kit of Ben Forta. You can learn more about it here - http://www.forta.com/books/0321223675/. Once you have the concepts down, you will have a much more concentrated idea on what to do.

  • Need help to create a new Xbox account

    I deleted my Xbox Live account, a long time ago and I want to create a new. My old Xbox Live account is associated to my the Microsoft Account. But when I want to create an Xbox Live account, it says I have one using my that already have Microsoft Account. I'm sure I deleted my Xbox Live account and when I go on my Xbox Live account in the Internet, it says this, "Uh oh... that shouldn't happen." It seems that you have found a bug in the system. Please try again later. "I need help, I really want to create a new Xbox Live account using my course Microsoft Account. Thank you.

    Hello

    Your Question is beyond the scope of this community.

    I suggest that repost you in the correct forum.

    'Home'

    http://forums.Xbox.com/

    "Xbox forums.

    http://forums.Xbox.com/xbox_forums/general_discussion/f/3817.aspx

    "Xbox Forums directory.

    http://www.Xbox.com/en-us/forums

    See you soon.

  • Need help to create a pdf file

    I need help creating a PDF with me for free!

    Thanks everyone, I solved the problem.

  • Need help to create a scrollbar in HTML table

    Hello dreamweavers!

    I need help here please...

    I need to create a table with three columns... or a webpage... that has the ability to scroll when things are added.


    This is a music site and page Web will be a list - a database of all sorts - of each title artist and album. If there are say, 200 titles in the catalog, then I need to list them all on one page and in 3 columns towards the bottom of the page. What I did using a table in HTML in Dreamweaver. The problem is each title on the table is static and when adding in a new title in the catalog, ALL securities will have to be moved manually. So, I need to create a table where when I add another title (they will be alphabetical) say to am' for example, then all of the other titles will be automatically moves along a (somewhat as in a Word document by adding a new line). Everything else is automatically shifted. I don't know if this is still possible in Dreamweaver?

    I hope that I have explained this correctly. It's quite a strange problem, and as such, I have been unable to find anything on this forum or google search.
    If anyone can help that would be most excellent! I'd be happy.

    Questions - if you need further information please ask

    I use Dreamweaver CS5.5 Version 11.5 Build 5315

    I have a Macbook Pro with Snow Leopard if that's at all relevant.

    My site is on Wordpress with the theme, Suffusion. I can link to it, if someone needs.

    Here is a picture of the table, as I did, to give an idea what it looks like:

    columns.jpg

    Thank you!

    P.I.G > /.

    big dreamers never sleep

    Mylenium was right. You must use a database for this server-side.

    Maintenance of static tables with this amount of data is going to be a logistical nightmare - not even worth considering.   Get an indexing plugin for WordPress.

    Nancy O.

  • Need help to create a custom connector

    I need help on developing custom Homegrown application connector and the version I use is OIM9.0.3
    First of all, what are the steps we need care while developing a custom connector.
    I can't able to find the process in google to develop the custom connector.
    If you have all data related to the development of the connector custom, please share to me...

    What are the thing we need to take care while developing the connector.
    I spoke in the version OIM9.1 there is a possibility to develop the custom connector using the Genric technology, we can create the custom connector using the IOM GTC 9.1 feature

    early response will be appreciated

    I think the approach to take here will depend to a large extent what are the characteristics of the request of the House. Where it stores its user and the right information? It exposes an API or perhaps the database tables that you can use for commissioning?

    In general, you need to create the following in IOM:

    (1) a Type of COMPUTER resource
    (2) a COMPUTER resource
    (3) a resource object
    (4) a form of customized process
    (5) a procurement process
    (6) task of process adapters (allows to really reach out to the target application and perform commissioning activities)

    Please come back with more information on what you are trying to integrate with and I can give you hope that some other points.

    Rob

  • Need help to create dynamic VO

    Hi experts,
    Need code to create dynamic VO

    --
    MD

    Hi MD,.
    use following code

    String sql1 = "SELECT col1, col2, col3 from table1 where ';"
    SQL1 = sql1 + "col1 =: 1";
    ViewObject vo = am.findViewObject (">");
    If (vo is nothing)
    VO = am.createViewObjectFromQueryStmt (">", sql1 ' ");
    vo.setWhereClauseParams (null);
    vo.setWhereClauseParam (0, >);
    vo.executeQuery ();

    --
    Thank you
    Shrikant

  • I need help to create an e-newsletter

    I learned, I can create an e-newsletter with graphics and a header using Adobe Dreamweaver, but I have no idea where to start. It will be impossible for a person with few computer skills (someone like me)?

    I use Dreamweaver CS4.

    Thanks for any help.

    [Thread moved to general Discussion Dreamweaver forum]

    Do you mean by "a few computer skills" you have no knowledge of web design, then you will not be able to create a newsletter with Dreamweaver. Dreamweaver is a professional tool for web site designers or other people at least the basics of html and css.

    If you have some basics of html and css, or are willing to learn (there are plenty of tutorials online), you can use DW to help you create the room of email marketing. Here are some links that will give you some information about creating email marketing documents:

    SitePoint has some good information on their website:

    http://www.SitePoint.com/article/code-HTML-email-newsletters/

    http://www.SitePoint.com/article/designers-guide-HTML-email/

    http://www.SitePoint.com/article/principles-beautiful-HTML-email/

    Chimp Mail is also another site with some great help, including html email templates free and a free guide in pdf:

    Design beautiful Emails

    Html email resources

  • Need help to create a BCD to 7-segment decoder using logic gates

    I guess I'm a bit puzzled here.  I am creating a decoder 7 segments with AND, NOT and OR the doors, but I seem to have a bit of luck to get the display of numbers 1, 4 and 9 to work.

    Any help would be appreciated, thanks.

    Spent a little more time before you look at this link:

    http://circuitscan.homestead.com/files/digelec/bcdto7seg.htm

  • Need help to create a conditional LOV function

    First off the coast to let put me the warning that I am not the right Wick informed in PL/SQL. I need to use the LOV conditional for a list of selection based on the user's role in this application.

    I use the example of samples of the Dene - link: [http://apex.oracle.com/pls/otn/f?p=31517:120:2954663700615140:NO]

    I created the 2 types required and tested the function with a simple select query and LOV works.

    However, I need the function to return values based on the user role. I know, it's probably the ugliest pl/sql, you may have seen yet ;) I hope that you guys can decipher the logic that I use. Obviously, this code does not validate.

    You guys could help me with this?
    CREATE OR REPLACE FUNCTION return_art_lov_fn
    RETURN art_table_type
    AS
      v_data   art_table_type := art_table_type ();
    BEGIN
    IF
    EXISTS (SELECT '1'FROM GBL_PEOPLE, GBL_ACCESS WHERE upper(gbl_people.userid) = upper(app_user) AND gbl_people.person_id = gbl_access.person_id and gbl_access.art_role = 9)
    THEN
    FOR c IN (SELECT reverse_name, person_id
                   FROM gbl_people)
       LOOP
          v_data.EXTEND;
          v_data (v_data.COUNT) := art_rectype (c.person_id, c.reverse_name);
       END LOOP;
    ELSE
    FOR c IN (select reverse_name,person_id from GBL_PEOPLE where upper(userid) = upper(APP_USER) and current_flag is not null
               union
              select reverse_name,person_id from GBL_PEOPLE where mgr_person_id =(select person_id from GBL_PEOPLE where upper(userid) = upper(APP_USER) and
               current_flag is not null) and current_flag is not null)
       LOOP
          v_data.EXTEND;
          v_data (v_data.COUNT) := art_rectype (c.person_id, c.reverse_name);
       END LOOP;
    ENDIF;
       RETURN v_data;
    END;
    -Vinod

    Published by: user4908943 on December 10, 2009 16:37

    Published by: user4908943 on December 10, 2009 16:40

    Published by: user4908943 on December 10, 2009 16:41

    Published by: Jeremy on December 11, 2009 04:34

Maybe you are looking for