using the collection as an array
HelloI want to use a collection as a Table.Can someone give me a code for this example.
I'm a collection to the parameter and want to join another collection that lines with another table. I want that, because if I'm going to do the operation loop taking elements one by one and in comparison with the record in the DB table, the performance should be degraded.
Please give the solution for the use of a collection in a table to join with another table.
Thanks in advance
Guljeet
Hello
You can find examples by doing a search on this forum or on AskTom.
See fi.:
http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:666224436920
Tags: Database
Similar Questions
-
How can insert quary in database by using the collection.
Hi friends,
My friend advice me to insert several point with collection for the use of multiple lines. But I don't know how to use the collection. How do I create the form to insert data using the collection.
Please send me any link or example .au insert data into database by using the collection.
My problem is:-
I have a bill with several point for example. Grapes (25) with amount here and now I want to add these question with quantity in my database, Badam (145), banana (49), Apple (12)
When I finally click on submit button.
Actully I was used as a table but I am facing a problem when using tabular, tabular, I enter first item for example. Apple and there quantity for example. 12 in the textfield and after clicking on Add line enter Buttom went to the database. but I want that entry should not go the database. But only the new line should add when I click on the button Add a line.
I want all these point 4 should enter into the database when I click on Submit Final.
Maury
Published by: Ed on September 6, 2009 02:22Hello
I would do something like the code:
BEGIN DECLARE vDATE DATE; BEGIN vDATE := TO_DATE(:P1_DATE1,'DD.MM.YYYY'); WHILE vDATE <= TO_DATE(:P1_DATE2,'DD.MM.YYYY') LOOP INSERT INTO ABC (DTE, LEAVE) VALUES (vDATE, :P1_C); vDATE := vDATE + 1; END LOOP; END; END;
You must ensure that the datepicker points both use the ' JJ. MM YYYY ' date format.
Andy
-
Interactive report editable without using the Collection
Hi Experts,
I use Oracle Apex 4.2.5
Is it possible to create an interactive report that can be changed in the same page? If the user edit a field, it must get updated in this table.
Let me know if this is possible without assistance from the Collections of the Apex
BR,
Patrick
Paul Broughton says:
Hi Patrick,
I also agree there is no out of the box solution, I need this for an application and I used elements of the APEX of the APEX_ITEM API
Here is a very basic example that I have not tested, but you have a question, something like:
[code]
Select
APEX_ITEM. DISPLAY_AND_SAVE (1, empno) as patient_id,
APEX_ITEM. TEXT (2, ename) as ename
Of
EMP;
[/ code]
Make sure you use columns of standard report as your column types.
When you click on submit you'd have a process similar to the following:
[code]
Start
BECAUSE me in 1... APEX_APPLICATION. G_F01. COUNTING LOOP
Update emp
set ename = apex_application.g_f02 (i)
where empno = apex_application.g_f01 (i);
end loop;
end;
[/ code]
That's assuming you don't need inline editing. If you do this will require an even more customized solution, but the way above requires no collections.
Thank you
Paul
Hi Paul,.
I think that IR out-of-box features do not work correctly when you use the APEX_ITEM functions in the query.
Here's another one you could use APEX 4.2
Yet another way to create & quot; editable interactive report & quot;
Kind regards
Jari
-
Why use the collections?
Please help me to better understand and to right the next point
to move from a PPT available in internet, I read a sentence under the heading "Why use collections?" Please find here
Use of complex data sets information to host non-PL/SQL environments using table functions
I think I understand: it means that complex data sets can be collected from oracle using only a single sql statement by using the installation, called Oracle Pipelined Table functions. http://www.akadia.com/services/ora_pipe_functions.html]
Is any other installation in oracle to the serveup of complex datasets of the information to the host non-PL/SQL environments?
Published by: o Manjusha Muraleedas, error corrected spelling.I watched the presentation and here's how I read it (although you might be better to ask the author):
Manjusha Muraleedas wrote:
My question is, why the statement "Serve up complex data sets of information to host non-PL/SQL environments using table functions" came under the title "Why use collections?". Just because there's an installation? or any other really good news?There is a hypothesis that is unwritten in the presentation: "complex" data is data that must be handled in PL/SQL, because only SQL does not work.
Nowhere the author says that a pure SQL solution should be changed into a solution of PL/SQL.
Once you decide that you must use the PL/SQL, you might want to put your data in collections in scalar variables.
I understand, complex data, works of art (suppose a structure with 3 columns of tables joing 5) can be meet non-pl/sql envirormment like Java, the use of the ref Cursor or xml. Collection using to do the same thing, this is not a good option.
Again, I think that the author uses "complex" as a shortcut for 'need to PL/SQL in the first place'. If the data must be processed in PL/SQL, there is no need to use PL/SQL scalar variables or collections.
I would say "use of the ref Cursor. Providing relational data in format XML should be the exception, not the rule. It has a cost of additional performance.Now lets talk about pipeline table functions.
...
functions table pipeline reached the performance of parallel processing. so even if binding commodity of time and memory is there, it will be performs better than refcursors or xml?Pipeline table functions perform no better than the ref Cursor. There are two processes running, one to SELECT and the other for the function, there will be more work on the server. With a ref cursor, there is a fair process to return the data.
Parallel processing is not a problem. If you can make it work in plain SQL, you can do in parallel in SQL simple.
Published by: Ashton stew on January 22, 2013 16:44
-
In a table by using the Collection update of nulls
I use collections to create a form in a table. However, I can't get the code to work. Could you please look at my logic and let me know what I am doing wrong?
Apex version: 4.1
1 process name: load Collection
a. process Point: On Load - before the header
Condition (b) process:
i. the condition Type: PL/SQL expression
+ ii. Expression:
+not apex_collection.collection_exists(p_collection_name => 'STAKEHOLDERS_COL')
c. code:
* 2. Report on the collection:if apex_collection.collection_exists('STAKEHOLDERS_COL') = TRUE then apex_collection.delete_collection( p_collection_name =>'STAKEHOLDERS_COL'); end if; apex_collection.create_collection_from_query( p_collection_name => 'STAKEHOLDERS_COL', p_query => 'select id , stakeholder_name , stakeholder_role_id , primary_contact_yn , receive_notification_yn , ''O'' original_flag , wwv_flow_item.md5(stakeholder_name, stakeholder_role_id, primary_contact_yn, receive_notification_yn) from eba_prjv_proj_stakeholders, p_generate_md5 => 'YES' );
a. query:
* 3. I have a button 'Add a line' add a blank line for inserts. The button "submit page" REQUEST As "ADD". *select apex_item.hidden(1,c001) id, apex_item.popupkey_from_query(2,c002,'select user_name d, user_name r from eba_prjv_app_users order by 1', 10) name, apex_item.select_list_from_query(4,c003,'select role_description d, id r from eba_prjv_stkhlder_roles order by role_code', 10) role, apex_ITEM.SELECT_LIST(5,c004,'N','Yes;Y,No;N') primary_contact_yn, apex_ITEM.SELECT_LIST(6,c005,'N','Yes;Y,No;N') receive_notifications_yn, apex_item.hidden(7, c006) status, apex_item.checkbox(8, seq_id) chkbx, apex_item.hidden(9, seq_id) seq_id from apex_collections where collection_name = 'STAKEHOLDERS_COL' AND c006 IN ('O','N','U')
* 4. The process of adding new line: *.
a. process Point: after submit - by the calculation and Validation
b. process of Condition: what key - add row
c. code:
* 5. I have a button Delete who submits the request page = 'DELETE '. *begin apex_collection.add_member( p_collection_name => 'STAKEHOLDERS_COL', p_c006 => 'N', p_generate_md5 => 'YES' ); end;
* 6. Collection update process:
a. process Point: after submit - by the calculation and Validation
+ b. Condition of process:
+REQUEST != 'ADD'
c. code:
* 7. Update the collection tableDECLARE l_status VARCHAR2(1); l_seq_id NUMBER; l_original_md5 VARCHAR2(4000); l_array_md5 VARCHAR2(4000); BEGIN FOR i IN 1..apex_application.g_f01.count LOOP -- Check previous status of Collection Member SELECT c006, c007 INTO l_status, l_original_md5 FROM apex_collections WHERE collection_name = 'STAKEHOLDERS_COL' AND seq_id = apex_application.g_f09(i); IF l_status = 'N' THEN l_status := 'N'; ELSE SELECT wwv_flow_item.md5(apex_application.g_f02(i) , apex_application.g_f04(i) , apex_application.g_f05(i) , apex_application.g_f06(i)) INTO l_array_md5 FROM DUAL; IF l_original_md5 != l_array_md5 THEN l_status := 'U'; END IF; END IF; IF l_status IN ('N','U') THEN apex_collection.update_member( p_collection_name => 'STAKEHOLDERS_COL' , p_seq => apex_application.g_f09(i) , p_c001 => apex_application.g_f01(i) , p_c002 => apex_application.g_f02(i) , p_c003 => apex_application.g_f04(i) , p_c004 => apex_application.g_f05(i) , p_c005 => apex_application.g_f06(i) , p_c006 => l_status , p_c007 => l_original_md5 ); END IF; END LOOP; IF :REQUEST = 'DELETE' THEN FOR i IN 1..apex_application.g_f08.count LOOP -- Check previous status of Collection Member SELECT seq_id, c006 INTO l_seq_id, l_status FROM apex_collections WHERE collection_name = 'STAKEHOLDERS_COL' AND seq_id = apex_application.g_f08(i); IF l_status = 'N' THEN apex_collection.delete_member( p_collection_name => 'STAKEHOLDERS_COL' , p_seq => l_seq_id ); ELSE apex_collection.update_member_attribute( p_collection_name => 'STAKEHOLDERS_COL' , p_seq => l_seq_id , p_attr_number => '6' , p_attr_value => 'D' ); END IF; END LOOP; END IF; end;
a. process Point: present - according to calculation and Validation
b. process of Condition: If the key (APPLY_CHANGES)
c. code
At the end of the process, I see null values inserted in my table. The report also displays null values.DECLARE l_table_md5 VARCHAR2(4000); l_collection_md5 VARCHAR2(4000); BEGIN FOR c1 IN (SELECT c001, c002, c003, c004, c005, c006, c007,seq_id FROM apex_collections WHERE collection_name = 'STAKEHOLDERS_COL' ) LOOP IF c1.c006 = 'N' THEN insert into eba_prjv_proj_stakeholders ( STAKEHOLDER_NAME, STAKEHOLDER_ROLE_ID, PRIMARY_CONTACT_YN, RECEIVE_NOTIFICATION_YN ) values (c1.c002, c1.c003, c1.c004, c1.c005 ); ELSIF c1.c006 = 'D' THEN DELETE FROM eba_prjv_proj_stakeholders WHERE id = c1.c001; ELSIF c1.c006 = 'U' THEN -- Check the record hasn't been updated since the query -- Get MD5 checksum from the Table SELECT wwv_flow_item.md5(STAKEHOLDER_NAME, STAKEHOLDER_ROLE_ID, PRIMARY_CONTACT_YN, RECEIVE_NOTIFICATION_YN) INTO l_table_md5 FROM eba_prjv_proj_stakeholders WHERE id = c1.c001; -- Compare the checksum values and if they are different, raise an error. IF l_table_md5 != c1.c007 THEN raise_application_error( -20001 , 'Current version of data in database has changed '|| 'since user initiated update process.'); return; END IF; UPDATE eba_prjv_proj_stakeholders set STAKEHOLDER_NAME = c1.c002, STAKEHOLDER_ROLE_ID = c1.c003, PRIMARY_CONTACT_YN = c1.c004, RECEIVE_NOTIFICATION_YN = c1.c005 where id = c1.c001; end if; end loop; apex_collection.delete_collection( p_collection_name => 'STAKEHOLDERS_COL' ); END;
Published by: jaouad khalifi on August 17, 2012 04:26
Published by: jaouad khalifi on August 17, 2012 04:42
Published by: jaouad khalifi on August 17, 2012 04:46
Published by: jaouad khalifi on August 18, 2012 02:03Hello
I changed and then brought back to the State that you had.
The problem here is that you have status and Seq_id returned with APEX_ITEM. HIDDEN, but you have not selected the Show check box for those columns attribute report tab.
Thus there is no f06 and f09 only named elements in your HTML DOM and therefore no APEX_APPLICATION. G_F06 and G_F09. If your processes
FOR correct here is what you do
1. mark the status and Seq_id as indicated in the report attribute tab columns
2. change the ACE status display hidden to report column Standard. Change display of the Seq_id also report Standard columnNote that when a column is not marked to show in the report he becomes any and you don't see the associated items in the DOM HTML.
See you soon,.
-
Data Modeler: how to create and use the collection type
Hello
essentially of departure I don't understand how (for example) create and use the data based on the type of data varray type.
Please notify.
Thank you
AndrewHi André,.
You can create new types of collection (varray/table) in two ways:
(1) in the browser - find 'Types of data' > 'Types of Collection' node menu dropdown - there just 'create new collection type' it
(2) in the types of data model diagram - you can create collection "some type structured" or collection of references to the it - use 'new Collection... '. "tool and click first on sight structured type and after the structured type that will contain the collection - new attribute is added to the latter and if there is none this type of collection already didn't set the new collection type are created and you can change it later.Philippe
-
Add line as a manual by using the collection: failed to add several lines
Hello
I have some problem by adding lines manual tabular form.
Whenever I click on the button 'Add Row', the previous entries are updated.
Help, please:
Here are the details in apex.oracle.com
https://Apex.Oracle.com/pls/Apex/f?p=39422:2
Schema: mikeT
user: bisitako / 20bisitako14.
Hello
Problem is that just the PL/SQL code of the dynamic action race will not fill APEX_APPLICATION. G_Fxx berries.
I copy your app ID 56444.
Here you can see example how to fill the tables and send the values for the application process by using dynamic action.
Kind regards
Jari
-
I want to create a simple table in which I need to store the email address and some ID. This will be stored in a loop. ID and email address can be repeaded in the loop so later on I want to choose DIFFERENT values in this one.
Thank you
DanishDanish wrote:
I want to create a simple table in which I need to store the email address and some ID. This will be stored in a loop. ID and address e-mail can be repeaded in the loop so later on I want to choose values DISTINCT from him.This last requirement is a very good reason to not store your values in an array. The tables are of basic data types and are not, by default, designed to make queries of type SQL against.
You'd better store your values in a global temporary Table, and then you can make a "distinct select ' on this table.
-
using fetch employeeid from the collection
Hi all
The code below may not fetch employee_id using the collection. can you please tell me where I was wrong.
DECLARE
Emp_table_type TYPE IS an ARRAY OF
Employees.employee_id%type;
my_emp_table emp_table_type;
BEGIN
SELECT employee_id IN my_emp_table FROM employees;
BECAUSE me IN 1.my_emp_table.count
LOOP
DBMS_OUTPUT. Put_line (my_emp_table (i) .employee_id);
END LOOP;
end;
WARNING: In BULK to COLLECT without a limit is a bad habit, correct it yourself.
DECLARE
TYPE emp_table_type IS TABLE OF THE employees.employee_id%type;
my_emp_table emp_table_type;
BEGIN
SELECT employee_id COLLECT LOOSE my_emp_table FROM employees;
BECAUSE me IN 1.my_emp_table.count
LOOP
DBMS_OUTPUT. Put_line (my_emp_table (i));
END LOOP;
end;
-
By comparing the game without using to COLLECT?
I want to know if there is an alternative to the following query without using the COLLECT function.
I have two lists that contain number game:
List01
SetName; NUM
A; 11
A; 12
A; 13
B; 21
B; 22
C; 34
C; 36
List02SetName; NUM
X; 11
X; 12
X; 13
Y; 21
Z; 34
Z; 22
I want to know how to find the list of the game in list02 who aren't in list01. I think the result is:
THERE
Z
Or:
Y; 21
Z; 34
Z; 22
I have this result with the following query. Is it possible to have the same result without using the COLLECT function?
CREATE or REPLACE type NUMBER_SETAS
TABLE OF NUMBER;
WITH AS List01
(SELECT 'A' AS SETNAME, LIKE DOUBLE NUM 11)
UNION
SELECT 'A' AS SETNAME, 12 IN THE DOUBLE NUM
UNION
SELECT 'A' AS SETNAME, DOUBLE NUM 13
UNION
SELECT 'B' AS SETNAME, 21 AS DOUBLE NUM
UNION
SELECT 'B' AS SETNAME, 22 IN THE DOUBLE ISSUE
UNION
SELECT 'C' AS SETNAME, 34 AS NUM FROM DUAL
UNION
SELECT 'C' AS SETNAME, 36 IN THE DOUBLE ISSUE
),
AS List02
(SELECT 'X' AS SETNAME, LIKE DOUBLE NUM 11)
UNION
SELECT 'X' AS SETNAME, 12 IN THE DOUBLE ISSUE
UNION
SELECT 'X' AS SETNAME, DOUBLE NUM 13
UNION
SELECT 'Y' AS SETNAME, 21 AS DOUBLE NUM
UNION
SELECT 'Z' AS SETNAME, 34 AS NUM FROM DUAL
UNION
SELECT 'Z' AS SETNAME, 22 IN THE DOUBLE ISSUE
),
SetsFromList01 AS
(SELECT SETNAME,
CAST (AT COST VIRES (NUM
(ORDER NUMBER) AS NUMBER_SET) AS setofNUM
OF LIST01
SETNAME GROUP
),
SetsFromList02 AS
(SELECT SETNAME,
CAST (AT COST VIRES (NUM
(ORDER NUMBER) AS NUMBER_SET) AS setofNUM
OF LIST02
SETNAME GROUP
)
SELECT SETNAME
OF SetsFromList02
WHERE setofNUM NOT IN
(SELECT setofNUM FROM SetsFromList01
);
Thank you
Yes, you are right, ROW_NUMBER is not necessary.
SY.
-
The use of collections to insert
Hello
To improve the performance of the insert statement, I was advised to use the collections.
I get no idea on how to use the concept of collection in my code.
Could you please give me an approach of skelton to do.
Here is the code example (the logic is that even in production code, instead of 1-100000 we cursor in prod) without the use of collections
Now, I have tried a few using colliection to improve the performance of inserting and stuck how to use collectionscreate table pop_tab ( col1 number ,col2 number ,col3 number ,col4 number ) create or replace package test_collect is procedure proc_lvl_ld ; procedure proc_pop_tab (v_var1 number ,v_var2 number ,v_var3 number ,v_var4 number) ; end test_collect; create or replace package body test_collect is procedure proc_lvl_ld is v_cnt number := 1 ; v_var1 NUMBER ; v_var2 NUMBER ; v_var3 NUMBER ; v_var4 NUMBER; begin for i in 1 .. 100000 loop v_var1 := v_cnt + 1; v_var2 := v_cnt + 2; v_var3 := v_cnt + 3; v_var4 := v_cnt + 4; v_cnt := v_cnt + 1; proc_pop_tab (v_var1 ,v_var2,v_var3,v_var4); end loop; commit; exception when others then DBMS_OUTPUT.PUT_LINE ( 'proc_lvl_load'||sqlcode||','||sqlerrm ); end proc_lvl_ld; procedure proc_pop_tab (v_var1 number ,v_var2 number ,v_var3 number ,v_var4 number) is begin insert into pop_tab (col1,col2,col3,col4) values (v_var1,v_var2,v_var3,v_var4) ; exception when others then DBMS_OUTPUT.PUT_LINE ( 'proc_pop_tab'||sqlcode||','||sqlerrm ); end proc_pop_tab; end test_collect;
Could you please help me in this and let me know if I'm not clearcreate or replace package body test_collect is procedure proc_lvl_ld is TYPE numtab1 IS TABLE OF NUMBER (4) INDEX BY BINARY_INTEGER; data1 numtab1; TYPE numtab2 IS TABLE OF NUMBER (4) INDEX BY BINARY_INTEGER; data2 numtab2; TYPE numtab3 IS TABLE OF NUMBER (4) INDEX BY BINARY_INTEGER; data3 numtab3; TYPE numtab4 IS TABLE OF NUMBER (4) INDEX BY BINARY_INTEGER; data4 numtab4; v_cnt number := 1 ; begin for i in 1 .. 100000 loop data1(data1.count +1) := v_cnt + 1; data2(data2.count +1) := v_cnt + 1; data3(data3.count +1) := v_cnt + 1; data4(data4.count +1) := v_cnt + 1; v_cnt := v_cnt + 1; --proc_pop_tab (v_var1 ,v_var2,v_var3,v_var4); end loop; forall j in 1 ..data1.count insert into pop_tab values ( --- How to use the above collection variables here commit; exception when others then DBMS_OUTPUT.PUT_LINE ( 'proc_lvl_load'||sqlcode||','||sqlerrm ); end proc_lvl_ld; end;
Published by: Smile on September 7, 2012 11:37Use:
forall j in 1 ..data1.count insert into pop_tab values (data1(j),data2(j),data3(j),data4(j));
Now:
SQL> create or replace package body test_collect 2 is 3 procedure proc_lvl_ld 4 is 5 TYPE numtab1 IS TABLE OF NUMBER (4) INDEX BY BINARY_INTEGER; 6 data1 numtab1; 7 TYPE numtab2 IS TABLE OF NUMBER (4) INDEX BY BINARY_INTEGER; 8 data2 numtab2; 9 TYPE numtab3 IS TABLE OF NUMBER (4) INDEX BY BINARY_INTEGER; 10 data3 numtab3; 11 TYPE numtab4 IS TABLE OF NUMBER (4) INDEX BY BINARY_INTEGER; 12 data4 numtab4; 13 v_cnt number := 1 ; 14 begin 15 for i in 1 .. 100000 loop 16 data1(data1.count +1) := v_cnt + 1; 17 data2(data2.count +1) := v_cnt + 1; 18 data3(data3.count +1) := v_cnt + 1; 19 data4(data4.count +1) := v_cnt + 1; 20 v_cnt := v_cnt + 1; 21 --proc_pop_tab (v_var1 ,v_var2,v_var3,v_var4); 22 end loop; 23 forall j in 1 ..data1.count 24 insert into pop_tab 25 values (data1(j),data2(j),data3(j),data4(j)); 26 commit; 27 exception when others then 28 DBMS_OUTPUT.PUT_LINE ( 'proc_lvl_load'||sqlcode||','||sqlerrm ); 29 30 end proc_lvl_ld; 31 end; 32 / Package body created. SQL> exec test_collect.proc_lvl_ld; proc_lvl_load-6502,ORA-06502: PL/SQL: numeric or value error: number precision too large PL/SQL procedure successfully completed. SQL>
Why? You said Association as number 4 tables while the values you are trying to assign their elements are in the range:
because me in 1... loop of 100000
If I change to:
because me in 1... 9998 loop
Then:
SQL> create or replace package body test_collect 2 is 3 procedure proc_lvl_ld 4 is 5 TYPE numtab1 IS TABLE OF NUMBER (4) INDEX BY BINARY_INTEGER; 6 data1 numtab1; 7 TYPE numtab2 IS TABLE OF NUMBER (4) INDEX BY BINARY_INTEGER; 8 data2 numtab2; 9 TYPE numtab3 IS TABLE OF NUMBER (4) INDEX BY BINARY_INTEGER; 10 data3 numtab3; 11 TYPE numtab4 IS TABLE OF NUMBER (4) INDEX BY BINARY_INTEGER; 12 data4 numtab4; 13 v_cnt number := 1 ; 14 begin 15 for i in 1 .. 9998 loop 16 data1(data1.count +1) := v_cnt + 1; 17 data2(data2.count +1) := v_cnt + 1; 18 data3(data3.count +1) := v_cnt + 1; 19 data4(data4.count +1) := v_cnt + 1; 20 v_cnt := v_cnt + 1; 21 --proc_pop_tab (v_var1 ,v_var2,v_var3,v_var4); 22 end loop; 23 forall j in 1 ..data1.count 24 insert into pop_tab 25 values (data1(j),data2(j),data3(j),data4(j)); 26 commit; 27 exception when others then 28 DBMS_OUTPUT.PUT_LINE ( 'proc_lvl_load'||sqlcode||','||sqlerrm ); 29 30 end proc_lvl_ld; 31 end; 32 / Package body created. SQL> exec test_collect.proc_lvl_ld; PL/SQL procedure successfully completed. SQL> select count(*) from pop_tab 2 / COUNT(*) ---------- 9998 SQL>
SY.
-
Using the Java Collections API in language PBL
Hello
You can use the collections api in a PBL language. Can someone provide an example of the same thing?
Thank you.Hello
Here is an example that you can make use of the api of Collections (Java).
arrayList as ArrayList = ArrayList()
Add arrayList using arg1 = "A".
Add arrayList using arg1 = 'B '.
Add arrayList using arg1 = 'C '.
Add arrayList using arg1 = "D".
Add arrayList using arg1 = 'E '.
Collections.swap (arg1: arrayList, arg2: 0, arg3: 4)
Collections.sort(Arg1: ArrayList)I hope this help you.
Sidonie
-
Need help to understand the collection
Hi all
I'm trying to understand the concept of collection, but when I look in the documentation that exists in google.ca, then, it seems very confusing. If someone suggest me or send me some simple examples and good collection and I really appreciate it. Thanks in advance.
Concerning
Line
Thanks for the explanation, could you please explain what does really to take care of the index as a whole and clause varchar2 and if yes then what condition we use varchar2 index and in which condition we use index as a whole, be we just use index by integer in our daily practice. Really appreciate your response. Thank you
Generally if you use collections, especially PL/SQL-only collections, your architecture is probably wrong. Collections are rarely necessary, but are often USED in the mistaken belief that they will help performance.
The use of the collections usually DEGRADES performance, sometimes severely, and they are often used in a way that is not scalable. You should avoid using collections if possible.
So don't use the collections AT ALL in your 'common practice '.
For the rare cases where there is to use an array associative index type to use depends on the data type of the element that you will use for the index. If you plan to use a string, then you use INDEX OF VARCHAR2. If you plan to use an integer, then you use INDEX BY PLS_INTEGER.
What type of index to use has NOTHING to do with performance.
One of the WORST mistakes developers make is to use an associative array as target of a BULK COLLECT INTO instead of using a TABLE IMBRIQUEE. Collection in bulk is more often used in a FORALL statement so that the elements are accessible only in the order. Useds "indexed" access with associative arrays isn't even necessary or used.
-
Using the Type of object in fusion
Hi all
You have a small problem where I would like some suggestions.
I had a declared TYPE.
CREATE OR REPLACE TYPE 'MY_TYPE_OT' IS (OF THE OBJECT
Field1 VARCHAR2,
Field2 VARCHAR2,
field3 VARCHAR2);
I now have an array declared to type this
TYPE MY_TYPE_TT IS TABLE OF INDEX MY_TYPE_OT BY VARCHAR2 (100);
I have the collection of type MY_TYPE_TT
MY_TYPE_TT MY_VARIABLE;
I am populating this variable lets say 10 records.
Then I try to save it to a database table, my_table for this I need to merge since it could be an update or insert. so, my query goes like this
MERGE INTO my_table T2 using T1 ON (T1.field1 = T2.field1 AND T1.field2 = T2.field2) TABLE ($my_var)
Here, I get an error that my_variable is not a table. I tried different things like doing a casting, which gives me invalid data type etc.
Any suggestions on how to pick up on this?
Thanks in advance
PaddyCollection with "index of" cannot be used in the context of sql. You can or use the collections without "index of" or treat it manually. See the example:
drop table MY_TABLE purge / CREATE OR REPLACE TYPE MY_TYPE_OT IS OBJECT ( field1 VARCHAR2(100), field2 VARCHAR2(100), field3 VARCHAR2(100)) / create table MY_TABLE of MY_TYPE_OT / declare TYPE MY_TYPE_TT IS TABLE OF MY_TYPE_OT INDEX BY VARCHAR2(100); MY_VAR MY_TYPE_TT; begin --just testing values for collection: for i in 1..3 loop MY_VAR(i):=MY_TYPE_OT(null,null,null); MY_VAR(i).field1:='field1-'||i; MY_VAR(i).field2:='field2-'||i; MY_VAR(i).field3:='field3-'||i; end loop; -- manually merging by one row: for c in MY_VAR.first..MY_VAR.last loop execute immediate ' merge into MY_TABLE T2 USING (select :1 field1, :2 field2, :3 field3 from dual) T1 ON (T1.field1 = T2.field1 AND T1.field2 = T2.field2) when matched then update set t2.field3=t1.field3 when not matched then insert values(t1.field1,t1.field2,t1.field3) ' using MY_VAR(c).field1,MY_VAR(c).field2,MY_VAR(c).field3 ; end loop; end; /
Kind regards
Malakshinov Sayan -
Hi gurus
I'm stuck on a problem related to the collection.
I have the following structure.
Sample data
DROP TABLE dept2;
DROP TABLE dept2_dtl;
CREATE TABLE dept2
(DEPTNO NUMBER (2),)
DNAME VARCHAR2 (14).
LOC VARCHAR2 (13),
DEPT_ID NUMBER (5))
;
-------
CREATE TABLE dept2_dtl
(DEPTNO NUMBER (2),)
DNAME VARCHAR2 (14).
LOC VARCHAR2 (13),
DEPT_ID NUMBER (5))
;CREATE SEQUENCE dept_seq
START WITH 1000
INCREMENT BY 1;-----------
Code so far
DECLARE
TYPE t_dept IS TABLE OF dept2% rowtype;
v_dept t_dept;
cursor c1 is select deptno, dname, loc, null of the Department;
BEGIN
OPEN c1;
loop fetch c1 COLLECT LOOSE v_dept limit 1000;
exit WHEN v_dept.count = 0;
ForAll indx IN 1.v_dept.count
INSERT INTO dept2
(DEPTNO,
DNAME,
LOC ,
DEPT_ID)
VALUES
(
v_dept (indx). DEPTNO,
v_dept (indx). DNAME,
v_dept (indx). LOC,
dept_seq.nextval
);
-This section contains an exception
BEGINForAll indx IN 1.v_dept.count
INSERT INTO dept2_dtl
(DEPTNO,
DNAME,
LOC
-DEPT_ID
)
SELECT v_dept (indx). DEPTNO, v_dept (indx). DNAME, v_dept (indx). LOC
OF the double
where v_dept (indx). DEPTNO = 10;
End;
-Now, I want to addend loop;
END;The above code work fine, but I want to add dept2. DEPT_ID in table of details that are dept2_dtl but unable to reference it. I need to change a code in my second insert something like below:
SELECT v_dept (indx). DEPTNO, v_dept (indx). DNAME, v_dept (indx). LOC,
v_dept (indx). DEPT_ID
OF the double
where v_dept (indx). DEPTNO = 10;
but the problem is that I don't have DEPT_ID in my collection at this time, please advice. Thank you
I'm stuck on a problem related to the collection.
I see NOTHING in what you posted indicating that the collections or PL/SQL is even necessary.
The first part of what you are doing is just selecting data in DEPT and inserting into DEPT2 with a new value in the sequence.
Then you say you want to insert the same data into another table that you just inserted in the first table.
Why don't you just use SQL to query DEPT and do insertion in DEPT2?
Even if you were to use the collections and that the solution is pretty simple, don't you think?
This is the cursor you have defined:
cursor c1 is select deptno, dname, loc, null of the Department;
And that's what you say, what is the problem:
the problem is that I don't have DEPT_ID in my collection right now
So FIX THIS PROBLEM! is not the solution the more simple, just to add DEPT_ID to this collection?
Define your collection on the projection of CURSOR and add DEPT_SEQ. NEXTVAL in the cursor query.
Now you have DEPT_ID in the cursor AND in the collection, you can use the collection to INSERT in the two tables.
DECLARE
cursor c1 is select deptno, dname, loc dept_seq.nextval deptid of the Department;
TYPE t_dept IS TABLE c1% rowtype;
v_dept t_dept;
BEGIN
OPEN c1;
loop fetch c1 COLLECT LOOSE v_dept limit 1000;
exit WHEN v_dept.count = 0;
ForAll indx IN 1.v_dept.count
INSERT INTO dept2
(DEPTNO,
DNAME,
LOC ,
DEPT_ID)
VALUES
(
v_dept (indx). DEPTNO,
v_dept (indx). DNAME,
v_dept (indx). LOC,
v_dept (indx). DEPTID
);
ForAll indx IN 1.v_dept.count
INSERT INTO dept2_dtl
(DEPTNO,
DNAME,
LOC ,
DEPT_ID
)
SELECT v_dept (indx). DEPTNO, v_dept (indx). DNAME, v_dept (indx). LOC, v_dept (indx). DEPTID
OF the double
where v_dept (indx). DEPTNO = 10;
end loop;
END;
The big question is why you are using this TERRIBLE to begin implementation?
Maybe you are looking for
-
OfficeJet HO 5740: analysis via "Scan" printer ikon does not find the computer
When I try to scan to a file using the ikon of screen touch printers and after selecting the computer I want to test results from the screen "Select computer", "access to the computer" in the following error message: "The selected computer is not ava
-
OfficeJet 6700: scan to email
Using Win 7 64 bit desktop with OfficeJet 6700. How can I scan directly to Thunderbird without having to analyze everything first and then attach it to an email? I'd rather not use (or want to) Windows Live Mail.
-
BlackBerry Smartphones No. rings or vibrates on 8530
Since yesterday I can listen to no longer have any kind of sounds, whether alerts, ringtones, Pandora, etc.. And my phone vibrates any more, either. My sound setting is Normal, and I have all the settings 'ON '. I have not updated the operating syst
-
Presets freeze when it is applied to Images (LR 4.0)
I can't use the presets in LR 4.0. Some presets are applied to the images that I am editing. I can not cancel them. I can't use other predefined parameters. LR is freezing. I need to reset the image & start all over again. Cannot use my LR soft
-
Packer CC >; Configuration >; start and after 20 secons it stop
I have created a device license, downloaded CCpackager and after installation of Pentecost began, it stops after 20 seconds without any message