Another question about using objects in SQL queries
Hi gurus, I need your thoughts on this:
I have created generic object type "tree" - the constructor takes as a parameter sql query returning "node_id" and "parent_node_id". As a tree - the object has all related to a tree structure member functions and one of them is "oldest_relative" (the tree may not be fully connected - it may be more like a set of many trees, so it's not necessary all nodes to have the same root).
I also have departments table with the following fields: department_id, parent_department_id, department_name,...
all records in the table w/out parent_departments (parent_department_id is null) are considered divisions.
Now if I run the following query:
SELECT "DEPARTMENT_ID", "PARENT_DEPARTMENT_ID", "DEPARTMENT", tree('select department_id "node_id", parent_department_id "parent_node_id" from departments').oldest_relative("DEPARTMENT_ID") "DIVISION_ID" FROM departments
my question is: Is the tree object created for every row or does Oracle somehow caches the object since the object itself is not changing but only the parameter for the oldest_relative member function.
The table only has a few hunderd records and I can't see much of a difference in the execution time btw the query above and query like this:
SELECT "DEPARTMENT_ID", "PARENT_DEPARTMENT_ID", "DEPARTMENT", b.t.oldest_relative("DEPARTMENT_ID") "DIVISION_ID"
FROM departments left join (select tree('select department_id "node_id", parent_department_id "parent_node_id" from departments') t from dual) b on 1 = 1
where the object is clearly created just ones. (there is probably a better way to do it instead of this join)
Pls elaborate
George
Hi, TREE is not a function but PL/SQL object type I have written representing tree structure. The Oracle version is 10g.
Similar Messages
-
Question about using objects in SQL query.
I had posted this question in the SQL/PLSQL forum but I guess nobody took the time to understand exactly what I am asking so I decided to try here hoping to get the answer. So here is the thing:
I have created generic object type "tree" - the constructor takes as a parameter sql query which returns "node_id" and "parent_node_id" - this is all we need to have a tree. The object has all related to a tree structure member functions and one of them is "oldest_relative" (the tree may not be fully connected - it may be more like a set of many trees, so it's not necessary all nodes to have the same root).
I also have departments table with the following fields: department_id, parent_department_id, department_name,...
all records in the table w/out parent_departments (parent_department_id is null) are considered divisions.
Now if I run the following query:
SELECT "DEPARTMENT_ID", "PARENT_DEPARTMENT_ID", "DEPARTMENT_NAME", tree('select department_id "node_id", parent_department_id "parent_node_id" from departments').oldest_relative("DEPARTMENT_ID") "DIVISION_ID" FROM departments
my question is: Is the tree object created for every row or does Oracle somehow caches the object since the object itself is not changing but only the parameter for the oldest_relative member function.
The table only has a few hunderd records and I can't see much of a difference in the execution time btw the query above and query like this:
SELECT "DEPARTMENT_ID", "PARENT_DEPARTMENT_ID", "DEPARTMENT_NAME", b.t.oldest_relative("DEPARTMENT_ID") "DIVISION_ID"
FROM departments left join (select tree('select department_id "node_id", parent_department_id "parent_node_id" from departments') t from dual) b on 1 = 1
where the object is clearly created just ones. (there is probably a better way to do it instead of this join)
Pls elaborate
GeorgeNot exactly sure what the question is...
As I understand, you are comparing the following two constructor calls:
+select.. tree('select department_id "node_id", parent_department_id "parent_node_id" from departments').oldest_relative("DEPARTMENT_ID") ... FROM ...+
+select tree('select department_id "node_id", parent_department_id "parent_node_id" from departments') ... FROM dual+
These calls are the same (besides the 1st one doing an immediate implicit call to a method of the object being constructed). The number of times these are being called depends on the number of times this SQL projection is applied - and that is determined by the number of rows being projected by the SELECT.
The latter one is against DUAL which only has a single row. So that constructor is only called once. The former can be against multiple rows. Obviously a single pass through a data set is desirable - which means that the sub-select (use by the constructor) should ideally only be executed once and makes the 2nd method more desirable.
However, I'm having a hard time understanding why the class and constructor are at all needed. Why pull data from a SQL table into PL memory? As that is where the class will need to cache and store the results of that construction parameter SQL SELECT. And once in PL memory, how does the object effectively access, search and use this cached data?
PL memory is expensive. It is not sharable.
PL data structures are primitive - these cannot be compared to SQL structures in the form of tables and columns that can be stored in a number of physical ways (index tables, hash tables, partitioned tables, clustered tables, etc). Cannot be indexed like SQL structures using B+tree, bitmap, function and other indexing methods. Cannot be sorted, grouped, analysed, filtered, etc like SQL structured data.
It makes very little sense to read SQL data into a class and then deal with that data, cached in expensive PL memory, using primitive PL structures.
And the same would be true if Java or C# was used. The best place for data is inside the SQL engine. That is the most superior environment for data. It can processes more data, scale better, perform better and offer more flexibility, than pulling data from it and then crunch that data using PL or Java or C#. -
Hi Guys,
Need some help here with understanding the basics. Basically i'm getting a bit confused on how objects are instantiated and used in java. Firstly an object of a class is instantiated with the following piece of code;
ClassA obj = new ClassA();This would allow you to use the variable and method of ClassA. Say ClassA has the method set(). You could call it via the obj object with the code;
obj.set();that I understand. You can also declare an annonymous object which is an object that is only really going to be used once for the purposes of the statement. For example, something like;
System.out.println(new Date());That I understand too. However what is confusing me is this type of object instantiation;
public static ClassA obj; You cannot not call the set() method of the ClassA in the same way so why use this? Also this code is confusing me;
obj = new ClassA();Are you saying that a precreated object is now equal to ClassA. Meaning that you can call its set() method in the same way?
What do they mean? Why are they used? Can anyone give me an example of how they would be used?
Any help would be appreciated.public static ClassA obj;This is a declaration, basically you are telling the
computer that you intend to make a "ClassA" object
and the program will allocate enough memory to hold a
"ClassA" object, although the object "obj" does not
actually "exist" at this time. This is why you can't
use the set() method, because obj doesn't have any
methods at all since it hasn't fully been created
yet.
obj = new ClassA();This is what actually creates the object, according
to the instructions in the object's "ClassA()"
method, which is known as a constructor.
ClassA obj = new ClassA();This statement simply combines the two previous ones
into one line. You are declaring "obj" to be a
"ClassA" which allocates memory to store it, and then
immediately executing the "ClassA()" constructor to
build a new ClassA and store it in the memory space
referenced by "obj". Does any of that make sense?
I'm not exactly a teacher, but I think I understand
your problem enough to explain it.Yes that does make sense. However i have some more questions now if you dont mind answering.
If the code
public static ClassA obj;simply allocates the memory (instantiate) and does not name (declare) the object then why cant you do something like this afterwards;
obj = new ClassC();or this;
obj1 = new ClassA();The object doesn't yet exist you only putting memory aside for it. Its only at this point that your naming the object and setting the parameters for it.
Why bother even allocating memory for the object without actually declaring the object? Surely combing the two statements is more efficient and makes more sense than separating them. Why do you need to allocate the memory and then give it a name?
Also the following piece of code;
ClassA objA = obj;Since obj is already intialized as being a new ClassA object, then is this simply declaring and instantiating a new object of type ClassA? And what is the difference between this and;
ClassA objA = new ClassA();Thank You -
I have a question about using multiple ipads in our school. Each of our teachers have a iPad and AppleTV in their classroom. The issue is, with our classrooms so close in proximity to one another, is there a way to pair teacher #1 iPad to its AppleTV without effecting/projecting onto the adjacent teachers #2 classroom AppleTV?
Not as such.
Give the AppleTV units unique names and also enable Airplay password in settings with unique passwords for each teacher.
AC -
Question about using TVARV in an ABAP program
Hello gurus, Im sorry about the silly question.
I have a question about using TVARV in an ABAP program.
A program is presenting a problem and I think that in this code:
SELECT SIGN OPTI LOW HIGH
FROM TVARV
INTO TABLE R_1_163431035_VELOCIDADE
WHERE NAME = '1_163431035_VELOCIDADE'
AND TYPE = 'S'.
IF ZMM001-VELOCIDADE_B IN R_1_163431035_VELOCIDADE AND
ZOPERADORAS-OPERADORA = 'ABCD' AND
ZMM001-MATERIAL IN R_1_163431035_PRODUTO.
ELSE.
ENDIF.
What happens is that the value "ZMM001-SPEED" B not exist in "R1_163431035_VELOCIDADE" but the program executes commands under the IF and not under the ELSE, as I imagine it would work. Is this correct ?
I am new to ABAP programming, but I have a lot of XP in other programming languages and this makes no sense to me.
Anyone know where I can find some documentation of the use of "TVARV" in ABAP programs?
I search the Internet if other programmers use TVARV this way, but found nothing, which leads me to think that was a quick and dirty solution that used here.
If this is a bad way to program, what would be the best way?
Regards
Ronaldo.Hi Ronaldo,
But in this case, the range is not empty, there are 17 records, in this way.:
For the column "SING" all values are "E"
It means that the result is false if ZMM001-VELOCIDADE_B has the same value as one of the 17 records (E = exclude).
For instance, if it has value 'C' and one of 17 records matches C, then the result is false.
The "IF" with "IN" using "TVARV" as used in the program of the post above has the same behavior of a selection screen?
Yes, the same behavior as the selection criterion to be exact. You can press the help key in the complex selection dialog for more info.
I know it's a silly and very basic question, but other language that I used, only the SQL has the "IN" operator, but I think they work in different ways, so I would like to understand how it works in ABAP.
Not silly ;-). Yes they work differently.
More info here:
- http://help.sap.com/saphelp_nw70/helpdata/en/9f/dba74635c111d1829f0000e829fbfe/frameset.htm
- http://help.sap.com/saphelp_nw70/helpdata/en/9f/dba71f35c111d1829f0000e829fbfe/frameset.htm
BR
Sandra -
Question about using Runtime.getRuntime();
hi all
i have a question about using Runtime.getRuntime(). if i use this to get a runtime reference to run an external program, is it considered as starting a new thread inside the thread that starts it?
is it safe to do it in the Session EJB? if not, what can you recommand to do it? thankshi all
i have a question about using Runtime.getRuntime().
if i use this to get a runtime reference to run an
external program, is it considered as starting a new
thread inside the thread that starts it? No. Starting a process, starts a process. Threads have nothing to do with it.
is it safe to do it in the Session EJB? if not, what
can you recommand to do it? thanksSo what? Run another process? If you want to run another process in java then your choices are to use Runtime.exec() or use JNI. And using JNI will probably end up doing exactly the same thing as Runtime.exec().
"Safe" is harder. Typically to correctly use Runtime.exec() you must use threads. And as noted threads ideally should not be used. You can use them but if you do you had better understand why they didn't want you using them in the first place. You had also better be sure that you really want to wait for it to complete.
Other than that Runtime.exec() is safe because it can't crash the VM like other interfaces can (like JNI.) -
Yet another question about super raid - GS70
Yes, another question about Super Raid...I recently picked up the cheapest model of the GS70 on newegg which comes with 1 mSata SSD...just a mediocre one if I remember reading correctly. I'm interested in using MSI's Super Raid once my warranty is over with and have been reading a couple posts here:
1. Walk through of how to reinstall OS
--> https://forum-en.msi.com/index.php?topic=167198.msg1224063#msg1224063
2. I'll need a Super Raid card with links to get some, for about $100 each
--> https://forum-en.msi.com/index.php?topic=171722.msg1252847#msg1252847
3. I can't get Super Raid unless it originally came with it?
--> https://forum-en.msi.com/index.php?topic=171185.msg1249640#msg1249640
So what's the bottom line? Would I still be able to enable super raid in the future or am I SOL since it didn't come with it originally?
thanks!The GT70 CAN come with an adapter that has 2 (on the older, GT70 0NX models) or 3 (on newer GT70 20X models) sockets for mSATA drives. It's an optional part, that takes place of the primary SATA drive in the notebook, and physically has a different part that connects to the motherboard. If it doesn't come with the SuperRaid adapter, then it just has support for a single 2.5" SATA drive.
The GS70 on the otherhand, has this built into the motherboard and there is no swapping it out for a normal 2.5" SATA drive. You can only use mSATA drives (on those ports). The GS70 is meant to be an ultrabook, and therefore does not have the same ability as the GT70 to house up to 2 full size 2.5" SATA drives.
That's really the main difference here. Without physically seeing a GT70 to see how the SuperRaid adapter works, it's slightly difficult to explain.
But in the end, I wouldn't worry about the SuperRaid....The GS70 should have support for Intel Raid Management Engine, in which case that's all you really need. -
Question about using Revel on iPhone4
I have just created 3 carousels on Revel and put pictures in them from my camera roll. Now I want to move some to a different carousel. I can copy and put them in the new carousel, but how do I delete them from the original carousel without deleting the picture from the entire system? The delete warning concerns me.
jessevsm wrote:
I have another question about the Vision:M. I was curious if you're able to password protect certain folders so that in order to access them, you have to put in a password. I know you can password protect files so it can't be messed with or whatever, but it doesn't stop the files from being viewed. Is there any way to do this?
there is an option somewhere in the settings menu to hide protected files, so you can't see them or edit them till the password is entered. -
Make sure that your bean is implementing the serializable interface and that
you are accessing the bean from the session with the same name.
Bryan
"Sandeep Suri" <[email protected]> wrote in message
news:[email protected]..
Hi, I have quick question about use of USEBEAN tag in SP2. When I
specify a scope of SESSION for the java bean, it does not keep the
values that I set for variable in the bean persistent.Thanks,Sonny
Try our New Web Based Forum at http://softwareforum.sun.com
Includes Access to our Product Knowledge Base! -
Question about using new battery in old Powerbook
I have a pre-intel Powerbook G4, and the battery is pretty much toast (lasts about 15 minutes now). I have ordered a new battery for it, and I have this question about using it:
Am I smarter to keep the new strong battery out of the PB most days (as I usually work with it plugged in at home) and just pop it in when I know I will be out surfing on batteries? Or is it just as good living in my laptop 24/7 and only occasionally being called upon to do its job?
Current bad Battery Information below:
Battery Installed: Yes
First low level warning: No
Full Charge Capacity (mAh): 1144
Remaining Capacity (mAh): 1115
Amperage (mA): 0
Voltage (mV): 12387
Cycle Count: 281
thanks folks, ShereenHi, Shereen. Every Powerbook battery wants to be used — drained and then recharged — at least every couple of weeks. If you've always used your Powerbook on AC power nearly all the time, and not followed that pattern of discharging and recharging the battery every week or two, it's possible that your use habits have shortened the lifespan and prematurely diminished the capacity of your old battery. Of course it's also possible that your battery is merely old, as a battery's capacity also diminishes with age regardless of how it's used. You didn't say how old the battery is in years, so this may or may not be an issue. I mention it only because it can be an issue.
For general information on handling a battery for the longest possible lifespan, see this article. My advice on the basis of that article and long experience reading these forums is that it would be OK to do as you propose, but I doubt that you'd derive any significant benefit from it. You would still want to be sure of putting the new battery through a charge/discharge cycle every week or two, even if you didn't have a reason to use the Powerbook away from home or your desk, because sitting unused outside the computer is just as bad for a battery as sitting unused inside it. And you should never remove the battery from your computer when it's completely or almost completely discharged and let it sit that way any longer than a day or two.
Message was edited by: eww -
Question about using Macbook in Vietnam.
I have a question about using Macbook in Vietnam. I bought my mac here in the US, and I'm going to visit Vietnam, but I'm wondering if I can plug in the power directly into the wall or I have to need any convert power modem for my mac. The only thing I know that Vietnam use 220V so, can anyone help me?
You may need a plug adaptor, but you don't need a power converter.
(43828) -
I have a question about using adobe CS files in CS6 edition
I am a graphic artist . I have a question about using adobe CS files in CS6 edition. when I am gonna open thse adobe CS created files in CS6 Edition i get a color variation than i made with the CS version.Please give me an idea about this issue as soon as possible.If you need i can upload my problem as a screenshot to clearity
donrulz,
Are your Edit>Color Settings the same?
Are you using spot colours, such as Pantone (there have been some changes in CMYK values with new colour books)? -
Where Would be the best category to ask a question about using dashboard?
Where Would be the best category to ask a question about using dashboard?
However, don't ask it in this topic. Create a new topic for the question with a title describing that you are looking for Dashboard help.
-
Question about Using PAPI Web Service in PowerBuilder 9
Hi, all.
I Have a simple question about using papiws in power builder 9.
In pb9, I created a new Web Service Proxy Wizard and I input a url for papiws(ex. http://seraphpernote:7001/papiws/PapiWebService) and click next.
But I couldn't get any Service List.
In Eclipse, I used this url for using papiws well.
Does anybody know about this case??
help me plz.IIRC you must activate PAPI-WS for the engine. In Studio you do it by right-clicking on the project, then "engine preferences". In enterprise/standalone you must activate PAPI-WS in the Admin Center.
-
Question about using 10g/11g and APEX ...
Hi,
I just recently learned of Oracle's APEX and have a few questions about using it.
Can I use APEX with express, standard, and enterprise editions of 10g and 11g?
Are all of these free to use?You might want to read about APEX rather than jumping into questions that are reasonably well documented. Info at http://www.oracle.com/technology/products/database/application_express/index.html
Your specific questions:
1) Apex is a package that can be installed into any properly licensed database.
2) The price for the production license of the database varies by edition.
The price for Express Edition is $0 for use in production. Part of the cost for that edition is 'no Oracle Support based support, no patches, data volume limitation, etc.'
Maybe you are looking for
-
NO Sound; experts please help
I currently have no sound on my HP Spectre XT Ultrabook PC!!! Upon buying the laptop it had Beats audio on the laptop. That stopped working recently, but I still had the normal reduced audio, until that stopped completely soon after. I have tried mul
-
How do I add music or videos to my Apple TV
I did the initial sync with the setup but now I want to add more files from my iTunes library. When I start iTunes, though, my Apple TV isn't listed as a device. What am I doing wrong?
-
I hadnt used my iPod in awhile, so when I tried to sync it, the libraries didnt match up and to avoid hassle I decided to restore it (using the option on itunes when you plug in your device). After restoring, I tried to connect to iTunes again. While
-
Keychain Access: cannot add a new item: user name or passphrase not correct
When trying to add a new item to "Keychain Access", the application suddenly refused to do so. Error message: Title: An error has occurred. Unable to add an item to the current keychain. Message: The user name or passphrase you entered is not correct
-
Posting payment to a company with sole proprietor
Hi, Need you experts to help me address my query. For companies with sole proprietor, the bank account name is usually the owner's name instead of the company name. Currently, for such cases, we amend the vendor name from the company to the bank acco