Working with multiple results of a complex query
Hi all!
As I "advance" in learning PL/SQL with oracle, I now get stuck in handling multiple results of a complex query. As far as I know, I cannot use a cursor here, as there is no table where the cursor could point to.
Here is the concept of what I want to do (pseudocode):
foreach result in SELECT * FROM table_1, table_n WHERE key_1 = foreign_key_in_n;
-- do someting with the resultHere is my attemt, that freezes the browser gui and throws an internal database error:
declare
type t_stock is record(
baggage_id baggage.baggage_id%type,
section_id sections.section_id%type,
shelf_id shelves.shelf_id%type
v_stock t_stock;
rcnt number(2);
begin
dbms_output.put_line(TO_CHAR(rcnt));
loop
SELECT COUNT(*) INTO rcnt FROM (
SELECT baggage.baggage_id, sections.section_id, shelves.shelf_id
FROM baggage, sections, shelves
WHERE baggage.baggage_id = sections.contained_baggage_id
AND shelves.is_connex_to_section_id = sections.section_id);
IF rcnt <= 0 THEN
exit;
END IF;
SELECT baggage.baggage_id, sections.section_id, shelves.shelf_id INTO v_stock
FROM baggage, sections, shelves
WHERE baggage.baggage_id = sections.contained_baggage_id
AND shelves.is_connex_to_section_id = sections.section_id
AND ROWNUM < 2;
UPDATE sections SET contained_baggage_id = NULL WHERE section_id = v_stock.baggage_id;
commit; -- do I need that?
end loop;
END;
/So, is there a way to traverse a list of results from a complex query? Maybe without creating a temporary table (or is that the better way?).
regards, Alex
I reformatted the code
pktm
Ok, here are the details:
The tables are used to model kind of a transport system. There are terminals connected with sections that may contain 1 piece of baggage. The baggage is moved by a procedure through a transport system. After each of these "moving steps", I check if the baggage is in front of the shelf it should be in.
[To be honest, the give statement doesn't contain the info, in which shelf the baggage wil bee inserted. That was spared out because of the lack of a working piece of code :)]
But: if we consider the fact, that a baggage is in front of such a shelf in the way, that it should be put in this shelf, then all this makes some sense.
- move baggae through a transport system
- see if you can put baggage into a shelf
In order to "put baggage in a shelf", I need to remove it from the transport section. As the transport system is not normalized, I need to update the section where the baggage was in.
Uhm... yes it's a task that doesn't make too much sense. It seems to be some kind of general spirit in university homework :)
But: the FOR r IN (Statement) lloks good. I'll use that.
And, the ROWNUM < 2 is used to limit the size of the result to 1, there is no need to have a specific ordering. It's just because - afaik - oracle doesn't have a limit clause. I would appreciate your help if you know a better way to do limit resultsets.
best regards, Alex
Similar Messages
-
1. How to create an explain plan with rowsource statistics for a complex query that include multiple table joins ?
When multiple tables are involved , and the actual number of rows returned is more than what the explain plan tells. How can I find out what change is needed in the stat plan ?
2. Does rowsource statistics gives some kind of understanding of Extended stats ?You can get Row Source Statistics only *after* the SQL has been executed. An Explain Plan midway cannot give you row source statistics.
To get row source statistics either set STATISTICS_LEVEL='ALL' in the session that executes theSQL OR use the Hint "gather_plan_statistics" in the SQL being executed.
Then use dbms_xplan.display_cursor
Hemant K Chitale -
Why is scrolling not working with multiple youtube embeds layed out in a stack on one page?
Hi ,
This is a sort of performance issue , because your program takes more than the max time set for the program to execute in foreground.
There are many stuff in program which will hamper your performance.
I will list down a few
1. SELECT *
FROM konp
INTO CORRESPONDING FIELDS OF TABLE konp_itab
FOR ALL ENTRIES IN a363_itab
WHERE knumh EQ a363_itab-knumh
in this statement you are using for all entries a363_itab , but before this statement you are not checking if the table has any entry or not , please do remember that for all entries has this characterstic , that if you internal table does not contain any record , then all the records are selected from the database table. So in this case if you table a363_itab is empty , so what you want is no data must be seelcted from table konp , but what will happen is all the records in KONP will be seelcted.
2. While retreiving data you are using seelct * even though you do not require all the fields , an example is
<b>SELECT *
FROM mkpf
INTO CORRESPONDING FIELDS OF TABLE mkpf_itab
FOR ALL ENTRIES IN mseg_itab
WHERE mblnr EQ mseg_itab-mblnr.</b>
in this your internal table contains only 2 fields
<b>mblnr LIKE mkpf-mblnr, "Number of Material Document
bldat LIKE mkpf-bldat, "Document Date in Document</b> , but to get these 2 fields you are selecting all the fields of the table.
3. In select you are using into corresponding fields of table , it is not a good practice., so please avoidd it.
Please understand that you must try to reduce the access to your database tables and try to keep it minimal , because this same thing may happen becasue data in DEV is very less compared to the volume of data in production , so a program working in DEV will take much more time in PRD if not written properly and may result in timeouts , as in your case.
Please try to make chanegs to the prorgam and see if it works.
In case you have more queries , please do revert back.
Regards
Arun
*Reward points if replay is helpful -
Maintain performance while working with multiple shape layers (~50 )
Hey guys, I've been working on some projects lately where I need to animate a lot of shape layers cascading, arraying, with various animation properties. When I get to the point of using 30-60 or so shape layers, and they're all doing some kind of scale, position, etc. animations, my computer slows to a complete crawl. This then forces me into using a single shape layer and the repeater functions. These can work well sometimes, and don't hamstring the flexibility too much, UNTIL you need to incorporate varying colors. At that point, I usually switch my shape layers to masks and place a layer below with varying colors as needed. The shape animations then reveal those colors, but this doesn't work for a complex object that in itself requires many colors. Sooo...
What kind of workflows do you all have for working with multiple semi-complex objects at once? I figure I must be missing something, because this has gotten really limiting. Is everyone just working with 256GB of RAM?
FYI, my computer specs are:
2 x 2.66 GHz 6-Core Intel Xeon
32 GB 1333 MHz DDR3 ECC
ATI Radeon HD 5870 1024 MB
OS X 10.9.4 (13E28)
Thanks!!Pre-comping can speed up your previews if you are using disk cache, but nothing will speed up your first ram preview or a ram preview after a keyframe change except a better optimized system. All it takes to slow things down is one effect or a footage file that causes AE to start consuming memory and processor power.
As a test I just created a gradient filled rectangle, added rotation keyframes, duplicated the layer so I have 64 copies on my Mac Mini and tried a ram preview compared with the same comp with only 1 layer. Almost no difference in the time it took to preview 10 seconds. Threw in a scale transform for all layers and again, not much difference between one shape layer and 64. To make things much harder I change the rectangle to a Polystar and animated everything in the Polystart transform properties, set up a composition with 128 duplicates and a comp with one layer. 2.5 seconds for a ram preview at quarter rez for a single layer, 10 seconds for a ram preview for 128 layers. That's more than acceptable to me for a two year old Mac Mini with 16 gb of ram. Increasing the zoom factor to 50% with Resolution set to Auto doubled the ram preview time which was still acceptable.
This makes me wonder what else is going on in your composition. Any effects or other things going on? Have you optimized your system for maximum performance? There are links with suggestions for doing that all over this site as well as the Adobe recommendations found here: Optimizing After Effects Performance -
Working with Multiple Files in Workspace Layout
If I was working with multiple files in the workspace layout, they each used to be available for selection from a tab. Now I can either cascade the files horizontally or vertically - but not have them appear in a tab across the top of the workspace layout.
Does anyone know how to set the workspace to present multiple files in tabs? I have CS3.Tanya,
This may not help, but the times when that happens to me is when I go too fast and some operations haven't finished. I then try to select a file that hasn't completed and the file I select is in the process of having the data updated. The worst is when it is trying to render as I am doing something.
I hope this helps some.
Mel -
Multiple Quizzes with multiple results (in Captivate 6)
Hey guys, Thanks for reading!
Does anyone know if it is possible to do multiple tests with multiple results in captivate 6? or if it is possible to have a pre-test with a quiz, and have separate results for each?
I've been having a play with captivate 6 and when I put a quiz in, it overrides the results slide for my pre-test.
Looking at the results slide master properties I can choose to have results for one of my quizzes but not both (even on separate slides):
It wont even let me insert another slide based on the other result.
I would like to know if multiple quizzes with multiple results is possible in Captivate 6?, or if I am simply doing something wrong?
Thanks!Sorry for way-late reply...
It's really more how your LMS handles 'courses' and the terminology it uses.
Essentially, most often, a 'SCORM Package' (SCO) is a 'course'. I'd rather call each SCO a 'lesson' as, to me, 'courses' should be setup in the LMS with a series of 'Lessons'.
Regardless of the terminology, each 'SCO' is launched by the LMS and one score can be recorded for it via SCORM.
So if you need multiple final scores recorded, each of those final scores need to be in their own SCO.
A common approach is a Pre-Test SCO (or 'lesson', or 'course', whatever term), a 'Content' SCO perhaps with some interspersed scored interactions, and a Post-Test SCO...all three merged together as a 'course' (or whatever term) within the LMS.
That said, as said, it really all depends on how your LMS handles various SCOs...
Clear as mud?
E -
Working with multiple layers in CS 3 ?
In order to work with multiple layers in cs3, I first need to open few images to work with,and when I open few images it only shows last image that I opened.Frist images can't be seen in workspace, and when I open new document I can't see not even one photo I opened?
try tapping the F key a few times until you get to the screen mode that allows you to see all image windows.
-
Does WRT54GP2 work with multiple ViOP providers ?
My question is, Does WRT54GP2 router work with multiple ViOP providers ? Can I use it with a ViOP provider other then Vonage ?
Thanks, JohnYes you definately can , all you need is a VOIP adapter that supports SIP . It's a standard protocol and is supported by all routers and VOIP providers
-
Reg:working with multiple windows in webdynpro-abap
Hi ,
How can we create multiple windows and how can we link them...
suppose we have 3 fields on first screen .how to move the data from the first screen to second screen..
Thanks & Regards
Suman PuthadiHi
As per your Subject you are looking for "working with multiple windows in webdynpro-abap" and for abap there is a different forum. Web Dynpro ABAP
Hope its clear to you...
Even you can read this post when ever you get time Read before posting
Regards
Ayyapparaj -
Problem when working with multiple sequences
Dears,
In order to make life easier (I am currently working on a rather long project), I work with multiple sequences, one per chapter.
My problem: I named one sequence "assembly sequences" in order to add the various sequences. I dropped the sequence no 1, then no 2. All works fine, beside that when playing the sequence no 2, I see two black lines on top and bottom of the screen for the all length of the sequence. Which is not the case when I click on the sequence itself and play it independently.
Any idea how to solve this ?
Thanks
NicThanks, what happened is that :
1st sequence is like this : Frame size 720x576 pixels, video rate 25fps, Compressor DV-Pal. And I think it is the one appropriate for me and my country.
2nd sequence is like this : Frame size 720x480 pixels,
video rate 29.97 fps, Compressor DV-DVPRO-NTSC.
I think I should change the second sequence setting, but can I do it after all the work I have done, and continue making a 3rd, 4th and so on ?
Tx for your precious help,
Nicolas -
Just started working with multiple artboards in ai but have read nothing about the layers panel, whether you use one layers panel for all the artboards or if the layers panel is duplicated so there is one for each artboard.
I don't really understand your problem, but I've had headaches with managing a GUI before (as many programmers have, I'm sure).
My best advice, if the scheme your using to build and manage a GUI is too confusing for you, the programmer, to easily understand/manage, change the scheme. Even if this means recoding a good deal of your program (though, hopefully, you've kept the GUI as seperate from your functional code as possible) it should be worth it.
Perhaps a clearer explination of your problem would help better illustrate your problem?
-Rejun -
Constructing test with multiple results
Hi, I have the question for Lilybyri:
I learn to construct test with multiple results from your article:
Constructing Test with Multiple Results (CP5)
This is exactly what I need. My question is - can I use the radio button interaction or smart shape instead click box? What you recommend? I use CP7 or CP8.
Need to publishing the final test both HTML5 and SWF output. My test wil have 55 questions and 4 results score - one of them describe the personality of learner.
YarikAdvasntage of click box and shape button is that they can have score
attached to it. That is not the case for radio buttons interaction that has
also limited formatting options. -
How do icloud and itunes match work with multiple libraries?
How do icloud and itunes match work with multiple libraries?
This forum is for troubleshooting compatibility issues between Macs and Windows, not iTunes. You'll probably want to repost your question in the iTunes discussions:
http://discussions.apple.com/category.jspa?categoryID=150 -
Display a query with multiple results and a little addon :D
Hello everybody,
I wanna make a JSP page that displays multiple results from a query.
I wanna those results to appair in a table, a row each one, and also a little "square radio form buttton" that makes me select rows I wanna delete (with another button at the end)
any idea?
Better if you post the code, I'm not a good JSP writer
thanks everybody for your attention and your time
Kind regardsYou're right.. I'd post nothing..
But it's all still in progress and I don't know what to post..
I understand is really difficult to invent some code without an origin (variables, functions, the bean), but also some general info would be really appreciated,also making a streched example if you can..
REQUESTS:
1) I need make a new JSP page, where will be visualize rows returned from a precise query selection
2)I use Beans, and my idea was to create Bean in JSP, open connection, make the query and create "some kind of FOR cycle" that fills a table, row by row
3)Every row must got a little "radio button" for a delete selection; the delete function will start when I press a specific button in this page(i'll use a servlet for this function)
4)The biggest and important trouble is HOW to display multiple rows in the Table -
Print to pdf often doesn't work with multiple pages?
When I try to print to pdf, it often doesn't work right.
I can select, for example, multiple Excel worksheets to print. It looks fine with 4 pages in Preview, but when I select save as .pdf, it only prints 2 of the 4 pages, and it prints those in 2 separate documents rather than a single .pdf document with multiple pages.
Is there a way to do this? Is this an Apple error or Microsoft error? Since it looks fine in Preview, my guess it is an Apple error?
MarkIt sounds like this is the problem with the way Apple handles multiple orientations in a pdf document. You can use Acrobat to print the files - it handles multiple orientations correctly. There was a previous thread on this:
http://discussions.apple.com/message.jspa?messageID=1983431#1983431
Maybe you are looking for
-
Can I put more than one user under one Apple ID account. I want to let other family members use imessage on their own Apple device. Or is there another way to get this end result?
-
Animated Gifs won't animate when forwarded to other people from mail...
I received a cute series of animated gif files via email today. I decided to forward the mail to a few friends and included myself on the list since I've had issues with forwarded gif files not animating in the past. Several friends received the file
-
Experiencing HDTV on my Powerbook
I was unsure where to post this query, so I thought here might suit. I have the PB described below, and an HD Ready Samsung LCD TV. Can I connect the Powerbook to the TV and experience true HDTV? If so, how would I do it? With the VGA port? Any where
-
Mac101 (German?); Hands on Finder Intro;
Hello, my mother in law (60+) plans for a computer her first at all. Is there a Mac101 out in German language? And if possible a printable version too? Good old dead old OS7 Mac was shipped with a nice intro for the very first steps to use the finder
-
How to organize / group fonts in Photoshop
When I open fonts drop down menu inside of Photoshop, I have over 300 fonts listed in alphabetical order, most of which I don't use. I installed about 20 fonts that I like. But how do I group them together? After typing and selecting text in Photosh