Best way to populate smaller collections from one huge collection?

Best way to populate smaller collections (based on underlying tables) from one huge collection (based on View)?
1) Real time facts: Data volume is decent, 10K rows avg (may be 100K in 1 year), 1 view - 4 underlying tables
2) Is Associatve arrays best or nested table???

CODE BELOW:

type my_emp_tbl IS TABLE OF emp%ROWTYPE index by pls_integer;
type my_dept_tbl IS TABLE OF dept%ROWTYPE index by pls_integer;
type my_loc_tbl IS TABLE OF loc%ROWTYPE index by pls_integer;

CREATE OR REPLACE emp_dept_loc_pkg IS
 -- BASED ON VIEW
 type my_emp_dept_loc_tbl IS TABLE OF my_emp_dept_loc_view%ROWTYPE INDEX BY pls_integer;
 emp_dept_loc_procedure (in_emp_dept_loc_tbl IN my_emp_dept_loc_tbl);
END emp_dept_loc_pkg;

CREATE OR REPLACE emp_dept_loc_pkg BODY IS
 PROCEDURE emp_dept_loc_procedure (in_emp_dept_loc_tbl IN my_emp_dept_loc_tbl) IS
 BEGIN
 
    1) Process each record from the input (in_emp_dept_loc_tbl) collection and populate each of the
       other (decalared in separate pacakges based on underlying tables of this view) collections EMP, DEPT, LOC????
       
 END emp_dept_loc_procedure;
END emp_dept_loc_pkg;
loginboyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
I would probably not use local collections at all.

Have you tested them versus just selecting from the view and processing without storing the results in memory as a collection?

As far as your question goes, I would personally set up both methods as as tests and, well, test them both against my database/server setup.
0
loginboyAuthor Commented:
Hi slightwv,

Thanks. Technically it's not fromt he view from the input collection has structure of view.

the frontend technology will pass that huge colelction as input. So can't go with direct from view to table. Need to use collections.

Please advice.
0
slightwv (䄆 Netminder) Commented:
So where does the view come into play?

Will you be loading the 'collection' into the view?  parsing it and loading it into the base tables? what?

If you can drive what data type the application passes in, have you considered passing in a CLOB as XML and loading tables from the XML?

I would probably go the XML route but the final decision will be based on your own specific situation and likely require individual testing.  No two systems are the same so no single solution works best across systems.

As I mentioned in the question you just closed:  Any final decision will have to be based on your individual testing.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

loginboyAuthor Commented:
In case DB nested table object (though it won't be used as a column in any physical table) are created, is it possible to read from this DB nested table object in PLSQL code? If so How?  what would the syntax be like?
0
slightwv (䄆 Netminder) Commented:
I would need to know more about your system and objects.  Even then, it still comes down to you needing to test variations on your specific system.

As for specific code examples that could not be found with an Internet search, we would need a test case that included objects, sample data and expected results.

That way, we could set it up on our test systems to make sure everything works the way you want it to work.
0
loginboyAuthor Commented:
Here are the test objects, sample data, expected results....
Questions below in comments, Please help


create or replace type emp_obj_type as object
( ID     number,  
  NAME     varchar2(100),
  ROLE     varchar2(100),
  static function initialize return emp_obj_type
);
/

create or replace type body emp_obj_type as
  static function initialize return emp_obj_type is
  begin
    return(emp_obj_type(null,
                        null,
                        null));
  end initialize;
end;
/


create or replace type emp_obj_type_tbl IS TABLE OF emp_obj_type;

SET SERVEROUTPUT ON
declare
 v_emp_obj_rec         emp_obj_type := emp_obj_type.initialize();
 v_emp_obj_tbl         emp_obj_type_tbl := emp_obj_type_tbl();
begin

 for i in 1..3
 loop
   v_emp_obj_rec.ID    :=  i;
   v_emp_obj_rec.NAME  := 'ABC - ' || i;
   v_emp_obj_rec.ROLE  := 'ROLE of ABC - ' || i;
   
   v_emp_obj_tbl.extend();
   v_emp_obj_tbl(v_emp_obj_tbl.last) := v_emp_obj_rec;
   
 end loop;
 
 dbms_output.put_line('Count of nested table - '||v_emp_obj_tbl.count());
 
 /*
 1) How to I read (right here) the data from this nested table object?
 2) Don''t want to use Loops
 3) Can I do direct SELECT?  
 4) CAST, COLLECT, MULTISET? Keywords will be helpful?
 */
 
end;
/
0
slightwv (䄆 Netminder) Commented:
>>Here are the test objects, sample data, expected results....

Sorry but not even close.

I see no actual data and no desired results.

What I'm looking for is:
given:
create table tab1(col1 char(1));
--with data, the 'sample data'
insert into tab1 values('a');
insert into tab1 values('1');
commit;

I need:
-- the expected results:  Anything that is a number.

col1
------
1



I need to be able to create my own objects from what you provide so I can produce the results you post as expected.

What is better "A" or "B" isn't a good question because of what I posted above:  Every database/system is different.  What is 'best' for one may not be 'best' or others.

Only by trial and error can you make that decision.  We can 'suggest' but only once we can test...
0
slightwv (䄆 Netminder) Commented:
Here is what I understand:

You have some application written in some language that will pass some data in some format to your database.

You want to know what the 'best' way to take that data and do something with it.

Now do you see where we need more information?
0
loginboyAuthor Commented:
Worked with using the combo of TABLE and CAST functions

TABLE(CAST(variable_object_type AS object_type)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
loginboyAuthor Commented:
Found solution outside of EE
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.