Cursor cursor to COLLECT in BULK and test
Hello
I am struggling to test a cursor, my requirement is as follows
To truncate a table then reinsert this record with all the content of the cursor if cursor returns record.
PROCEDURE populate_offline_table AS
CURSOR ext_table_cursor
IS
SELECT * from ext_table;
ARRAY TYPE IS TABLE of ext_table_offline % ROWTYPE;
ext_table_array TABLE.
ext_table_empty EXCEPTION;
BEGIN
OPEN ext_table_cursor.
IF ext_table_cursor % ROWCOUNT > 0 THEN
EXECUTE IMMEDIATE 'TRUNCATE TABLE ext_table_offline';
LOOP
Get the ext_table_cursor COLLECT LOOSE ext_table_array LIMIT 1000;
EXIT WHEN ext_table_cursor % NOTFOUND;
FORALL rec IN 1.ext_table_array. COUNTY
INSERT INTO ext_table_offline VALUES (rec) ext_table_array;
END LOOP;
ON THE OTHER
RAISE ext_table_empty;
END IF
CLOSE Ext_table_cursor;
EXCEPTION
WHEN ext_table_empty
THEN dbms_output.put_line ('outer Table is empty');
END populate_offline_table;
Can someone help me please
2726801 wrote:
I have some questions:
1. What is the disadvantages of using slider with BULK COLLECT and LIMIT?
This isn't a slow line according to the treatment, and after treatment. The term "bulk collect" is not a magic formula that transforms the transformation of the slow line in function in evolutionary and optimal treatment.
If you move/copy data from a database table to the other, and you use the PL/SQL engine and the memory of PL/SQL to transfer data from a target SQL to another, it is neither optimal or scalable.
Remove the PL/SQL engine called detour and DIRECTLY copy/move the target of SQL source data to the target SQL, optimal and scalable.
Tags: Database
Similar Questions
-
Need help with debugging collection in bulk and loop forall
Hi people,
I was wondering if someone can look at my PL/SQL code and tell me where I'm wrong.
Environment
=========
10g (Rel 2)
Algorithm of
=======
A slider lets collect records
The data block
Bulk insert the data into a table
Implementation
==========
Set serveroutput on;
declare
cursor source_cur is
Select * from
from t1;
-Define the variables and collection types to be used by the BULK COLLECT clause
source_data_type type is the table of the source_cur % rowtype;
source_data_table source_data_type;
Start
Open source_cur;
loop
extraction source_cur
bulk collect into source_data_table;
When the output source_data_table.count = 0;
-Now, we print the data collected
-for i in source_data_table.first... source_data_table. Last
-loop
-dbms_output.put_line (' company name: ' | source_data_table (i).) Company);
-dbms_output.put_line ('Count: ' | source_data_table.) (COUNT);
-end loop;
end loop;
close source_cur;
Note: The statements above Print print the correct data and County
-Now, bulk insert us the data into the target table
dbms_output.put_line ('Count: ' | source_data_table.) (COUNT);
Note: The print statement above indicates a number 0 =. Since there is no available record, FORALL loop below will not insert anything in the table
ForAll idx in source_data_table. FIRST... source_data_table. LAST
Insert into T2
source_data_table (idx) values;
end;
/
Thanks in advance
rogers42You'll want to do something like this
open source_cur; loop fetch source_cur bulk collect into source_data_table; exit when source_data_table.count = 0; forall idx in source_data_table.FIRST .. source_data_table.LAST insert into T2 values source_data_table(idx); end loop; close source_cur;
or even better:
insert into target select col, col, col from source
no need to COLLECT in BULK and FORALL
;) -
Hello Experts,
Please review the below excerpt as it errors with a PLS-00103: Encoountered synbol «END».
IF v_geospatial_coordinate_type = "None".
THEN
P_cursor OPEN;
LOOP
SEARCH p_cursor
LOOSE COLLECTION v_search_results_basic LIMIT 100;
BECAUSE me in 1.v_search_results_basic.count
WHEN the OUTPUT v_search_results_basic.count < 100;
END LOOP;
CLOSE P_cursor;
Thanks for the help and of course your professionalism.you missed "LOOP".
IF v_geospatial_coordinate_type = 'None' THEN OPEN p_cursor; LOOP FETCH p_cursor BULK COLLECT INTO v_search_results_basic LIMIT 100; FOR I in 1..v_search_results_basic.count LOOP --<--- EXIT WHEN v_search_results_basic.count < 100; END LOOP; CLOSE p_cursor;
-
I can't bid on firefox or explorer. I place the cursor in the quote box, and it will not only record the numbers. Can anyone help please thanks
Problem solved. My husband came and noticed that the number lock has been deactivated. I can't thank you enough for your help. Hope my solution helps someone else with the same problem.
-
original title: halo 2
Hello... Just installed Halo 2 on my Windows 7, 64-bit desktop. I have all the latest drivers. All other games work fine.
When I use my mouse on the line, the cursor movement is very slow and jerky. Unplayable.
I was looking for a patch for the game or suggestion on how to correct adjust them. I tried the option in game of adjustment of moving the mouse, but it did not help.
Suggestions please...
----------------
-
How can I change the cursor in an individual account (and not the owner) a computer to my client?
Hi MichaelConner1,
You can keep the individual mouse for each user account on the computer.
Log on to each user account and then change the mouse pointer scheme using the link below and check if it helps.
http://www.Microsoft.com/enable/training/WindowsXP/pointerscheme.aspx
-
my pc is stuck. I doubt that the fan provided within the system does not work. The problem is if I work for an hour or more first the cursor starts to behave correctly and then the program gets stucked and the pc needs a forced closure. And where the driver is placed at the bottom is very hot.
Original title: Stucks
Hello
In addition to becoming the fan if it does not, if it is a desktop computer, clean the inside with a can of compressed air.
If it's a laptop, check the vents for hair, dust, etc. and do not use a laptop when it is based on material surfaces: bedspreads, blankets, etc.
If the problem persists, if this is a laptop (as you say only pc, no office or laptop), take it to a local computer and reliable repair shop and get them to open and clean the dust inside...
Here is an interesting discussion about the reasons of your problem (IF your laptop):
http://PC-trickandsolution.blogspot.com.au/2011/07/fix-laptop-overheating-shutdown-problem.html
NB: > however 9 out of 10 cases of overheating are caused by obstruction of the air flow.
See you soon.
-
Hi all
I want to pick only 10 records at a time. It is extracted all 14 records why? I need only 10 records, if I had no please let me help.
DECLARE
CURSOR emp_cur IS
SELECT empno,
ename ,
job
FROM emp;
TYPE emp_no_type IS TABLE OF emp. EmpNo % TYPE ;
TYPE emp_name_type IS TABLE OF emp. Ename % TYPE ;
TYPE job_name_type IS TABLE OF emp. job % TYPE ;
emp_no_tab EMP_NO_TYPE
emp_name_tab EMP_NAME_TYPE
job_name_tab JOB_NAME_TYPE
v_limit PLS_INTEGER := 10;
START
OPEN emp_cur;
LOOP
-Get 10 rows at a time
FETCH emp_cur bulk collect INTO emp_no_tab, emp_name_tab, job_name_tab
limit
v_limit ;
EXIT WHEN emp_no_tab. County = 0;
FOR i IN emp_no_tab. first .. emp_no_tab . last LOOP
dbms_output . Put_line ('Emp Number: ' || Emp_no_tab (i) );
dbms_output . Put_line ('Emp Name: ' || Emp_name_tab (i) );
dbms_output . Put_line ('Emp Job: ' || Job_name_tab (i) );
END LOOP;
END LOOP;
CLOSE emp_cur;
END ;
Thank U
994122 wrote:
Thank you..
Ensure?
What happens when the EMP table contains 24 ranks?
Do not rely on the attributes of the cursor with bulk collect (PL/SQL practices: COLLECT in BULK)
Just drag the outer loop, (because what you want to do, it's to combat by setting the limit only) and the exit condition:
OPEN emp_cur;
-LOOP
-Go get 10 lines at a time
Collect the FETCH emp_cur in bulk IN emp_no_tab, emp_name_tab, job_name_tab
limit
v_limit;
-EXIT WHEN emp_no_tab.count = 0;
I'm IN emp_no_tab.first... emp_no_tab. Last LOOP
dbms_output. Put_line ('Emp number: ' |) Emp_no_tab (i));
dbms_output. Put_line (' Name of Emp: ' |) Emp_name_tab (i));
dbms_output. Put_line ('Emp Job: ' |) Job_name_tab (i));
END LOOP;
-END LOOP;
CLOSE Emp_cur;
-
Dear all,
I try to use bulk collect for one of my requirements. I defined a procedure and using bulk collect inside.
The procedure is the compilation of the warnings.
The error message is "PLS-00487: invalid reference to the variable 'I'".
Here is the procedure I use.
----------------------------------
CREATE OR REPLACE procedure APPS.XXX_MRP_PAY4 (RETCODE OUT VARCHAR2,
ERRBUF OUT VARCHAR2
-P_SERVICE_CALC_DATE IN DATE,
-P_VARIABLE IN NUMBERS
)
is
-L_VARIABLE NUMBER: = P_VARIABLE;
cursor c1 is
SELECT
EMPLOYEE_NUMBER
FULL_NAME
OF XX_MRP_SALARY_BREAKUP SB,
sit_date sd
where = SB.employee_number sd.emp_num (+);
TYPE MRP_RESULTS IS TABLE OF c1% ROWTYPE INDEX BY PLS_INTEGER;
MRP MRP_RESULTS;
CLOB L_TEXT;
Start
FND_FILE.put_line (FND_FILE.output, 'EMPLOYEE_NUMBER' |) CHR (9) | "FULL_NAME");
-I'm looping C1
OPEN c1;
LOOP
FETCH c1
BULK COLLECT INTO MRP LIMIT 1500;
WHEN THE MRP OUTPUT. COUNT = 0;
because me in 1... MRP. COUNTY
loop
L_TEXT: = I.EMPLOYEE_NUMBER | Chr (9) | I.FULL_NAME;
FND_FILE.put_line (FND_FILE.output, L_TEXT);
end loop;
END LOOP;
CLOSE c1;
end XXX_MRP_PAY4;
-------------------------------
You kindly could guide me on this plssSeems you placed a CURSOR for... LOOP in a COLLECTION in BULK.
The variable 'i' used to be a record, but now it's a number.
Suspect you want...
l_text := mrp (i).employee_number || CHR (9) || mrp (i).full_name;
-
Remove bulk and bulk update - to improve performance.
How to remove bulk and in bulk to update?
DECLARE
CURSOR l_cur_PR_vins IS
SELECT a23.physical_vin_string
OF gfsta23_veh a23
WHERE a23.vpo_purge_ind = 'PR ';
BEGIN
FOR l_cur_vins IN l_cur_PR_vins LOOP
BEGIN
l_str_physical_vin_string: = l_cur_vins.physical_vin_string;
-REMOVE all records OF GFSTV53_VEH_CLSFCN_RPTG_FTR
DELETE FROM GFSTV53_VEH_CLSFCN_RPTG_FTR v53
WHERE THERE ARE
(SELECT 1
OF GFSTV49_VEH_CLSFCN_INTRFC v49
WHERE v49.physical_vin_string = l_str_physical_vin_string
AND v53.veh_clsfcn_txn_sakey = v49.veh_clsfcn_txn_sakey);
-REMOVE all records OF GFSTV44_VEH_REPORTING_FTR
DELETE FROM GFSTV44_VEH_REPORTING_FTR v44
WHERE THERE ARE
(SELECT 1
OF GFSTV41_VEH_CONFIG v.41
WHERE v41.physical_vin_string = l_str_physical_vin_string
AND v44.veh_config_sakey = v41.veh_config_sakey);
-REMOVE all records OF GFSTV41_VEH_CONFIG
DELETE FROM GFSTV41_VEH_CONFIG v.41
WHERE v41.physical_vin_string = l_str_physical_vin_string;
-DELETE all the records OF gfstv49_veh_clsfcn_intrfc
DELETE FROM GFSTV49_VEH_CLSFCN_INTRFC v49
WHERE v49.physical_vin_string = l_str_physical_vin_string;
-Update GFSTA23_VEH set VPO_PURGE_IND = 'PC '.
UPDATE gfsta23_veh
SET vpo_purge_ind = l_con_purge_complete_status,
vpo_purge_dts = GFSTU_DATETIME_UTILITIES_PA.gfstu_to_gmt_fn,
update_userid = USER,
update_dts = GFSTU_DATETIME_UTILITIES_PA.gfstu_to_gmt_fn
WHERE physical_vin_string = l_str_physical_vin_string;
END;
END LOOP;
END;
Thank you
VinodhWhy use a cursor loop here at all. A set of update/remove unique statemnets will still be faster than the constructions of PL/SQL, you can come.
These are, I think, sql statements are equivalent to your version of loopig.
BEGIN --DELETE all records FROM GFSTV53_VEH_CLSFCN_RPTG_FTR DELETE FROM GFSTV53_VEH_CLSFCN_RPTG_FTR v53 WHERE v53.veh_clsfcn_txn_sakey IN (SELECT v49.veh_clsfcn_txn_sakey FROM GFSTV49_VEH_CLSFCN_INTRFC v49 JOIN gfsta23_veh a23 ON v49.physical_vin_string = a23.physical_vin_string and a23.vpo_purge_ind = 'PR'); --DELETE all records FROM GFSTV44_VEH_REPORTING_FTR DELETE FROM GFSTV44_VEH_REPORTING_FTR v44 WHERE v44.veh_config_sakey = (SELECT v41.veh_config_sakey FROM GFSTV41_VEH_CONFIG v41 JOIN gfsta23_veh a23 ON v41.physical_vin_string = a23.physical_vin_string and a23.vpo_purge_ind = 'PR'); --DELETE all records FROM GFSTV41_VEH_CONFIG DELETE FROM GFSTV41_VEH_CONFIG v41 WHERE v41.physical_vin_string IN (SELECT a23.physical_vin_string FROM GFSTV41_VEH_CONFIG v41 WHERE a23.vpo_purge_ind = 'PR'); --DELETE all records FROM gfstv49_veh_clsfcn_intrfc DELETE FROM GFSTV49_VEH_CLSFCN_INTRFC v49 WHERE v49.physical_vin_string IN (SELECT a23.physical_vin_string FROM GFSTV41_VEH_CONFIG v41 WHERE a23.vpo_purge_ind = 'PR'); --Update GFSTA23_VEH set VPO_PURGE_IND = 'PC' UPDATE gfsta23_veh SET vpo_purge_ind = l_con_purge_complete_status , vpo_purge_dts = GFSTU_DATETIME_UTILITIES_PA.gfstu_to_gmt_fn, update_userid = USER, update_dts = GFSTU_DATETIME_UTILITIES_PA.gfstu_to_gmt_fn WHERE physical_vin_string IN (SELECT a23.physical_vin_string FROM GFSTV41_VEH_CONFIG v41 WHERE a23.vpo_purge_ind = 'PR'); END;
John
-
SP2-0552 error in Collections in bulk
Im trying to run this piece of code, but get an error such as displayed below;
-COLLECTIONS IN BULK
DECLARE
CURSOR v_bulk IS
SELECT employee_id
Employees;
TYPE c_array IS TABLE OF v_bulk % ROWTYPE
INDEX BY PLS_INTEGER;
v_array c_array;
BEGIN
OPEN v_bulk.
LOOP
Get the v_bulk COLLECT LOOSE v_array LIMIT 100;
EXIT WHEN v_bulk % NOTFOUND;
DBMS_OUTPUT. Put_line (v_array);
END OF LOOP:
CLOSE V_bulk;
END;
/
Error: Variable binding of the SP2-0552 'CLOSE' not stated
Please help me on this.
Thanks in advance.: after the end of the loop.
should be;
alvinder
-
Select the distinct value of a column in the collection in bulk.
Hi all
Collecting the data of a query to a variable of type table. I need to select a separate of a perticular column value in the collection.
Collection has followiing values inside.
I need to select distinct column values (for example: Col (c) .sourcecode) collection and the need to insert in the table if the value in this column does not exist in the table.Col(c).articleid, Col(c).userkey, Col(c).origin, Col(c).addnlorigindata, Col(c).avdest, Col(c).dispfmt, Col(c).sourcecode, Col(c).success_ind, Col(c).error_code, Col(c).entry_createddate, Col(c).createdby, Col(c).filenumber, Col(c).linenumber, Col(c).acctnum, Col(c).assetkey, Col(c).autocompletedterm, Col(c).accessionnumber, Col(c).requestdatetime, Col(c).requestorip, Col(c).articleordinal, Col(c).userinitiatedind, Col(c).captchastatus
Say, Col (c) .sourcecode has the value XYZ, ABC. If the "XYZ" value does not exist in the table, so I need to insert in the table and if "ABC" exists in the tables then don't insert it. (something like fusion) after seecting to the distinct values in a column in the collection.
Thanks n regards
Nana Akkivalli.The collection must be inserted before you can use this topic.
In the Begin block, you have to collect a loose and insert inside: something like
SELECT * BULK COLLECT INTO l_array FROM ALL_USER ...CONDITIONS...
-
Collect in bulk does not print the results in the table
Then the PL/SQL block below do not load and print whatever it is:
-Database 11 g:
declare
Type (vr_Rec) is rendered
DESCRIPTION VARCHAR2 (100)
QTDE NUMBER (2));
Type vt_Rec index vr_Rec table of Pls_Integer;
va_rec vt_Rec;
vc_Cursor SYS_REFCURSOR;
Start
Vc_Cursor open for 'SELECT "x" DESCRIPTION, 1 QTDE FROM DUAL UNION ALL' |
"SELECT the"y"DESCRIPTION, 2 QTDE FROM DUAL;
Loop
Get the vc_Cursor collect in bulk va_rec limit 20000;
When the output va_rec. Count = 0;
End loop;
Close Vc_Cursor;
If va_rec > 0 Then Count.
For / * everything * / i in va_rec. first... va_rec. last loop
dbms_output.put_line (va_rec (i). DESCRIPTION | ' - ' || va_rec (i). QTDE);
End loop;
End If;
end;lucitah wrote:
Then the PL/SQL block below do not load and print whatever it is:Yes, this isn't. Look at the code. Each extraction replaces data read by the previous fetch. And since he finished when va_rec. Count = 0, we are left with empty va_rec. You need something like:
declare Type vr_Rec Is Record ( DESCRICAO VARCHAR2(100) , QTDE NUMBER(2) ); Type vt_Rec Is table of vr_Rec Index By Pls_Integer; va_rec vt_Rec; vc_Cursor SYS_REFCURSOR; begin Open vc_Cursor For 'SELECT ''x'' DESCRICAO, 1 QTDE FROM DUAL UNION ALL '|| 'SELECT ''y'' DESCRICAO, 2 QTDE FROM DUAL'; Loop Fetch vc_Cursor Bulk Collect Into va_rec Limit 20000; Exit When va_rec.Count = 0; For i In va_rec.First..va_rec.Last Loop dbms_output.put_line( va_rec(i).DESCRICAO || ' - ' || va_rec(i).QTDE ); End Loop; End Loop; Close vc_Cursor;
SY.
-
I have an iphone 6 it is damaged by water but I set myself and the person put it on charge and tested it with a multimeter and it worked perfectly but when I went to get a screen tested on it because she does not have the person had not on is it did not work, even if the person has used only flow to correct and get a few corosions out with the replacement of some components of the person responsible for 10 minutes after having plugged in and the battery it wamer so it as I said her test with a multi meter test and he registered 12v and I wondered if something was wrong with it and if I could fix it easily?
Check the liquid Indcator of Contact.
Instructions here > liquid for iPhone or iPod is not covered by the warranty - Apple support
Just so you know, the service of the liquid damage to an iPhone or iPod is not covered by the limited warranty of one Apple or an AppleCare Protection Plan (APP).
-
I had designed a Web application and tested on Firefox 18, 19, 20 and now when I check it on 21 version it is not rendered correctly. Now tell me what I need to do.
https://developer.Mozilla.org/docs/Mozilla/Firefox/releases/21
Maybe you are looking for
-
Hi, I need help. I have an ipad 16 GB 1 air and for some reason any tells me I don't have enough storage, among all applications installed, I have only 1 GB occupied. so, I do not understand. < image edited by host to remove personal information >
-
Shift T does not work properly in Word 2011
I type a document in word for mac 2011, and it changes the font style when I hold SHIFT and press the button "t". I can't understand how to do to stop this, as now have to use caps lock whenever I need to type capital T. How can I stop this from ha
-
Missing driver base system device
Hi all The Lenovo Solution Center gives me an alert on a driver for the basic system problem Device.The is that I do not know how to solve this problem. I have reisntalled the Lenovo system update, the driver for the card reader and the drivers for t
-
program files empty after diversion
My computer has been hijacked, all files were hidden. I think I fixed by passing through all the hidden files and unchecked, but now all my programes say they are empty. How can I get them back when I click on programes. I tried the system restore, b
-
I bought Windows 7 Professional, because my children have games that need XP to run. I have dl'ed and installed XP Mode and Virtual PC, install Zoo Tycoon 2 for my son and I don't get a video memory error message. If I get this error message when you