Batch preparation

Hi,
Oracle 11.2.0.1
Windows
create table products
pno varchar2(7),
distcode varchar2(2),
sub varchar2(2),
weight number(4),
tehsil varchar2(30),
lineno number(4)
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010175','01','18',211,'PLACE1',1);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010178','01','18',80,'PLACE1',2);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010012','01','18',77,'PLACE1',3);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010213','01','18',71,'PLACE1',4);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010154','01','18',57,'PLACE1',5);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010057','01','18',48,'PLACE1',6);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010136','01','18',38,'PLACE1',7);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010657','01','18',22,'PLACE1',8);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010318','01','18',20,'PLACE1',9);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010212','01','18',19,'PLACE1',10);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010209','01','18',12,'PLACE1',11);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010033','01','18',11,'PLACE1',12);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010429','01','18',10,'PLACE1',13);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010196','01','18',58,'PLACE2',14);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010103','01','18',25,'PLACE2',15);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010464','01','18',17,'PLACE2',16);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010269','01','18',17,'PLACE2',17);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010292','01','18',17,'PLACE3',18);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010230','01','18',17,'PLACE3',19);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010448','01','18',13,'PLACE3',20);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010062','01','18',10,'PLACE3',21);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010388','01','18',101,'PLACE4',22);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010217','01','18',94,'PLACE4',23);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010224','01','18',60,'PLACE4',24);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010547','01','18',29,'PLACE4',25);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010219','01','18',35,'PLACE5',26);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010189','01','18',81,'PLACE6',27);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010245','01','18',45,'PLACE7',28);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1010130','01','18',51,'PLACE8',29);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020739','02','18',154,'PLACE9',30);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020463','02','18',115,'PLACE9',31);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020763','02','18',109,'PLACE9',32);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020394','02','18',88,'PLACE9',33);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020291','02','18',79,'PLACE9',34);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020043','02','18',76,'PLACE9',35);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020302','02','18',64,'PLACE9',36);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020216','02','18',63,'PLACE9',37);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020573','02','18',63,'PLACE9',38);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020740','02','18',62,'PLACE9',39);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1021302','02','18',62,'PLACE9',40);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020908','02','18',59,'PLACE9',41);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020120','02','18',59,'PLACE9',42);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020056','02','18',56,'PLACE9',43);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020395','02','18',49,'PLACE9',44);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020567','02','18',49,'PLACE9',45);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020593','02','18',49,'PLACE9',46);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020747','02','18',49,'PLACE9',47);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020396','02','18',48,'PLACE9',48);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020215','02','18',44,'PLACE9',49);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020398','02','18',43,'PLACE9',50);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020976','02','18',40,'PLACE9',51);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020236','02','18',33,'PLACE9',52);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020462','02','18',32,'PLACE9',53);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020574','02','18',32,'PLACE9',54);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020316','02','18',29,'PLACE9',55);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020010','02','18',27,'PLACE9',56);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020393','02','18',26,'PLACE9',57);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1021093','02','18',25,'PLACE9',58);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020989','02','18',23,'PLACE9',59);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020554','02','18',23,'PLACE9',60);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1021316','02','18',19,'PLACE9',61);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020921','02','18',18,'PLACE9',62);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020864','02','18',17,'PLACE9',63);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020996','02','18',16,'PLACE9',64);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020125','02','18',16,'PLACE9',65);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020214','02','18',15,'PLACE9',66);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020555','02','18',15,'PLACE9',67);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020912','02','18',14,'PLACE9',68);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020918','02','18',12,'PLACE9',69);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020448','02','18',11,'PLACE9',70);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020710','02','18',11,'PLACE9',71);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020953','02','18',75,'PLACE10',72);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020870','02','18',71,'PLACE10',73);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020701','02','18',63,'PLACE10',74);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1021325','02','18',60,'PLACE10',75);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020698','02','18',46,'PLACE10',76);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020800','02','18',45,'PLACE10',77);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020906','02','18',32,'PLACE10',78);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020421','02','18',25,'PLACE10',79);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020141','02','18',23,'PLACE10',80);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020697','02','18',20,'PLACE10',81);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020704','02','18',19,'PLACE10',82);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020863','02','18',17,'PLACE10',83);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020376','02','18',14,'PLACE10',84);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020428','02','18',14,'PLACE10',85);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020987','02','18',13,'PLACE10',86);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020521','02','18',10,'PLACE10',87);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020272','02','18',10,'PLACE10',88);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020948','02','18',84,'PLACE11',89);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020266','02','18',78,'PLACE11',90);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020792','02','18',60,'PLACE11',91);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1021065','02','18',60,'PLACE11',92);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020566','02','18',56,'PLACE11',93);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020563','02','18',46,'PLACE11',94);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020728','02','18',43,'PLACE11',95);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020966','02','18',41,'PLACE11',96);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020644','02','18',40,'PLACE11',97);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020761','02','18',37,'PLACE11',98);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020670','02','18',34,'PLACE11',99);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020564','02','18',33,'PLACE11',100);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020434','02','18',32,'PLACE11',101);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020811','02','18',29,'PLACE11',102);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020873','02','18',29,'PLACE11',103);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020441','02','18',28,'PLACE11',104);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020787','02','18',27,'PLACE11',105);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020002','02','18',26,'PLACE11',106);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020382','02','18',26,'PLACE11',107);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020601','02','18',26,'PLACE11',108);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020889','02','18',26,'PLACE11',109);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020890','02','18',25,'PLACE11',110);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020370','02','18',22,'PLACE11',111);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1021139','02','18',22,'PLACE11',112);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020600','02','18',21,'PLACE11',113);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020608','02','18',21,'PLACE11',114);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020650','02','18',21,'PLACE11',115);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1021099','02','18',21,'PLACE11',116);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1021342','02','18',21,'PLACE11',117);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020435','02','18',20,'PLACE11',118);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020708','02','18',20,'PLACE11',119);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020709','02','18',20,'PLACE11',120);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020940','02','18',19,'PLACE11',121);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020974','02','18',19,'PLACE11',122);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020383','02','18',17,'PLACE11',123);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020822','02','18',17,'PLACE11',124);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1021335','02','18',17,'PLACE11',125);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020765','02','18',16,'PLACE11',126);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020874','02','18',15,'PLACE11',127);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020364','02','18',12,'PLACE11',128);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020595','02','18',12,'PLACE11',129);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020188','02','18',11,'PLACE11',130);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020810','02','18',11,'PLACE11',131);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1021020','02','18',11,'PLACE11',132);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1021003','02','18',10,'PLACE11',133);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020263','02','18',136,'PLACE12',134);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020520','02','18',60,'PLACE12',135);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020314','02','18',53,'PLACE12',136);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020026','02','18',42,'PLACE12',137);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020764','02','18',37,'PLACE12',138);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020112','02','18',34,'PLACE12',139);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020525','02','18',33,'PLACE12',140);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020387','02','18',30,'PLACE12',141);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020278','02','18',21,'PLACE12',142);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020438','02','18',20,'PLACE12',143);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020542','02','18',20,'PLACE12',144);
Insert into SCOTT.PRODUCTS (PNO,DISTCODE,SUB,WEIGHT,TEHSIL,LINENO) values ('1020312','02','18',13,'PLACE12',145);
For above data, I have adopted almost same functionality (Great code by Frank, populate_bin procedure) which have been mentioned in the below thread:
https://forums.oracle.com/message/9243262#9243262
Because whatever that OP requires, almost the same functionality I need with couple of additional features.  In mine case, above table is treated as a raw data, which needs further processing.  We are treating above data as PNO=School code and Weight=Number of students in the said school for mentioned subject who are going to appear in the exam, and we have to make "group(s)" of school(s) in which we will appoint an examiner to take exam.
Batch preparing rules :
bin_weight_max(please see above thread)
1.For order by column, lineno is there.  Just take rows in order of lineno column.
2.In one batch, there should be maximum 4 schools within distcode only.
3.In one batch, the count of candidates should be equal to bin_weight_max.  If we are going to add next school (and count of schools are still less than equal 4) and sum of students of the batch is less than equal to bin_weight_max + 10%, it is allowable.
4.In batch, there should not be mixing of multiple district codes.
5.Break of candidates will be almost same as mentioned in above thread i.e. 30 students.
6.Unique PNOs are there.  No repetition of PNO.
7.Count of rows in the table are between 1000 to 7000 only.
Let me elaborate more (For above data)
Suppose bin_weight_max = 210 (i.e. in one batch there can be 210 or +10% i.e. 21+210=231)
Max_No_of_Schools = 4 (i.e. only 4 schools/row can be there,order by lineno in one batch)  <--- Mine requirement please
Now,
In first school there are 211 students :
So, First batch will be:
1  1010175  211 (Even though 211 is crossing 210 boundary, but it is less than 231 though)
Now, if I adds second school (order by lineno) whose count is 80 and 211+80 is more than 231, so here
breaking will be occurred.
2  1010178   80
Ok, now I adds second row whose count of student is 70, so 80+77=157 less than 210 and 231, and count of school is less than Max_No_of_Schools, take it.
   1010012   77
Ok, now I adds third row whose count of student is 71, so 157+71=228 more than 210 but less than 231, and count of school is less than Max_No_of_Schools take it.
   1010213   71
Ok, now I adds fourth row whose count of student is 57, so 228+57=285 more than 210 and more than 231 = False, next batch require.
So, how second batch will looks like :
2  1010178   80
   1010012   77
   1010213   71
3  1010154   57
   1010057   48
   1010136   38
   1010657   22
Max_No_of_Schools = 4, next batch, same distcode
4  1010318   20
   1010212   19
   1010209   12
   1010033   11
Max_No_of_Schools = 4, next batch, same distcode
5  1010429   10
   1010196   58
   1010103   25
   1010464   17
Max_No_of_Schools = 4, next batch, same distcode
6  1010269   17
   1010292   17
   1010230   17
   1010448   13
Max_No_of_Schools = 4, next batch, same distcode
7  1010062   10
   1010388   101
   1010217   94
Sum of student are 205, if I adds next 60 students then 265 is more than 210 and 231, next batch, same distcode
8  1010224   60
   1010547   29
   1010219   35
   1010189   81
i.e. same distcode, sum of students is less than bin_weight_max+10%, count of school is less than 4, then next school will be added as it is, otherwise try to make it near by bin_weight_max or bin_weight_max+10% by breaking of student in the chunk of 30s.  If at any place when we are going to add next school (order by lineno) and its distcode is different than previous one, then also break of batch (next batch) will be happened.  So finally, new batch rule are :
1.Count of schools are 4
2.Same district code
3.sum of students is less than bin_weight_max+10%,
I don't know how good/clear I have mentioned my requirement, which is purely based upon Frank's great code in above thread.  At the same time, since I am very much poor in PL/SQL, I searched in this forum, and found above thread, implemented it, it worked like a charm, but since couple of new business rules have been included in the required output, failed to get new required output, I am opening a new thread here.
kindly let me know, I have to mention more.
Thanks and Regards
Girish Sharma

Playing with recursion:
154 pupils on lineno = 30 changed to 15 to check dist_code change
with
bins(school_id,dist_code,pupils,sum_pupils,bin,cnt,lim,lineno) as
(select school_id,dist_code,pupils,pupils,0,0,210,lineno
   from schools
  where lineno = 1
union all
select s.school_id,
        s.dist_code,
        s.pupils,
        case when b.sum_pupils + s.pupils <= 1.1 * b.lim
              and b.cnt < 4
              and b.dist_code = s.dist_code
             then b.sum_pupils + s.pupils
             else s.pupils
        end,
        case when b.sum_pupils + s.pupils <= 1.1 * b.lim
              and b.cnt < 4
              and b.dist_code = s.dist_code
             then b.bin
             else b.bin + 1
        end,
        case when b.sum_pupils + s.pupils <= 1.1 * b.lim
              and b.cnt < 4
              and b.dist_code = s.dist_code
             then b.cnt + 1
             else 1
        end,
        b.lim,
        b.lineno + 1
   from bins b,
        schools s
  where b.lineno = s.lineno
select school_id,dist_code,pupils,bin
  from bins
where bin != 0
SCHOOL_ID
DIST_CODE
PUPILS
BIN
1010175
01
211
1
1010178
01
80
2
1010012
01
77
2
1010213
01
71
2
1010154
01
57
3
1010057
01
48
3
1010136
01
38
3
1010657
01
22
3
1010318
01
20
4
1010212
01
19
4
1010209
01
12
4
1010033
01
11
4
1010429
01
10
5
1010196
01
58
5
1010103
01
25
5
1010464
01
17
5
1010269
01
17
6
1010292
01
17
6
1010230
01
17
6
1010448
01
13
6
1010062
01
10
7
1010388
01
101
7
1010217
01
94
7
1010224
01
60
8
1010547
01
29
8
1010219
01
35
8
1010189
01
81
8
1010245
01
45
9
1010130
01
51
9
1020739
02
15
10
1020463
02
115
10
1020763
02
109
11
1020394
02
88
11
1020291
02
79
12
1020043
02
76
12
1020302
02
64
12
1020216
02
63
13
1020573
02
63
13
1020740
02
62
13
1021302
02
62
14
1020908
02
59
14
1020120
02
59
14
1020056
02
56
15
1020395
02
49
15
1020567
02
49
15
1020593
02
49
15
1020747
02
49
16
1020396
02
48
16
1020215
02
44
16
1020398

Similar Messages

  • Re-using a PreparedStatement in a batch update

    Can I use a PrepatedStatement to add to a batch for a delete and then recreate the same PreparedStatement to do a bunch of inserts and have all the database work be done when executeBatch() is called?
    Or do I need a seperate PreparedStatement for my deletes and inserts?
    // Add the delete old records SQL to the batch
    String sql = "DELETE FROM LWOS422A WHERE RPMTRX=? AND RPVERS=? AND RPRPSC=?";
    PreparedStatement ps = connection.prepareStatement(sql);
    ps.setObject(1, primaryValues[0]);
    ps.setObject(2, primaryValues[1]);
    ps.setObject(3, primaryValues[2]);
    ps.addBatch();
    // Add the insert of all new records to the batch
    sql = "INSERT INTO LWOS422A VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
    ps = connection.prepareStatement(sql);
    for (int r=0; r<getRowCount(); r++) {
       for (int c=0; c<getColumnCount(); c++) {
          ps.setObject(c+1, getValueAt(r, c));
       ps.addBatch();
    ps.executeBatch();
    connection.commit()

    unfortunately no. when you issue the con.prepareStatement for the second time, all the batches from the first prepared statement lost. You will have to make 2 different batched prepared statements or change to statement objects.
    Jamie

  • How to execute these insert statements as a batch?

    Hello,
    I have these three insert sql statements which execute individually. I want to execute them as a batch:
    sql = "Insert into FirstTable (MessageId, MsgDate, MsgTitle) values (?, ?, ?)";
    insertStatement = connection.prepareStatement(sql);
    insertStatement.setInt(1, jmsgid);
    insertStatement.setString(2, jlogdate);
    insertStatement.setString(3, jmsgtitle);
    insertStatement.executeUpdate();
    sql = "Insert into SecondTable (MessageId, MsgDate, MsgTitle) values (?, ?, ?)";
    insertStatement = connection.prepareStatement(sql);
    insertStatement.setInt(1, jmsgid);
    insertStatement.setString(2, jlogdate);
    insertStatement.setString(3, jmsgtitle);
    insertStatement.executeUpdate();
    sql = "Insert into ThirdTable (MessageId, MsgDate, MsgTitle) values (?, ?, ?)";
    insertStatement = connection.prepareStatement(sql);
    insertStatement.setInt(1, jmsgid);
    insertStatement.setString(2, jlogdate);
    insertStatement.setString(3, jmsgtitle);
    insertStatement.executeUpdate();
    I tried the following method, but something is wrong. Can somebody help with executing these inserts as a batch?
    stmt = connection.createStatement(); // connection pool
    sql = "Insert into FirstTable (MessageId, MsgDate, MsgTitle) values (?, ?, ?)";
    insertStatement.setInt(1, jmsgid);
    insertStatement.setString(2, jlogdate);
    insertStatement.setString(3, jmsgtitle);
    stmt.addBatch(sql);
    sql = "Insert into SecondTable (MessageId, MsgDate, MsgTitle) values (?, ?, ?)";
    insertStatement.setInt(1, jmsgid);
    insertStatement.setString(2, jlogdate);
    insertStatement.setString(3, jmsgtitle);
    stmt.addBatch(sql);
    sql = "Insert into ThirdTable (MessageId, MsgDate, MsgTitle) values (?, ?, ?)";
    insertStatement.setInt(1, jmsgid);
    insertStatement.setString(2, jlogdate);
    insertStatement.setString(3, jmsgtitle);
    stmt.addBatch(sql);
    stmt.executeBatch();
    Thank you,
    Logan

    Errr I can't for the life of me understand why you thought that would work. I am bit concerned about how you assembled this code... did you copy and paste and hope for the best?
    It should be.....
    1) Get a preparedStatement using your sql. Do this step once.
    2) For each query you want to batch.... set each of the parameters and call addBatch. Call all this on the prepared statement.
    3) Then call executeBatch on the prepared statement.
    You do not need the other vanilla statement for anything.
    One important thing to note. When you batch parameters for batch prepared statement execution you can only (hopefully obviously) batch for the same SQL query. You can't do one insert and another update in the same query. It has to be all the same query.. just different parameters. This won't effect what you are doing in the above but sometimes it confuses people and they get into trouble later so I thought I would mention it now.

  • Slow access of our database

    We have a program that simulates the flow of time. For every "day" that the program simulates, we write some data that we generate into two different tables in the database using two different INSERT statements. In both cases, we place about 4 integers into the table at a time, so it's not like we're writing a lot of data. Regardless, the program simulates 3500 "days", and is very slow. (We know it is the INSERT statements, because the program runs very quickly when we comment them out.)
    When the program ends, we write out a lot of data all at once...about 12,000 rows with 7 integers each. Here, we also use INSERT statements for each row; it is also very slow.
    Are there clever ways to speed things up? We're pretty new to communicating with a database through Java.

    Batch the inserts.
    Use PreparedStatements
    Use CallableStatements (stored procedures)
    Drop the indexes before batch inserts and recreate them after.
    Any of the above four mentioned may lead to improvements in speed on their own or in conjunction with the others. I suspect batching prepared statements alone could give you a dramatic speed increase (because the database won't have to parse each query individually and parsing is a relatively expensive operation usually)
    If the first three don't do anything for you then look at locking the table and dropping the indexes as mentioned. Indexes are great for SELECTs when you have lots of data but they make INSERTS, UPDATES and DELETES much slower then they would be otherwise. Depending on the database indexing scheme (of which you have little to no control) the performance is likely to degrade as the number of rows in the table increases when you INSERT on a table with indexes.
    Personally I think dropping and recreating indexes is not a bad idea for operations like this. Because combined with the performance benefits on the insert when you recreate the index it won't be fragmented and if you are inserting a heavy relative number of rows in a table with an index it is likely that the index will be fragmented and need to be rebuilt anyway. (Index fragmentation means a number of things depending on the system but in short it means mostly that your key distribution is likely to be unbalanced relative to your data which makes the index less efficient)
    On the other hand if you need to ensure entegrity of the data you are inserting with a key or unqiue index you are rather stuck with that.

  • Batch updates with callable/prepared statement?

    The document http://edocs.bea.com/wls/docs70/oracle/advanced.html#1158797 states
    that "Using Batch updates with the callableStatement or preparedStatement is
    not supported". What does that actually mean? We have used both callable and prepared
    statements with the batch update in our current project (with the Oracle 817 db).
    It seems to run ok anyway.

    So the documentation should state that batch updates do not work ok in old versions
    of JDriver for Oracle, BUT work correctly with newer version. Additionally, batch
    updates work ok when used with Oracle supplied jdbc-drivers?
    "Stephen Felts" <[email protected]> wrote:
    Support for addBatch and executeBatch in the WLS Jdriver for Oracle was
    added in 7.0SP2.
    It was not available in 6.X or 7.0 or 7.0SP1.
    "Janne" <[email protected]> wrote in message news:3edb0cdc$[email protected]..
    The document http://edocs.bea.com/wls/docs70/oracle/advanced.html#1158797
    states
    that "Using Batch updates with the callableStatement or preparedStatementis
    not supported". What does that actually mean? We have used both callableand prepared
    statements with the batch update in our current project (with the Oracle817 db).
    It seems to run ok anyway.

  • Error handling in prepared statement batch

    Hi,
    For a prepared statement batch, it is not possible to know which operation failed. ... You should always perform a ROLLBACK operation in this situation.
    For a generic statement batch or callable statement batch, the update counts array is only a partial array containing the actual update counts up to the point of the error. ... You can either commit or roll back the successful operations in this situation, as you prefer.
    -- http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/java.920/a96654/oraperf.htm#1056233
    But, I want to skip failed operations and continue to excecute the remains of the batch, also, I want to improve application performance, what should I do? Is there any choice?
    Best Regards,
    Kevin Zhao

    According to the Oracle docs these are not the only possible values:
    Oracle9i JDBC Developer's Guide and Reference
    Release 2 (9.2) chapter 12
    Performance Extensions
    "For a prepared statement batch, it is not possible to know which operation failed. The array has one element for each operation in the batch, and each element has a value of -3. According to the JDBC 2.0 specification, a value of -3 indicates that an operation did not complete successfully. In this case, it was presumably just one operation that actually failed, but because the JDBC driver does not know which operation that was, it labels all the batched operations as failures."
    It goes on to say that for a generic statement batch it is possible to know which failed. I would like to know if similar functionality will be available for prepared statement batches in the future.

  • What is a better approach, batch or prepared statement?

    Hi,
    In my application, the user account property will be retrieved from DB and the last login time will be updated after a successful sign on. There are two query statements in this procedure; select and update. What is a better approach in JDBC to deal with the two queries: batch or prepared statement?
    Thanks.

    Hi, Duffy,
    Thanks for your input.
    I would like to use PreparedStatement with batch update. From my reading, however, it is not suitable to use PreparedStatement with batch update. At less, I haven't see a single example on the tutorial or article sections of this site. I am not sure the following is valid or not:
                   stmt = connection.prepareStatement(INSERT_SMT_QUERY_STR);
                   stmt.setLong(1, details.getRegardID());
                   stmt.setLong(2, details.getWriterID());
                   stmt.setInt(3, details.getVisibility());
                   stmt.setString(4, details.getSubject().trim());
                   stmt.setString(5, details.getContent().trim());
    stmt.addBatch() <-- what goes into here?

  • Count of Rows Updated with prepared statement batch

    I am using a batch of prepared statements for update operation. (pstmt.executeBatch())
    Configuration I am using
    WLS 6.1sp2 Connection pool - Oracle Thin driver - TX Datasource
    DB - Oracle 8.1.7
    The batch update works well i.e data gets updated and committed. BUT I am not
    getting back the count of number of rows updated.
    Is there any thing more required on WLS side ?
    Thanks in Advance

    The Oracle drivers do not return the updated row counts from batched updates.
    Try running the attached program with the thin driver
    java Batch oracle.jdbc.driver.OracleDriver jdbc:oracle:thin:@host:port:database user password
    You will see that returns -2, which indicates that the number of rows updated is unknown.
    This does meet the JDBC spec.
    "Harshad Nanal" <[email protected]> wrote in message news:3f8a455f$[email protected]..
    >
    I am using a batch of prepared statements for update operation. (pstmt.executeBatch())
    Configuration I am using
    WLS 6.1sp2 Connection pool - Oracle Thin driver - TX Datasource
    DB - Oracle 8.1.7
    The batch update works well i.e data gets updated and committed. BUT I am not
    getting back the count of number of rows updated.
    Is there any thing more required on WLS side ?
    Thanks in Advance[Batch.java]

  • XML SQL format for Prepared statements in batch mode

    Hi
    I want to use the batch mode in JDBC adapter for inserting huge volume of records with better performance.
    so i need to execute the prepared statements in one batch.   Is the XML SQL format for prepared statements below correct ?to<root>
      <stmt>
        <Customers action="SQL_DML">
          <access> INSERT INTO Customers (CompanyName,Address,CustomerID) VALUES($NAME$,$ADDRESS$,$KEYFIELD$)
          </access>
          <key>
            <NAME>IBM</NAME>
            <ADDRESS>Street 3 </ADDRESS>
            <KEYFIELD>CO</KEYFIELD>
          </key>
          <key>
            <NAME>PWC</NAME>
            <ADDRESS>Street 4 </ADDRESS>
            <KEYFIELD>NO</KEYFIELD>
         </key>
        </Customers>
      </stmt>
    </root>
    Please advise

    Hello Experts
    Please throw some light on the above question.
    Thanks in advance.

  • Multiple prepared statements batch execution

    Hi,
    I have many different select SQLs I would like to execute in a batch.
    Its not a problem if they are simple SQLs, you simply use the statement object and addBatch(sql) to it and then execute the entire batch.
    But I would like these SQLs to be of a prepared statement format (meaning with ? and so on).
    I know its possible if they are all of same prepared statement SQL and I can bind varabiles to then and write addBatch() and so on. but the the SQLs are different then one another (different tables and so on).
    is it possible?

    The sqls are different.
    However, when you create 1prepared statement, during its creation you give it, its sql.
    that sql should be only 1 command.That doesn't make it clear. I can make one prepared statement that has multiple SQL statements in it.
    There is no rule that states that it must only have one SQL statement.
    if I enable a simple prepared statement to accept a sql which is build from several
    commands it might mean that there was some sql injection there.Then I can only suppose that you are using prepared statements incorrectly. However, excluding building SQL statement itself, I have no idea how you would construct a prepared statement that would allow an injection attack. And building the SQL statement itself is exactly what prepared statements and a solution in terms of injection attacks prevent.
    the solution of providing several sqls in the prepared statement constructor is not a valid option from my perspective.You might believe so. You might have a reason for that although I have no idea what it is. It certainly isn't due to injection attacks because that isn't a valid reason.
    That doesn't mean that it can't be done.

  • Resultset from a batch select using prepared statement

    Hi,
    Is it possible to add results of batch execute of select statements and retrieve the result set ..
    I am running select statement in a batch mode setting in value for a column.I add this to a prepared batch.
    I would like to get the reults as a batch and spin through the result set like a r.next(). Is this possible ?
    I have given the code below
    sql = "select ordervalue , orderdate from discreet_orders "+
    "where order_no = ? ";
    dbObject.prepareStatement(sql);
    dbObject.prepareStatement(sql);
    for (int i=0; i < orderNoVect.size(); i++) {
    dbObject.setString(1,(String)scnV.elementAt(i));
    dbObject.addBatchPrepared();
    r = dbObject.execPrepared();
    dbObject.clearBatchPrepared();
    I would like to do a r.getNext() process the values form the resultset.
    Is this possible ? If not is there an other way to do it ?
    Thanks
    Arnold

    Olek wrote:
    hi
    Is there a way do a batch update using prepared statement?
    I don't want to insert every row in a single query...
    regards,
    OlekPossibly the confusion here stems from the existence of two addBatch methods in PreparedStatement.
    addBatch(String sql)inherited from Statement adds a new query to the batch of SQL statements for the statement. However you don't want to use this with PreparedStatements Instead you want
    addBatch()which adds the current set of parameters to the prepared statements batch of commands.
    In this scenario you prepare your query (insert statement) and then call setXXX(x,y) for each parameter and then addBatch for each tuple. Then call executeBatch to execute all the queries based on your batched parameters.
    If this didn't answer your question I don't know what your question is exactly. I would add that you probably want to set a "reasonable" size on your batches and break them into smaller batches as is reasonable. Mainly because the implementation of batched PreparedStatements widely varies depending on the database and driver, thus there are certainly scenarios where given enough batched parameters you could have various unpleasant things visited upon your program. Like terminal slowness, running out of memory, etc.

  • Preparing for Large Batch of Windows Server Updates going back to Aug 2013

    How often do updates to Windows servers interfere with a servers performance, services, and/or software?
    In other words, after installing updates, what level of validation should be involved in making sure the updates are not causing issues on the server? With such a large batch of updates to install this weekend, I want to be prepared for worst case scenarios
    involving systems not booting up, required services not starting, software conflicts, etc. We have a 2008R2 server and a 2003 server to test on, but they're not really representative of the production servers in terms of the roles they play and services they
    run. Just to clarify, this is my first time updating Windows servers.

    1. There is a long term mantra: Test updates in test environment before applying updates in production systems.
    2. Situation is complicated a bit by the fact that there are "direct"  and WSUS update packages.
    3. MS states that updates are tested thoroughly. I do believe they do a good job.
    4. I work with Windows for a very long period and I am pretty sure that the quality of software including updates is increasing.
    5. I understand your hesitation, my first updates caused the same tension.
    6. You have a possibility to download updates for "direct" application from catalog update repository. Problem is that you do not know the optimal order of installation. Fortunately information on problems and their solution comes fast from Internet if you
    listen on right channels.
    7. From my point of view the danger stems from some optional updates, namely drivers may send your server to unexpected operation. I do prefer drivers and firmware from server/computer vendor, though some irregularities exists.
    HTH
    Milos

  • Jdbc2Odbc, Prepared Stmts and Batches... just don't work together.

    Hi.
    this throws a NegativeArraySizeException on executeBatch:
    con.setAutoCommit(false);
    PreparedStatement p=con.prepareStatement("insert test_date(txt) values(?)");
    p.setString(1, "das");
    p.addBatch();
    p.setString(1, "sss");
    p.addBatch();
    p.executeBatch();
    con.commit();
    p.close();
    con.close();
    this does too:
    con.setAutoCommit(false);
    PreparedStatement p=con.prepareStatement("insert test_date(txt) values(?)");
    p.setString(1, "das");
    p.addBatch();
    p.executeBatch();
    con.commit();
    p.close();
    con.close();
    this works fine:
    con.setAutoCommit(false);
    PreparedStatement p=con.prepareStatement("insert test_date(txt) values(?)");
    p.setString(1, "das");
    p.addBatch();
    p.executeUpdate();
    con.commit();
    p.close();
    con.close();
    to make things worse, this does not throw any Exception, but instead of a 5, I get 144595456 in the table!!!:
    con.setAutoCommit(false);
    PreparedStatement p=con.prepareStatement("insert test_date(l) values(?)");
    p.setInt(1, 5);
    p.addBatch();
    p.executeBatch();
    con.commit();
    p.close();
    con.close();
    could someone recode Jdbc2Odbc?? :))
    nikolas/

    Hi,
    As far as I know, this is a bug in the JDBC-ODBC bridge. I used to get the same error and I used a native driver to get around this problem. My database was DB2, and I used a native driver for DB2. One more thing, the JDBC-ODBC bridge is very slow and you will notice the difference once you use the native driver.
    There is a batch file usejdbc2.bat which directs the driver to use the jdbc 2.0 specs explicitly. I ran that before actually using the native driver. In the case of a DB2 driver it should be in the directory Sqllib\java12. But I am not sure about the other drivers.
    Hope this helps and best wishes,
    Nish

  • Steps to prepare and upload  excel  files data to r/3?

    Hi abap experts,
    We have brand new installed ECC system somehow configured but with no master or transaction data loaded .It is new  empty system....We also have some legacy data in excel files...We want to start loading some data into the SAP sandbox step by step and to see how they work...test some transactions see if the loaded data are good etc initial tests.
    Few questions here are raised:
    -Can someone tell me what is the process of loading this data into SAP system?
    -Should this excel file must me reworked prepared somehow(fields, columns etc) in order to be ready for upload to SAP??
    -Users asked me how to prepared their legacy excel files so they can be ready in SAP format for upload.?Is this an abaper  job or it is a functional guy job?
    -Or should the excel files be converted to .txt files and then imported to SAP?Does it really make some difference if files are in excel or .txt format?
    -Should the Abaper determine the structure of those excel file(to be ready for upload ) and if yes,  what are the technical rules here ?
    -What tools should be used for this initial data loads? CATT , Lsmw , batch input or something else?
    -At which point we should test the data?I guess after the initial load?
    -What tools are used in all steps before...
    -If someone can provide me with step by step scenario or guide of loading some kind of initial  master data - from .xls file alignment  to the real upload  - this will be great..
    You can email me  some upload guide or some excel/txt file examples and screenshots documents to excersize....Email: [email protected]
    Your help is appreciated it.!
    Jon

    Depends on data we upload the data from file to R/3 .
    If it is regular updation then we used to get the data from application server files to R/3 since local file updation we can not set up background processing..
    If it is master data upload and that to one time upload then we use presenation server files to SAP R/3..
    See the simple example to upload the data to on master custom table from XLS File
    Program    : ZLWMI151_UPLOAD(Data load to ZBATCH_CROSS_REF Table)
    Type       : Upload program
    Author     : Seshu Maramreddy
    Date       : 05/16/2005
    Transport  : DV3K919574
    Transaction: None
    Description: This program will get the data from XLS File
                 and it upload to ZBATCH_CROSS_REF Table
    REPORT ZLWMI151_UPLOAD no standard page heading
                           line-size 100 line-count 60.
    *tables : zbatch_cross_ref.
    data : begin of t_text occurs 0,
           werks(4) type c,
           cmatnr(15) type c,
           srlno(12) type n,
           matnr(7) type n,
           charg(10) type n,
           end of t_text.
    data: begin of t_zbatch occurs 0,
          werks like zbatch_cross_ref-werks,
          cmatnr like zbatch_cross_ref-cmatnr,
          srlno like zbatch_cross_ref-srlno,
          matnr like zbatch_cross_ref-matnr,
          charg like zbatch_cross_ref-charg,
          end of t_zbatch.
    data : g_repid like sy-repid,
           g_line like sy-index,
           g_line1 like sy-index,
           $v_start_col         type i value '1',
           $v_start_row         type i value '2',
           $v_end_col           type i value '256',
           $v_end_row           type i value '65536',
           gd_currentrow type i.
    data: itab like alsmex_tabline occurs 0 with header line.
    data : t_final like zbatch_cross_ref occurs 0 with header line.
    selection-screen : begin of block blk with frame title text.
    parameters : p_file like rlgrap-filename obligatory.
    selection-screen : end of block blk.
    initialization.
      g_repid = sy-repid.
    at selection-screen on value-request for p_file.
      CALL FUNCTION 'F4_FILENAME'
           EXPORTING
                PROGRAM_NAME = g_repid
           IMPORTING
                FILE_NAME    = p_file.
    start-of-selection.
    Uploading the data into Internal Table
      perform upload_data.
      perform modify_table.
    top-of-page.
      CALL FUNCTION 'Z_HEADER'
      EXPORTING
        FLEX_TEXT1       =
        FLEX_TEXT2       =
        FLEX_TEXT3       =
    *&      Form  upload_data
          text
    FORM upload_data.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
           EXPORTING
                FILENAME                = p_file
                I_BEGIN_COL             = $v_start_col
                I_BEGIN_ROW             = $v_start_row
                I_END_COL               = $v_end_col
                I_END_ROW               = $v_end_row
           TABLES
                INTERN                  = itab
           EXCEPTIONS
                INCONSISTENT_PARAMETERS = 1
                UPLOAD_OLE              = 2
                OTHERS                  = 3.
      IF SY-SUBRC <> 0.
        write:/10 'File '.
      ENDIF.
      if sy-subrc eq 0.
        read table itab index 1.
        gd_currentrow = itab-row.
        loop at itab.
          if itab-row ne gd_currentrow.
            append t_text.
            clear t_text.
            gd_currentrow = itab-row.
          endif.
          case itab-col.
            when '0001'.
              t_text-werks = itab-value.
            when '0002'.
              t_text-cmatnr = itab-value.
            when '0003'.
              t_text-srlno = itab-value.
            when '0004'.
              t_text-matnr = itab-value.
            when '0005'.
              t_text-charg = itab-value.
          endcase.
        endloop.
      endif.
      append t_text.
    ENDFORM.                    " upload_data
    *&      Form  modify_table
          Modify the table ZBATCH_CROSS_REF
    FORM modify_table.
      loop at t_text.
        t_final-werks = t_text-werks.
        t_final-cmatnr = t_text-cmatnr.
        t_final-srlno = t_text-srlno.
        t_final-matnr = t_text-matnr.
        t_final-charg = t_text-charg.
        t_final-erdat = sy-datum.
        t_final-erzet = sy-uzeit.
        t_final-ernam = sy-uname.
        t_final-rstat = 'U'.
        append t_final.
        clear t_final.
      endloop.
      delete t_final where werks = ''.
      describe table t_final lines g_line.
      sort t_final by werks cmatnr srlno.
    Deleting the Duplicate Records
      perform select_data.
      describe table t_final lines g_line1.
      modify zbatch_cross_ref from table t_final.
      if sy-subrc ne 0.
        write:/ 'Updation failed'.
      else.
        Skip 1.
        Write:/12 'Updation has been Completed Sucessfully'.
        skip 1.
        Write:/12 'Records in file ',42 g_line .
        write:/12 'Updated records in Table',42 g_line1.
      endif.
      delete from zbatch_cross_ref where werks = ''.
    ENDFORM.                    " modify_table
    *&      Form  select_data
          Deleting the duplicate records
    FORM select_data.
      select werks
             cmatnr
             srlno from zbatch_cross_ref
             into table t_zbatch for all entries in t_final
             where werks = t_final-werks
             and  cmatnr = t_final-cmatnr
             and srlno = t_final-srlno.
      sort t_zbatch by werks cmatnr srlno.
      loop at t_zbatch.
        read table t_final with key werks = t_zbatch-werks
                                    cmatnr = t_zbatch-cmatnr
                                    srlno = t_zbatch-srlno.
        if sy-subrc eq 0.
          delete table t_final .
        endif.
        clear: t_zbatch,
               t_final.
      endloop.
    ENDFORM.                    " select_data
    and also you can use .txt file upload using Function module - GUI_UPLOAD
    if it is application server then use open datset command.
    Thanks
    Seshu

  • Steps to prepare and upload legacy master data excel files into SAP?

    Hi abap experts,
    We have brand new installed ECC system somehow configured but with no master or transaction data loaded .It is new empty system....We also have some legacy data in excel files...We want to start loading some data into the SAP sandbox step by step and to see how they work...test some transactions see if the loaded data are good etc initial tests.
    Few questions here are raised:
    -Can someone tell me what is the process of loading this data into SAP system?
    -Should this excel file must me reworked prepared somehow(fields, columns etc) in order to be ready for upload to SAP??
    -Users asked me how to prepared their legacy excel files so they can be ready in SAP format for upload.?Is this an abaper job or it is a functional guy job?
    -Or should the excel files be converted to .txt files and then imported to SAP?Does it really make some difference if files are in excel or .txt format?
    -Should the Abaper determine the structure of those excel file(to be ready for upload ) and if yes, what are the technical rules here ?
    -What tools should be used for this initial data loads? CATT , Lsmw , batch input or something else?
    -At which point we should test the data?I guess after the initial load?
    -What tools are used in all steps before...
    -If someone can provide me with step by step scenario or guide of loading some kind of initial master data - from .xls file alignment to the real upload - this will be great..
    You can email me some upload guide or some excel/txt file examples and screenshots documents to excersize....
    Your help is appreciated it.!
    Jon

    hi,
    excel sheet uploading:
    http://www.sap-img.com/abap/upload-direct-excel.htm
    http://www.sap-img.com/abap/excel_upload_alternative-kcd-excel-ole-to-int-convert.htm
    http://www.sapdevelopment.co.uk/file/file_upexcel.htm
    http://www.sapdevelopment.co.uk/ms/mshome.htm

Maybe you are looking for