logical prior connection problem

Hi all

I have the scenario where I fill in amount of parent based on her children:

create table xx_pack_content)

child varchar2 (255),

parent varchar2 (255),

child_quantity NUMBER

);

insert into xx_pack_content values ('OBJ2', 'OBJ1', 50)

insert into xx_pack_content values ("OBJ3", "OBJ2", 2)

insert into xx_pack_content values ('OBJ4', 'OBJ2', 6)

SELECT the level,

x.Child,

x.Parent,

x.child_quantity

OF xx_pack_content x

START WITH x.parent =: p_parent_val

CONNECT BY PRIOR x.child = x.parent

Brothers and SŒURS ORDER BY level, x.child;

Code:

FUNCTION parent_qty (p_parent_val) RETURN VARCHAR2

CURSOR lcu_cur

IS to SELECT the level,

x.Child,

x.Parent,

x.child_quantity

OF xx_pack_content x

START WITH x.parent = p_parent_val

CONNECT BY PRIOR x.child = x.parent

Brothers and SŒURS ORDER BY level, x.child;

TYPE level_tbltype IS TABLE OF lcu_cur % ROWTYPE;

level_tbl level_tbltype;

lv_parent_content VARCHAR2 (30): = NULL;

lv_level_low VARCHAR2 (30): = NULL;

lv_level_high VARCHAR2 (30): = NULL;

BEGIN

OPEN lcu_cur (p_parent_val);

Get the lcu_cur COLLECT in BULK IN level_tbl;

CLOSE Lcu_cur;

DBMS_OUTPUT. Put_line ("Count:" | ") level_tbl. (COUNT);

lv_level_low: = level_tbl (level_tbl. PREMIER level);

lv_parent_content: = level_tbl (level_tbl..) Quantity FIRST) | » x';

BECAUSE me IN 2.level_tbl. LAST

LOOP

lv_level_high: = level_tbl (i) level;

IF (lv_level_low <>lv_level_high) THEN

lv_parent_content: = lv_parent_content | level_tbl (i) .child_quantity;

lv_level_low: = level_tbl (i) level;

ON THE OTHER

lv_parent_content: = lv_parent_content | ' ('| level_tbl (i) .child_quantity |) » +';

lv_level_low: = level_tbl (vpe_idx2) level.

END IF;

return (lv_parent_content);

END LOOP;

DBMS_OUTPUT. Put_line ('lv_parent_content: ' | lv_parent_content);

END;

expected results:

---------------

I need to build a function that returns the total amount of parent based on the parameter

When I pass "OBJ1" he shud be returned as 50 x (2 + 6) x'

When I pass 'OBJ2' he shud be returned as '(2+6) x'

If there is more than one child for the parent's should be like "(2 + 6 +..)" x'

I wrote a function above, but need help to get a correct output.

Don't know what you want to do when / if have brothers and sisters separated children but anyway...

Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production
With partitioning, OLAP, Data Mining and Real Application Testing options

SQL > SELECT LISTAGG)
2. DECODE (COUNT (*), 1,)
MAX 3 (TO_CHAR (child_quantity)),
4              '(' || LISTAGG (child_quantity, '+')
5 THE GROUP)
6 ORDER BY child) | ')') || 'x', ' ')
7 IN GROUP)
8 LEVEL CONTROL) Qty.
9 FROM xx_pack_content
10 START WITH PARENT = "OBJ1".
11 children to connect BY PRIOR = PARENT
12 GROUP BY LEVEL;

QTY.
--------------------------------------------------------------------------------
50 x (2 + 6) x

SQL > SELECT LISTAGG)
2. DECODE (COUNT (*), 1,)
MAX 3 (TO_CHAR (child_quantity)),
4              '(' || LISTAGG (child_quantity, '+')
5 THE GROUP)
6 ORDER BY child) | ')') || 'x', ' ')
7 IN GROUP)
8 LEVEL CONTROL) Qty.
9 FROM xx_pack_content
10 START WITH PARENT = 'OBJ2 '.
11 children to connect BY PRIOR = PARENT
12 GROUP BY LEVEL;

QTY.
--------------------------------------------------------------------------------
(2 + 6) x

SQL >

Tags: Database

Similar Questions

  • Logical remote connects to the MainStage but not Garageband?

    I have tried everything I can find to do remote logic to connect to the Garage band and none of it works.

    I can get my iPad to connect to MainStage without any problem. Open the first time I run logic remote with Garageband

    I get the prompt to allow the connection and pair the remote but from there it happens just to expire and I get the message...

    'Logic remotely was unable to connect to the selected Mac. If this is the first time that you connect logic remotely, you must confirm the connection on the selected Mac. " I did this step. I have the latest version of MainStage and Garageband available from 26/01/16.

    My firewall settings are turned off completely,

    I removed preference files and rebooted several times.

    I have the same problem between two different Macs and on two different networks.

    Thanks for any help you may have.

    Looks like you are trying to connect to Go with a Pro iPad or iPhone (which is not taken in charge)?  The configuration required for the logic of remote 1.3:

    The system configuration required

    Requires iOS 9.1 or later

    iPad support requires Logic Pro X 10.2.1 MainStage v3.2.3 or GarageBand v10.1

    iPad support Pro requires Logic Pro X 10.2.1 or MainStage v3.2.3

    support iPhone requires Logic Pro X 10.2.1

    Note that GarageBand is currently only supported on iPad.  I expect that will change with the next update to GarageBand, but I don't know about you.

  • AppStore connection problem!

    Hello

    I'm running a 21.5 "iMac with OS X El Captan 10.11.5. My problem is that I am not able to connect to iCloud and the App Store on my Mac.

    The error I get is "there was an error connecting to server Apple ID"

    The same username and password works perfectly well on the site of iCloud, my app store on the iPhone and the iPad, but not on Mac.

    What is the way my iMac communicates via the internet? We have a firewall. And oh, the software update for El Capitan is downloading as I type; He didn't even ask for IDs, just started downloading automatically. The same thing happened yesterday with the updates listed on the tab Update on the app store - they have been is downloaded yesterday without asking my login details but it was a rare event; connection problems I described above took place during the last month or so.

    How can I fix?

    Thank you!!

    Try disconnecting all the services using your Apple ID on your iMac, iTunes, FaceTime, iMessage and try to sing.

    If you cannot connect to the iTunes Store - Apple Support

  • Connection problems can not connect I forgot my password I did ' get the confirmation email.

    Cannot connect connection problems I forgot my password I have request a Reset password but I did ' t get the confirmation email.

    Go through the logon process. When you enter your name / password
    should be a link I forgot the password. Site more to have that.

  • Why do I get "Connection problem" on my laptop, when I try to access my e-mail account Yahoo with the new version of Firefox?

    Since I updated firefox to 29.0.1 on my desktop, I can't access my account at Yahoo.com from my ASUS laptop. "Connection problem" appears when he tries to retrieve new messages. I received mail on the ASUS 12/03/13, but from now on I get this message and no new mail arrives at the ASUS.

    Some problems occurs when your Internet security program was set to trust to the
    a previous version of Firefox, but no longer recognizes your updated as version
    level of confidence. Now how do I solve the problem: to allow Firefox to connect to the Internet
    Once again:

    • Make sure your Internet security software is up-to-date (for example, you are using the latest version)
    • Delete Firefox to list your program of trusted or recognized programs, then add it again. For detailed instructions, see Configure the firewall so that Firefox can access the Internet.
  • Strange internet connectivity problem

    Hello!

    I'm having a connectivity problem I have never met before. I use a wireless router from Apple with internet cable.

    Yesterday, my computer would be is no longer in contact with my router wi - fi. I get a message that the network could not be attached (I ran the Diagnostics wireless, but it's a whole lot of sense to me empty files). However, I also have a Roku, and which IS connected to the WiFi without problem. I completely stopped and restarted the computer, no joy. Reset the modem and the router, no joy. Still works with Roku, not with the computer. But the weird part is, I have Optimum Online, which allows subscribers to log-in to its hotspots, and it worked! I am connected Optimum wi - fi network on my computer right now.

    So I don't know where is the problem! It is not the router, because this is related work with Roku and is not the computer, because it is connected and working with the Optimum hotspot. What gives?

    Try this!

    Go to the Apple menu > System Preferences > network

    Select a Wi - Fi connection in the sidebar and then click on the button "Advanced...". "in the lower right corner of the screen

    In the list of preferred networks, delete the name of your Wi - Fi network

    Click on the "OK" button to save that change and then 'apply' in the network preferences window.

    Now, go to the Applications folder > utilities > Keychain Access

    Make sure that "Login" keychain is selected and "All items" in the category is selected in the sidebar

    Use the search field to find items that Keychain with the name of your Wi - Fi network and remove

    Quit Keychain Access

    Now try and access your Wi - Fi network

  • Icloud connection problems

    Hi - I've changed my Apple ID a year ago.

    For these last days, I get messages saying: my Mac cannot connect with icloud and gives the e-mail address of old and obsolete, that I stopped using it a year ago. I ' ved checked my details with the system Apple ID. Everything is up-to-date. Checked the system does not recognize the old e-mail address or the password tied to it.  How to stop the message saying that there is a connection problem?  Thank you very much

    Can you go into System Preferences/iCloud and log out of the old ID? Then log in with the ID of the new?

  • connection problems with the version 6.18.0.106

    Hello

    I have Windows XP and I have always used an earlier version of Skype, but now the old version is retired and I can't use it. So I download the new version 6.18.0.106, but this one has a connection problems. Every 4 seconds, I am offline and then online again for 4 seconds. My connection is OK and my provider does not block Skype calls. Is there anyone who knows how to fix?

    Try to uninstall the latest version and install the older version of Skype 6.14.0.104:

    http://download.Skype.com/MSI/SkypeSetup_6.14.0.104.msi

  • Connection problems: Win7, Skype 6.14

    Hello

    I had connection problems since just after I did a windows update last night. (no idea if it's just a coincidence?)

    I read through several other posts here, tried reinstalling Skype several times (also re-installed an older version), checked the compatibility mode and still no joy. Oh, I restarted a few times too.

    I'm trying to connect using my Skype username and password (I don't have an account of ms) but the screen is just stuck there, it says signing in and the whirly thing (term techy lol) is just Dervishes round and round.

    I luuuurv my Skype, absolutely essential for me because I work from home, so I hope someone can help. PLEEEEASE :-)

    Thank you

    Try to uninstall the currently installed version and install the older version of Skype 6.9.0.106 using this msi installer:

    http://download.Skype.com/MSI/SkypeSetup_6.9.0.106.msi

  • LJ pro M177fw: eprint center connection problem

    Hello

    today I am trying to add my new printer to my eprint account, but I do not remember my pwd, so I want to co reset the password.

    By e-mail, I received a link

    http://h30495.www3.HP.com/reset_password/xxxxxxxxxxxxxxx

    but it didn't work, the Web server show this error:

    SERVER ERROR

    Oops! Only, something was wrong with our server.

    Try refreshing the page.

    I tried different browser and pc, but I can not reset my pwd.

    Is there a solution to this problem?

    Is the server down for ever?

    Thank you and best regards.

    Roberto

    Hey @Roberto_ITALY,

    Thanks for posting in the Forum from HP Support.

    I understand that you are unable to claim your HP Color LaserJet Pro MFP M177fw in your account ePrint Center due to a connection problem.  I would like to help.

    I don't see this particular error with password resets from time to time.  I have a workaround that can clear up this place for you:

    • Click here.  This will bring you to <www.snapfish.com >.  As the Snapfish site is linked directly with ePrint Center and HP connected, you can try to reset your password as follows - click the connection icon and then "forgot your password":

    • Enter the e-mail address that you use to connect to the ePrint Center and click on submit.
    • You should receive a message of automatic reset of password by email - the reset as expected before and then try to use this new password to Snapfish to connect downtown ePrint.
    • If this does not solve your problem of access ePrint Center, please call our Cloud Services to 855-785-2777. If you do not live in the United States / Canada region, please click the link below to get help from your region number.

      http://WWW8.HP.com/us/en/contact-HP/WW-phone-assist.html

    I hope this helps.  If my suggestion worked in your favor, feel free to give me a virtual h.o.t. by clicking on the 'Thumbs Up' icon below.

    Have a great day!

  • Connection problems. Cursor "turns" without touching the keys. Keypad lock. Tracpad disconnects. Need to close and restart before both work again. Any guidance will be appreciated.

    CONNECTION PROBLEMS.

    CURSOR "Runs" AFTER I TOUCH a BUTTON AND THEN the KEYBOARD LOCKS AND TRAC PAD DISCONNECTS.

    NEED TO SHUT DOWN I HAVE MAC AND TURN IT BACK ON AND KEYBOARD WORKS OK.

    IT IS AN INTERMIITANT BUT AN ANNOYING PROBLEM AND I WOULD GREATLY APPRECIATE SOME GUIDANCE.

    Thank you

    Hello

    Please, do not type in capital letters, which is considered yelling that I am sure that you are trying to do.

    Have you had the opportunity to read If your Apple wireless mouse, keyboard or the trackpad will not work as expected - Apple Support ?

  • connection problems mouse Apple

    I have connection problems and keeping a Bluetooth connection between my mac mouse for my laptop.

    Try resetting the PRAM and SMC.

    Barry

  • Satellite L10-119: OKI 8w Lite printer connection problem

    I have the Toshiba Satellite L10-119 series. I use it with 8W OKI printer. The printer works on USB port. Every day, when I print a ~ 10 pages of the judgment of the printer and XP driver display statement "connection problem". Currently, OKI prints all pages. Only restart helps XP on.

    The operating system is Windows XP and printer has an OKI dedicated for XP drivers. Other USB devices are working properly. I reinstall the Intel chipset drivers, I checked the printer on the other ports.

    Please send a sollution mail: michaljaniszek (at) walla (dot) com

    Hello

    You suggested that all other USB devices work properly on this unit.
    In this case, I guess that it s not a Satellite L10 problem but the OKI printer problem.
    Unfortunately, Toshiba is not responsible for the 3rd party hardware or software.

    However, I studied a bit on the net and found a few questions about the OKI printer problems. There are different issues and all have suggested contacting the OKI support. Well, in my opinion you should also ask the support. There may be more recent driver. Check it out.

    Good luck

  • Officejet 4500g510g connection problem

    The printer constantly alternates of connected and disconnected as displayed on the HP Solution Center does not allow me to fax or scan but allows me to print

    Hello VinhLong,

    When you connect a device to a router router assigns the device an IP address. There are two types of these assignments. You have a dynamic IP or static IP address.

    A dynamic IP address can change and is automatically assigned by the router. Whenever you reboot your computer, printer, etc., the router can assign the unit a new IP if for some reason he can't use it. This is the default setting and is what most people use.

    An IP address is an address that you essentially hard-code in the router which tells the router whenever this device connects to the network assign this IP address. Using the static IP address performance and connectivity is generally improved.

    Since you have a connection problem, we should see if we can stabilize the connection hard coding a static IP address on the router and the printer to the printer to use when connected to the router.

    Information about setting up a static IP address were taken from this article for troubleshooting HP.

    The "Printer not found" error message during the Installation of wired (Ethernet) network in Windows XP and Windows Vista

    The article is not completely relate to your problem, but we use it to capture the static IP address instructions.

    The DHCP Dynamic Host Configuration Protocol () service provided by the router can change the Internet Protocol (IP) address on the HP product, which interferes with the network installation. An IP address uniquely identifies the product over the network.

    Follow these steps to assign an IP address does not change to the product by the built-in webserver (EWS).

  • WMware el capitan apple id server connection problem

    Hello

    I just bought mac os x mountain lion and I install machine wmware virtual. When I level to el capitan, apple id server connection problem came. I have try so much to solve this problem, but I couldn't fix it in any case. When I'm not using the network it works perfectly fine, but if I use the network working I can't connect store mac or itunes or icloud. I spoke with the administrator of this issue, he could not find a solution too. Is there anyone know of this problem or what we should do to overcome this problem.

    When I try to open an app store, itunes, icloud or imessage session, he said: "there was a connection to the server id Apple error."

    Have you seen this page? A few bugs have been reported there for this error message. One of them is related to a proxy server and can be done with a computer serial number

Maybe you are looking for

  • Question of bedside table

    I tried to use the bedside table. Even spent the extra $30 for a stand to keep it on the side. When activated, nightstand mode turns on, but the watch quickly turns off by itself, goes black. Is it possible to have show constantly? The charger is con

  • FileSelectPopup hang with restrict extension option and the imaqGetFilterNames (.)

    Hi, I have a problem with FileSelectPopup suspended.  It happens when I limit the file extension in the pop up, and the user types a name with a different extension (for example, if I limit the file extension to "*.dat" and the user types "data.txt")

  • Error in Windows Live Mail: "this application has requested execution to terminate in an unusual way.

    Occasionally, the following message appears when my wife receives an email from someone on facebook. "This application has requested execution to terminate in an unusual way" launches us live mail. It has something to do with Microsoft Visual C ++ Ru

  • Computer Windows Vista does not recognize the USB mouse

    Original title: does not recognize usb devices... Im trying to use the mouse... got a new mouse... still does not recognize it worked but stopped, got a new mouse and still does not recognize it. I really need it... help please

  • Compilation of projects - VS2013

    If anyone has some useful resources to find how to compile projects; the Momentics IDE is installed, but I can't, compilation of changes to a program rolling. I was hoping that it is actually possible to use visual studio 2013 to develop and compile,