Please help me on "Bulk Collect"
Hi All,
I've a query like :
select deptno,
min(sal)
from emp;
The above query is taking some 1.2 min to return the expected result of 91k rows and taking cost of 3666.
But when i re written the query like;
select deptno,
min(sal)
from emp where deptno = :dno;
It is giving the correct result & taking very less time,but i need to get the result for all dept's without passing the deptno dynamically.
As per my knowledge i planing to create one function using "Bulk-Collect" and return the all deptno.That result i 've to use in where condition.
But when i trying to create a function i'm not able to do it.. SO can anyone help how to solve the above problem..
How to pass the entire column values in where condition using function..
Do i need to create a function or is there any other way of doing it..
Please help me...
Thanks,
gra
Hi,
I don't follow you when you say that want to get all departments and them pass them back to your query, that makes no sense to me.
If you want max salary for all departments, just:
select deptno, min(sal) min_sal
from emp
group by deptno;No function, no bulk collect no nothing, but plain SQL.
Regards
Peter
Similar Messages
-
Hi,
below procedure is throwing error like "invalid sql". i doubt problem is with insert statement inside the body of the procedure, please help me how to load table with individual columns in bulk collect
CREATE OR REPLACE PROCEDURE subscriber_load
IS
TYPE r_subscriber_data IS RECORD
( acct_no LPDADMIN.SUBSCRIBER.acct_no%TYPE,
acct_status_cd LPDADMIN.SUBSCRIBER.acct_status_cd%TYPE,
connect_date LPDADMIN.SUBSCRIBER.connect_date%TYPE,
disconnect_date LPDADMIN.SUBSCRIBER.disconnect_date%TYPE,
bill_salutation_cd LPDADMIN.SUBSCRIBER.bill_salutation_cd%TYPE,
bill_first_name LPDADMIN.SUBSCRIBER.bill_first_name%TYPE,
bill_last_name LPDADMIN.SUBSCRIBER.bill_last_name%TYPE,
bill_addr_1 LPDADMIN.SUBSCRIBER.bill_addr_1%TYPE,
bill_addr_2 LPDADMIN.SUBSCRIBER.bill_addr_2%TYPE,
bill_city LPDADMIN.SUBSCRIBER.bill_city%TYPE,
bill_postal_code LPDADMIN.SUBSCRIBER.bill_postal_code%TYPE,
bill_province_cd LPDADMIN.SUBSCRIBER.bill_province_cd%TYPE,
bill_cycle_day LPDADMIN.SUBSCRIBER.bill_cycle_day%TYPE,
home_phone LPDADMIN.SUBSCRIBER.home_phone%TYPE,
business_phone LPDADMIN.SUBSCRIBER.business_phone%TYPE,
first_name LPDADMIN.SUBSCRIBER.first_name%TYPE,
last_name LPDADMIN.SUBSCRIBER.last_name%TYPE,
home_phone LPDADMIN.SUBSCRIBER.home_phone%TYPE,
delql_status_cd LPDADMIN.SUBSCRIBER.delql_status_cd%TYPE,
service_address_1 LPDADMIN.SUBSCRIBER.service_address_1%TYPE,
service_address_2 LPDADMIN.SUBSCRIBER.service_address_2%TYPE,
service_city LPDADMIN.SUBSCRIBER.service_city%TYPE,
service_province_cd LPDADMIN.SUBSCRIBER.service_province_cd%TYPE
TYPE t_subscriber_data IS TABLE OF r_subscriber_data INDEX BY BINARY_INTEGER;
table_subscriber_data t_subscriber_data;
CURSOR c_subscriber_data IS
SELECT s.acct_no
,lb.lob_status_cd
,s.connect_date
,s.disconnect_date
,s.bill_to_salutation_cd
,substr(s.bill_to_name,instr(bill_to_name,',',1)+1) bill_first_name
,substr(s.bill_to_name,1,instr(bill_to_name,',',1)-1) bill_last_name
,s.bill_to_addr_1
,s.bill_to_addr_2
,s.bill_to_city
,s.bill_to_postal_code
,s.bill_to_province_cd
,s.bill_create_day_of_month
,s.home_phone
,s.business_phone
,substr(s.name,instr(bill_to_name,',',1)+1) first_name
,substr(s.name,1,instr(bill_to_name,',',1)-1) last_name
,s.home_phone
,s.delq_status_cd
,h.addr_1
,h.addr_2
,h.city
,h.province_cd
FROM ccsadmin.subscriber s
inner join CCSADMIN.HOUSE h
on s.HOUSE_KEY = h.HOUSE_NO
left outer join CCSADMIN.LINE_OF_BUSINESS lb
on h.HOUSE_NO = lb.HOUSE_NO
WHERE lb.LOB_TYPE_CD ='C'
AND lb.HOUSE_NO IS NOT NULL;
BEGIN
OPEN c_subscriber_data;
LOOP
FETCH c_subscriber_data BULK COLLECT INTO table_subscriber_data LIMIT 100000;
EXIT WHEN table_subscriber_data.COUNT = 0;
if table_subscriber_data.COUNT>0 then
FOR idx IN table_subscriber_data.first..table_subscriber_data.last loop
INSERT INTO LPDADMIN.SUBSCRIBER(acct_no
,acct_status_cd
,connect_date
,disconnect_date
,bill_salutation_cd
,bill_first_name
,bill_last_name
,bill_addr_1
,bill_addr_2
,bill_city
,bill_postal_code
,bill_province_cd
,bill_cycle_day
,home_phone
,business_phone
,first_name
,last_name
,home_phone
,delql_status_cd
,service_address_1
,service_address_2
,service_city
,service_province_cd
VALUES (table_subscriber_data(idx).acct_no
,table_subscriber_data(idx).acct_status_cd
,table_subscriber_data(idx).connect_date
,table_subscriber_data(idx).disconnect_date
,table_subscriber_data(idx).bill_salutation_cd
,table_subscriber_data(idx).bill_first_name
,table_subscriber_data(idx).bill_last_name
,table_subscriber_data(idx).bill_addr_1
,table_subscriber_data(idx).bill_addr_2
,table_subscriber_data(idx).bill_city
,table_subscriber_data(idx).bill_postal_code
,table_subscriber_data(idx).bill_province_cd
,table_subscriber_data(idx).bill_cycle_day
,table_subscriber_data(idx).home_phone
,table_subscriber_data(idx).business_phone
,table_subscriber_data(idx).first_name
,table_subscriber_data(idx).last_name
,table_subscriber_data(idx).home_phone
,table_subscriber_data(idx).delql_status_cd
,table_subscriber_data(idx).service_address_1
,table_subscriber_data(idx).service_address_2
,table_subscriber_data(idx).service_city
,table_subscriber_data(idx).service_province_cd);
END LOOP;
end if;
END subscriber_load;
/no PL/SQL required
INSERT INTO LPDADMIN.SUBSCRIBER(acct_no
,acct_status_cd
,connect_date
,disconnect_date
,bill_salutation_cd
,bill_first_name
,bill_last_name
,bill_addr_1
,bill_addr_2
,bill_city
,bill_postal_code
,bill_province_cd
,bill_cycle_day
,home_phone
,business_phone
,first_name
,last_name
,home_phone
,delql_status_cd
,service_address_1
,service_address_2
,service_city
,service_province_cd
) SELECT ..... -
Please Help Adobe CS6 Master Collection Activeringscode
Hi my name is Mathias
so i have a BIG Problem !
i have the Orig. Adobe CS6 Master Collection for Windows
and today when I try to open my Photoshop or Illustrator, comes a serial number input! OK No Problem
give my original code which is on a box!
so and now the Problem
the code of the original is no longer possible! it stands
the serial number you entered is invalid.
please help
i come from german
thxJust looking at that link and I don't think this is my problem. It says:
Bootstrapper requires certain installer components to be in place to load correctly. Otherwise, it displays the error "Installer failed to initialize. File not found. Please download Adobe Support Advisor to detect the problem."
Run the Adobe CS5 Cleaner Tool and remove the product that you are going to install. See Resolve installation problems with CS5 Cleaner Tool | CS5.5, CS5, CS4, CS3 (cpsid_82947).
But mine doesn't say "File not found" anywhere in the error message.
If it helps on my desktop when I try to install it an icon comes up for a second that looks like the dmg mounted icon with the word "core" underneath it.
I'm on a Mac by the way. Specs are:
Mac OSX Version 10.6.8
Model Name: Mac Pro
Model Identifier: MacPro4,1
Processor Name: Quad-Core Intel Xeon
Processor Speed: 2.26 GHz
Number Of Processors: 2
Total Number Of Cores: 8
L2 Cache (per core): 256 KB
L3 Cache (per processor): 8 MB
Memory: 8 GB
Chipset Model: ATI Radeon HD 4890 -
Please help: How to bulk retrieve data via JDBC?
I want to retrieve great amount of data from oracle database through java/jdbc. Is that possible I can run oracle EXP.exe from java? I know I can use JNU, is it easy and reliable? Is there any other JDBC bulk fetching functions available and efficient? Thanks a lot for any help.
-ZZuse TOPLINK from OracleHmmmm...
ssniazi does nothing but ask for contact information or recommend Oracle products.
Based on this I consider it likely that this person is some sort of sales representative either directly or indirectly associated with Oracle.
I personally wouldn't provide any contact information to them. Nor would I accept any advice until this person starts to actually provide some solutions or at least correctly reveals any financial interests that they might have.
In addition I believe ssniazi is in violation of the conduct code of this website because ssniazi is requesting information which will be used by a business entity without telling the users that it will be used in that way. And I expect that Oracle itself would frown on such activities.
2.3 You agree that You will not use the Website to:...(g) collect or store personal data about other users unless specifically authorized by such users. -
Can u please explain me the bulk & collection concept ?
why we use bulk & collection ?
when to use bulk & collection ?
and performance wise which is better ?
thanks in advanceuser10685034 wrote:
Can u please explain me the bulk & collection concept ?
why we use bulk & collection ?
when to use bulk & collection ?
and performance wise which is better ? In PL/SQL programming the SQL part is executed by SQL Engine and PL is executed by PL/SQL Engine.
So in general any SQL statement available in PL/SQL is send to the SQL engine by the PL/SQL Engine and processed and returned back. This process of sending and getting it back is called Context Switch.
Consider the following code.
for i in (select empno from emp where deptno = 100)
loop
update emp set sal = sal*100 where empno = i.empno;
end loop; Lets consider that there are 20 employee under deptno 100. So now the UPDATE statement is executed 20 times. That is there is 20 context switch.
Introduction of bulk collect reduces this. Consider the following code.
declare
Type EmpTbl as table of number(10);
lEmpNo EmpTbl;
begin
select empno bulk collect into lEmpNo from emp where deptno = 100;
forall i in 1..lEmpNo.count
update emp set sal = sal*100 where empno = lEmpNo(i);
end; Here in the above code what i am doing is
1. Created a PL/SQL Table called EmpTbl.
2. Created a variable lEmpNo of type EmpTbl.
3. Collected all the empno for deptno = 100 into the lEmpNo.
4. Using FORALL send all the empno in the PL/SQL table to update at a single shot. By this the context switch is reduced extensively. -
Please help with an embedded query (INSERT RETURNING BULK COLLECT INTO)
I am trying to write a query inside the C# code where I would insert values into a table in bulk using bind variables. But I also I would like to receive a bulk collection of generated sequence number IDs for the REQUEST_ID. I am trying to use RETURNING REQUEST_ID BULK COLLECT INTO :REQUEST_IDs clause where :REQUEST_IDs is another bind variable
Here is a full query that use in the C# code
string sql = "INSERT INTO REQUESTS_TBL(REQUEST_ID, CID, PROVIDER_ID, PROVIDER_NAME, REQUEST_TYPE_ID, REQUEST_METHOD_ID, " +
"SERVICE_START_DT, SERVICE_END_DT, SERVICE_LOCATION_CITY, SERVICE_LOCATION_STATE, " +
"BENEFICIARY_FIRST_NAME, BENEFICIARY_LAST_NAME, BENEFICIARY_DOB, HICNUM, CCN, " +
"CLAIM_RECEIPT_DT, ADMISSION_DT, BILL_TYPE, LANGUAGE_ID, CONTRACTOR_ID, PRIORITY_ID, " +
"UNIVERSE_DT, REQUEST_DT, BENEFICIARY_M_INITIAL, ATTENDING_PROVIDER_NUMBER, " +
"BILLING_NPI, BENE_ZIP_CODE, DRG, FINAL_ALLOWED_AMT, STUDY_ID, REFERRING_NPI) " +
"VALUES " +
"(SQ_CDCDATA.NEXTVAL, :CIDs, :PROVIDER_IDs, :PROVIDER_NAMEs, :REQUEST_TYPE_IDs, :REQUEST_METHOD_IDs, " +
":SERVICE_START_DTs, :SERVICE_END_DTs, :SERVICE_LOCATION_CITYs, :SERVICE_LOCATION_STATEs, " +
":BENEFICIARY_FIRST_NAMEs, :BENEFICIARY_LAST_NAMEs, :BENEFICIARY_DOBs, :HICNUMs, :CCNs, " +
":CLAIM_RECEIPT_DTs, :ADMISSION_DTs, :BILL_TYPEs, :LANGUAGE_IDs, :CONTRACTOR_IDs, :PRIORITY_IDs, " +
":UNIVERSE_DTs, :REQUEST_DTs, :BENEFICIARY_M_INITIALs, :ATTENDING_PROVIDER_NUMBERs, " +
":BILLING_NPIs, :BENE_ZIP_CODEs, :DRGs, :FINAL_ALLOWED_AMTs, :STUDY_IDs, :REFERRING_NPIs) " +
" RETURNING REQUEST_ID BULK COLLECT INTO :REQUEST_IDs";
int[] REQUEST_IDs = new int[range];
cmd.Parameters.Add(":REQUEST_IDs", OracleDbType.Int32, REQUEST_IDs, System.Data.ParameterDirection.Output);
However, when I run this query, it gives me a strange error ORA-00925: missing INTO keyword. I am not sure what that error means since I am not missing any INTOs
Please help me resolve this error or I would appreciate a different solution
Thank youIt seems you are not doing a bulk insert but rather an array bind.
(Which you will also find that it is problematic to do an INSERT with a bulk collect returning clause (while this works just fine for update/deletes) :
http://www.oracle-developer.net/display.php?id=413)
But you are using array bind, so you simply just need to use a
... Returning REQUEST_ID INTO :REQUEST_IDand that'll return you a Rquest_ID[]
see below for a working example (I used a procedure but the result is the same)
//Create Table Zzztab(Deptno Number, Deptname Varchar2(50) , Loc Varchar2(50) , State Varchar2(2) , Idno Number(10)) ;
//create sequence zzzseq ;
//CREATE OR REPLACE PROCEDURE ZZZ( P_DEPTNO IN ZZZTAB.DEPTNO%TYPE,
// P_DEPTNAME IN ZZZTAB.DEPTNAME%TYPE,
// P_LOC IN ZZZTAB.LOC%TYPE,
// P_State In Zzztab.State%Type ,
// p_idno out zzztab.idno%type
// IS
//Begin
// Insert Into Zzztab (Deptno, Deptname, Loc, State , Idno)
// Values (P_Deptno, P_Deptname, P_Loc, P_State, Zzzseq.Nextval)
// returning idno into p_idno;
//END ZZZ;
//Drop Procedure Zzz ;
//Drop Sequence Zzzseq ;
//drop Table Zzztab;
class ArrayBind
static void Main(string[] args)
// Connect
string connectStr = GetConnectionString();
// Setup the Tables for sample
Setup(connectStr);
// Initialize array of data
int[] myArrayDeptNo = new int[3]{1, 2, 3};
String[] myArrayDeptName = {"Dev", "QA", "Facility"};
String[] myArrayDeptLoc = {"New York", "Chicago", "Texas"};
String[] state = {"NY","IL","TX"} ;
OracleConnection connection = new OracleConnection(connectStr);
OracleCommand command = new OracleCommand (
"zzz", connection);
command.CommandType = CommandType.StoredProcedure;
// Set the Array Size to 3. This applied to all the parameter in
// associated with this command
command.ArrayBindCount = 3;
command.BindByName = true;
// deptno parameter
OracleParameter deptNoParam = new OracleParameter("p_deptno",OracleDbType.Int32);
deptNoParam.Direction = ParameterDirection.Input;
deptNoParam.Value = myArrayDeptNo;
command.Parameters.Add(deptNoParam);
// deptname parameter
OracleParameter deptNameParam = new OracleParameter("p_deptname", OracleDbType.Varchar2);
deptNameParam.Direction = ParameterDirection.Input;
deptNameParam.Value = myArrayDeptName;
command.Parameters.Add(deptNameParam);
// loc parameter
OracleParameter deptLocParam = new OracleParameter("p_loc", OracleDbType.Varchar2);
deptLocParam.Direction = ParameterDirection.Input;
deptLocParam.Value = myArrayDeptLoc;
command.Parameters.Add(deptLocParam);
//P_STATE -- -ARRAY
OracleParameter stateParam = new OracleParameter("P_STATE", OracleDbType.Varchar2);
stateParam.Direction = ParameterDirection.Input;
stateParam.Value = state;
command.Parameters.Add(stateParam);
//idParam-- ARRAY
OracleParameter idParam = new OracleParameter("p_idno", OracleDbType.Int64 );
idParam.Direction = ParameterDirection.Output ;
idParam.OracleDbTypeEx = OracleDbType.Int64;
command.Parameters.Add(idParam);
try
connection.Open();
command.ExecuteNonQuery ();
Console.WriteLine("{0} Rows Inserted", command.ArrayBindCount);
//now cycle through the output param array
foreach (Int64 i in (Int64[])idParam.Value)
Console.WriteLine(i);
catch (Exception e)
Console.WriteLine("Execution Failed:" + e.Message);
finally
// connection, command used server side resource, dispose them
// asap to conserve resource
connection.Close();
command.Dispose();
connection.Dispose();
Console.WriteLine("Press Enter to finish");
Console.ReadKey();
} -
Please help with the query (INSERT RETURNING BULK COLLECT INTO)
I am trying to write a query inside the C# code where I would insert values into a table in bulk using bind variables. But I also I would like to receive a bulk collection of generated sequence number IDs for the REQUEST_ID. I am trying to use RETURNING REQUEST_ID BULK COLLECT INTO :REQUEST_IDs clause where :REQUEST_IDs is another bind variable
Here is a full query that use in the C# code
INSERT INTO REQUESTS_TBL(REQUEST_ID, CID, PROVIDER_ID, PROVIDER_NAME, REQUEST_TYPE_ID, REQUEST_METHOD_ID, SERVICE_START_DT, SERVICE_END_DT, SERVICE_LOCATION_CITY, SERVICE_LOCATION_STATE, BENEFICIARY_FIRST_NAME,
BENEFICIARY_LAST_NAME, BENEFICIARY_DOB, HICNUM, CCN, CLAIM_RECEIPT_DT, ADMISSION_DT, BILL_TYPE,
LANGUAGE_ID, CONTRACTOR_ID, PRIORITY_ID, UNIVERSE_DT, REQUEST_DT, BENEFICIARY_M_INITIAL,
ATTENDING_PROVIDER_NUMBER, BILLING_NPI, BENE_ZIP_CODE, DRG, FINAL_ALLOWED_AMT, STUDY_ID, REFERRING_NPI)
VALUES
(SQ_CDCDATA.NEXTVAL, :CIDs, :PROVIDER_IDs, :PROVIDER_NAMEs, :REQUEST_TYPE_IDs,
:REQUEST_METHOD_IDs, :SERVICE_START_DTs, :SERVICE_END_DTs, :SERVICE_LOCATION_CITYs,
:SERVICE_LOCATION_STATEs, :BENEFICIARY_FIRST_NAMEs, :BENEFICIARY_LAST_NAMEs, :BENEFICIARY_DOBs,
:HICNUMs, :CCNs, :CLAIM_RECEIPT_DTs, :ADMISSION_DTs, :BILL_TYPEs, :LANGUAGE_IDs,
:CONTRACTOR_IDs, :PRIORITY_IDs, :UNIVERSE_DTs, :REQUEST_DTs, :BENEFICIARY_M_INITIALs,
:ATTENDING_PROVIDER_NUMBERs, :BILLING_NPIs, :BENE_ZIP_CODEs, :DRGs, :FINAL_ALLOWED_AMTs,
:STUDY_IDs, :REFERRING_NPIs) RETURNING REQUEST_ID BULK COLLECT INTO :REQUEST_IDs
However, when I run this query, it gives me a strange error ORA-00925: missing INTO keyword. I am not sure what that error means since I am not missing any INTOs
Please help me resolve this error or I would appreciate a different solution
Thank youYou cannot use (and do not want to in this case) the BULK COLLECT.
create table for_testing
the_id number not null primary key,
some_data number
declare
l_return_value for_testing.the_id%type;
begin
4
insert into for_testing
the_id,
some_data
values
1,
5
returning the_id into l_return_value;
dbms_output.put_line('the return values is ' || l_return_value);
end;
20 /
the return values is 1
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.02
TUBBY_TUBBZ?Is a simple example. In the future, please use the tags to preserve formatting on your code like i have so it remains readable . -
Bulk Collect taking more time. Please suggest .
I am working on oracle 11g
I have one normal insert proc
CREATE OR REPLACE PROCEDURE test2
AS
BEGIN
INSERT INTO first_table
(citiversion, financialcollectionid,
dataitemid, dataitemvalue,
unittypeid, financialinstanceid,
VERSION, providerid, user_comment,
userid, insert_timestamp,
latestflag, finalflag, filename,
final_ytdltm_flag, nmflag , partition_key
SELECT citiversion, financialcollectionid,
dataitemid, dataitemvalue, unittypeid,
new_fi, VERSION, providerid,
user_comment, userid,
insert_timestamp, latestflag,
finalflag, filename, '', nmflag,1
FROM secon_table
WHERE financialinstanceid = 1
AND changeflag = 'A'
AND processed_flg = 'N';
END test2;
To impove performance i have normal insert into convert it to bulk collect :
CREATE OR REPLACE PROCEDURE test
AS
BEGIN
DECLARE
CURSOR get_cat_fin_collection_data(n_instanceid NUMBER) IS
SELECT citiversion,
financialcollectionid,
dataitemid,
dataitemvalue,
unittypeid,
new_fi,
VERSION,
providerid,
user_comment,
userid,
insert_timestamp,
latestflag,
finalflag,
filename,
nmflag,
1
FROM secon_table
WHERE financialinstanceid = n_instanceid
AND changeflag = 'A'
AND processed_flg = 'N';
TYPE data_array IS TABLE OF get_cat_fin_collection_data%ROWTYPE;
l_data data_array;
BEGIN
OPEN get_cat_fin_collection_data(1);
LOOP
FETCH get_cat_fin_collection_data BULK COLLECT
INTO l_data limit 100;
FORALL i IN 1 .. l_data.COUNT
INSERT INTO first_table VALUES l_data (i);
EXIT WHEN l_data.count =0;
END LOOP;
CLOSE get_cat_fin_collection_data;
END;
END test;
But bulk collect is taking more time.
below is the timings
SQL> set timing on
SQL> exec test
PL/SQL procedure successfully completed
Executed in 16.703 seconds
SQL> exec test2
PL/SQL procedure successfully completed
Executed in 9.406 seconds
SQL> rollback;
Rollback complete
Executed in 2.75 seconds
SQL> exec test
PL/SQL procedure successfully completed
Executed in 16.266 seconds
SQL> rollback;
Rollback complete
Executed in 2.812 seconds
Normal insert :- 9.4 second
Bulk insert:- 16.266 seconds
I am processing 1 lakh rows.
Can you please tell me the reason why bulk collect is taking more time. ? According to my knowledge it should take less time.
Please suggect do i need to check any parameter?
Please help.
Edited by: 976747 on Feb 4, 2013 1:12 AM>
Can you please tell me the reason why bulk collect is taking more time. ? According to my knowledge it should take less time.
Please suggect do i need to check any parameter?In that case, your knowledge is flawed.
Pure SQL is almost always faster than PL/SQL.
If your Insert into Select is executing slow, then it is probably because the Select statement is taking long to execute. How many rows are being Selected and Inserted from your query?
You might also consider tuning the Select statement. For more information on Posting a Tuning request, read {message:id=3292438} and post the relevant information. -
Need help with Bulk Collect ForAll Update
Hi - I'm trying to do a Bulk Collect/ForAll Update but am having issues.
My declarations look like this:
CURSOR cur_hhlds_for_update is
SELECT hsh.household_id, hsh.special_handling_type_id
FROM compas.household_special_handling hsh
, scr_id_lookup s
WHERE hsh.household_id = s.id
AND s.scr = v_scr
AND s.run_date = TRUNC (SYSDATE)
AND effective_date IS NULL
AND special_handling_type_id = 1
AND created_by != v_user;
TYPE rec_hhlds_for_update IS RECORD (
household_id HOUSEHOLD_SPECIAL_HANDLING.household_id%type,
spec_handl_type_id HOUSEHOLD_SPECIAL_HANDLING.SPECIAL_HANDLING_TYPE_ID%type
TYPE spec_handling_update_array IS TABLE OF rec_hhlds_for_update;
l_spec_handling_update_array spec_handling_update_array;And then the Bulk Collect/ForAll looks like this:
OPEN cur_hhlds_for_update;
LOOP
FETCH cur_hhlds_for_update BULK COLLECT INTO l_spec_handling_update_array LIMIT 1000;
EXIT WHEN l_spec_handling_update_array.count = 0;
FORALL i IN 1..l_spec_handling_update_array.COUNT
UPDATE compas.household_special_handling
SET effective_date = TRUNC(SYSDATE)
, last_modified_by = v_user
, last_modified_date = SYSDATE
WHERE household_id = l_spec_handling_update_array(i).household_id
AND special_handling_type_id = l_spec_handling_update_array(i).spec_handl_type_id;
l_special_handling_update_cnt := l_special_handling_update_cnt + SQL%ROWCOUNT;
END LOOP;And this is the error I'm receiving:
ORA-06550: line 262, column 31:
PLS-00436: implementation restriction: cannot reference fields of BULK In-BIND table of records
ORA-06550: line 262, column 31:
PLS-00382: expression is of wrong type
ORA-06550: line 263, column 43:
PL/SQL: ORA-22806: not an object or REF
ORA-06550: line 258, column 9:
PL/SQL: SQMy problem is that the table being updated has a composite primary key so I have two conditions in my where clause. This the the first time I'm even attempting the Bulk Collect/ForAll Update and it seems like it would be straight forward if I was only dealing with a single-column primary key. Can anyone please help advise me as to what I'm missing here or how I can accomplish this?
Thanks!
ChristineYou cannot reference a column inside a record when doin a for all. You need to refer as a whole collection . So you will need two collections.
Try like this,
DECLARE
CURSOR cur_hhlds_for_update
IS
SELECT hsh.household_id, hsh.special_handling_type_id
FROM compas.household_special_handling hsh, scr_id_lookup s
WHERE hsh.household_id = s.ID
AND s.scr = v_scr
AND s.run_date = TRUNC (SYSDATE)
AND effective_date IS NULL
AND special_handling_type_id = 1
AND created_by != v_user;
TYPE arr_household_id IS TABLE OF HOUSEHOLD_SPECIAL_HANDLING.household_id%TYPE
INDEX BY BINARY_INTEGER;
TYPE arr_spec_handl_type_id IS TABLE OF HOUSEHOLD_SPECIAL_HANDLING.SPECIAL_HANDLING_TYPE_ID%TYPE
INDEX BY BINARY_INTEGER;
l_household_id_col arr_household_id;
l_spec_handl_type_id_col arr_spec_handl_type_id;
BEGIN
OPEN cur_hhlds_for_update;
LOOP
FETCH cur_hhlds_for_update
BULK COLLECT INTO l_household_id_col, l_spec_handl_type_id_col
LIMIT 1000;
EXIT WHEN cur_hhlds_for_update%NOTFOUND;
FORALL i IN l_household_id_col.FIRST .. l_household_id_col.LAST
UPDATE compas.household_special_handling
SET effective_date = TRUNC (SYSDATE),
last_modified_by = v_user,
last_modified_date = SYSDATE
WHERE household_id = l_household_id_col(i)
AND special_handling_type_id = l_spec_handl_type_id_col(i);
--l_special_handling_update_cnt := l_special_handling_update_cnt + SQL%ROWCOUNT; -- Not sure what this does.
END LOOP;
END;G. -
Hi All,
I need a help to create a bulk statement. Please find the scenario below
I would like to copy a table A from table B using bulk collect also the table A has more records (1Million). Before doing this I need to either truncate the table B or drop the table to load the data from table A.
Please provide me the correct statement to achieve this request. Thanks in advance!!
Regards,
Boovan.disabling any indexes on the target should be looked at first. If there are none then look at the above.
When you do a direct path load the indexes are build after loading.The point is that the direct path load does not avoid the undo due to the indexes.
In this example on a table with no indexes the undo used goes from 216kb to 16kb using append.
When an index is added the undo used goes up from 216kb to 704kb an increase of 488kb for a standard insert.
For the direct path insert the undo goes up from 16kb to 440kb so almost the full amount of undo due to the index.
So the presence of a single index can have a much greater impact on the amount of undo required than the use of a direct path load and that undo may not be avoided by the use of a direct path load unless the index is disabled beforehand.
Also note the tiny amounts of undo we are talking about for 50k rows.
SQL> create table t as select * from all_objects where 0 = 1;
Table created.
SQL> insert into t select * from all_objects;
56108 rows created.
SQL> select
2 used_ublk undo_used_blk,
3 used_ublk * blk_size_kb undo_used_kb,
4 log_io logical_io,
5 cr_get consistent_gets
6 from
7 v$transaction, v$session s,
8 (select distinct sid from v$mystat) m,
9 (select to_number(value)/1024 blk_size_kb
10 from v$parameter where name='db_block_size')
11 where
12 m.sid = s.sid
13 and ses_addr = saddr;
UNDO_USED_BLK UNDO_USED_KB LOGICAL_IO CONSISTENT_GETS
27 216 13893 1042736
SQL> rollback;
Rollback complete.
SQL> insert /*+ append */ into t select * from all_objects;
56108 rows created.
SQL> select
2 used_ublk undo_used_blk,
3 used_ublk * blk_size_kb undo_used_kb,
4 log_io logical_io,
5 cr_get consistent_gets
6 from
7 v$transaction, v$session s,
8 (select distinct sid from v$mystat) m,
9 (select to_number(value)/1024 blk_size_kb
10 from v$parameter where name='db_block_size')
11 where
12 m.sid = s.sid
13 and ses_addr = saddr;
UNDO_USED_BLK UNDO_USED_KB LOGICAL_IO CONSISTENT_GETS
2 16 1307 1041151
SQL> rollback;
Rollback complete.
SQL> create unique index t_idx on t (object_id);
Index created.
SQL> insert into t select * from all_objects;
56109 rows created.
SQL> select
2 used_ublk undo_used_blk,
3 used_ublk * blk_size_kb undo_used_kb,
4 log_io logical_io,
5 cr_get consistent_gets
6 from
7 v$transaction, v$session s,
8 (select distinct sid from v$mystat) m,
9 (select to_number(value)/1024 blk_size_kb
10 from v$parameter where name='db_block_size')
11 where
12 m.sid = s.sid
13 and ses_addr = saddr;
UNDO_USED_BLK UNDO_USED_KB LOGICAL_IO CONSISTENT_GETS
88 704 20908 1043193
SQL> rollback;
Rollback complete.
SQL> insert /*+ append */ into t select * from all_objects;
56109 rows created.
SQL> select
2 used_ublk undo_used_blk,
3 used_ublk * blk_size_kb undo_used_kb,
4 log_io logical_io,
5 cr_get consistent_gets
6 from
7 v$transaction, v$session s,
8 (select distinct sid from v$mystat) m,
9 (select to_number(value)/1024 blk_size_kb
10 from v$parameter where name='db_block_size')
11 where
12 m.sid = s.sid
13 and ses_addr = saddr;
UNDO_USED_BLK UNDO_USED_KB LOGICAL_IO CONSISTENT_GETS
57 456 2310 1041047 -
HELP!!! How to print out details in BULK COLLECT?
I have a
select line#, item, price ...
BULK COLLECT into v_line_table
from table_1, table_2
where ....
How can I do dbms_output.put_line from v_line_table, so I can see what value I got?
Please help! Thank youdoesn't seems to recognize the word "COLLECTION"
dbms_output.put_line(COLLECTION.my_column);
I aslo tried FOR LOOP, no luck
FOR x IN 1 .. v_line_table.COUNT
LOOP
dbms_output.put_line('v_line_table.line_discount '|| v_line_table(x).line_discount); */
END LOOP;
please advise -
Hi!
There is probably a pretty easy fix for this situation - it's just I can't figure out what it is. Thanks in advance for your help.
Here's my situation;
1. I have a pretty large collection of music which I paid to match a couple years ago. My computer which I originally used to subscribe to iTunes match has died. No problem right? Since I have already subscribed to iTunes Match. But wait...
2. I wanted to download my entire music collection onto another one of my computers just because I want to keep a back-up of all my music - just incase some time in the future I do NOT want to subscribe to iTunes Match anymore.
3. While I was able to download most of my collection - a ton of songs were not downloaded. But instead, I see as pictured in [1] below, an exclaimation point in a circle to the left of the song, and a cloud icon with an exclaimation point in it under the "Match" column.
4. I am still able to play these songs - and download them individually, but not without going through a 4 step process FOR EACH SONG!!!
THERE MUST BE ANOTHER WAY to download all my music without going through this ridiculous process.
[1] STEP ONE - Select the song I want to download. If I double click it - I first see this message below that says, "The song "the beatles - Beetles-Hey Jude" could not be used because the original file could not be found. Would you like to locate it?" So, since I no longer have the original file, I click "Cancel". BUT, that's exactly the moment when THE SONG STARTS PLAYING - and the the cloud icon with the exclaimation point turns to a could icon with an down-arrow letting me know that I can now download the file. (Go to step 2)
[2] BUT when I click that cloud icon with the down arrow, the cloud icon with the down arrow changes back to the cloud icon with the exclaimation point and then I get this message that says "The item was not added to iCloud because an error occurred." But the song seems to have downloaded in the right folder in my iTunes music folder. So, I hit OK, and I and I am still able to play this song. (Go to step 3)
[3] So at this stage, I am not sure why there is the CLoud icon with the Exclaimation point in it next to the song. Because it was just downloaded from the cloud, into my iTunes folder. But never the less the cloud icon with the exclaimation point is still there. The only way I can now get rid of that is to right click and select - "Add to iCloud".
[4] So now you see here below, STEP 4 - Hey Jude is downloaded, and matched to the cloud. THERE HAS GOT TO BE A BETTER WAY! Please help.I have the same problem!!!!PLEASE HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-I'm having some serious problems with installing iTunes on my laptop. I have searched and searched the internet and can not find any solution to my problem. I am receiving the error "itunes is not a valid win32 application' after the program finishes downloading. Sometimes however it will just stop in the middle of the download. I use a SONY VAIO VGN-NW25GF which was only purchased last year. It uses windows 7. I had trouble downloading itunes to begin with though eventually it worked, however since the new 10.1 update has been available ive been attempting to update it almost every time i use itunes. Each and every time it fails and i've had enough as i need to update my iphone software. I’ve since uninstalled both itunes and quicktime hoping it will reinstall properly. But nothing, the same problem is occurring and now i have no itunes program!
I've tried all the solutions online about deleting browing history/temp folder and any itunessetup.exe/quicktimesetup.exe files and nothing works. I've also tried downloading using a different browser and still nothing. I’ve done a virus scan, disk cleanup and disk defragment and NOTHIGN is working. I'm starting to get quite frustrated as i need this program for my iphone. Any help would be greatly appreciated!! Thanks -
Needed help in bulk collect using collections
Hi,
I have created a schema level collection like "CREATE OR REPLACE TYPE T_EMP_NO IS TABLE OF NUMBER ;
will i able to use this in a where clause which involves bulk collect?
Please share ur thoughts.
My oracle version is 10guser13710379 wrote:
Will i be able to do a bulk collect into a table using this collection of my sql type?Bulk fetches collects into an array like structure - not into a SQL table like structure. So calling a collection variable in PL/SQL a "+PL/SQL table+" does not make much sense as this array structure is nothing like a table. For the same reason, one needs to question running SQL select statements against PL/SQL arrays.
As for your SQL type defined - it is a collection (array) of numbers. Thus it can be used to bulk fetch a numeric column. -
My ipod touch(4th gen) just recently had the iOS 5 update.bu for some reason about 80% of my music collection appears with no album artwork and doesnt play any songs.basically it has my music on their but wont let me access it? please help!
i have the same problem but i have ios 5.01. how do you unsync? please help, thanks
-
ITunes Match has messed up my entire music collection - please help me
Does anyone else have a problem with iTunes Match splitting their albums? I have been happily using iTunes for my entire music collection (round 800 albums) but it became a disaster the day I turned on Match. Where an album has a guest contributor on a track, it removes that track and places it separately, same album name and cover, but with the individual track(s). Some albums have been split across more than 7 individual album entries. The changes appear to be permanent. Turning off Match does not cure the problem. Removing the album and reloading it doesn't cure the problem. I have been through and individually altered each album track to say that it it part of the same album. This results in the album tracks places together but then shows the album as 'unknown artist' so I can't view my music properly. I am at my wits end with this. Please help.
Hi,
This is not a match issue but a general iTunes problem - read this article http://samsoft.org.uk/iTunes/grouping.asp
Jim
Maybe you are looking for
-
Adobe Bridge CC Freezes Every Time
Please help, Bridge CC is basically unusable! It has been this way since I installed it. I have followed these steps several times and no success: http://helpx.adobe.com/bridge/kb/troubleshoot-errors-freezes-bridge-windows.html Basically every time I
-
What is the best method to parse a java file for function names
st="class"; while (StreamTokenizer.TT_EOF != tokenizer.nextToken ()) if (StreamTokenizer.TT_WORD == tokenizer.ttype) if (tokenizer.sval.toLowerCase().equals(st.toLowerCase())){ System.out.print (tokenizer.nextToken() + " "); //prints the c
-
Oracle 9.0.1 SQL*Plus and PL/SQL
Having just upgraded from Oracle 8.0.1 to the above, can anyone suggest a good book for learning the above languages as I believe there is quite a lot of difference in the codes, which also contains some good exercises for trying them out. Phil.
-
Tcode PA70(Fast Entry) using SAP GUI for HTML
Hi Gurus, when i am copying data(one row) from excel sheet into infotype using tcode PA70(Fast Entry),through EP(transaction iview Created Using SAP GUI for HTML). enter TCODE PA70-> select Recurring Payments/Deductions -> click create -> copy the da
-
Preview in browser option not working
Hi there, I'm running dreamweaver cs4 on mac osx 10.4.11. I'm trying to use the 'preview in browser' option without any success. When I try to preview in Firefox, or any other browser in fact, I get the message 'Unable to launch Firefox.app - Please