Using Collections
HI EXPERTS
i want to implement the below procedure using pl/sql collections can any one suggest for the followinG
create or replace procedure test_proc
is
cursor c1 is select * from temp;
cursor c1 is select * from MONITORING;
i temp%rowtype;
j MONITORING%type;
begin
open c1
loop
if (I.RES_CODE = '02' and i.CUST_ACCNO = j.CUST_ACCNO and i.CUST_MMID = j.CUST_MMID and i.CUST_MOBNO = j.CUST_MOBNO) then
Insert into APP
(CUST_ACCNO,CUST_MOBNO,CUST_MMID,REMARKS,RES_CODE)
SELECT I.CUST_ACCNO,I.CUST_MOBNO,I.CUST_MMID,i.RES_CODE,'03'
FROM temp I
WHERE EXISTS (SELECT NULL FROM MONITORING M WHERE M.CUST_ACCNO = I.CUST_ACCNO AND M.CUST_MOBNO = I.CUST_MOBNO AND M.CUST_MMID = I.CUST_MMID)
AND I.RES_CODE = '02';
elsif (I.RES_CODE = '02' and (i.CUST_ACCNO != j.CUST_ACCNO or i.CUST_MMID != j.CUST_MMID or i.CUST_MOBNO != j.CUST_MOBNO)) then
Insert into APP
(CUST_ACCNO,CUST_MOBNO,CUST_MMID,REMARKS,RES_CODE)
SELECT I.CUST_ACCNO,I.CUST_MOBNO,I.CUST_MMID,i.RES_CODE,'04'
FROM temp I
WHERE NOT EXISTS (SELECT NULL FROM MONITORING M WHERE M.CUST_ACCNO = I.CUST_ACCNO AND M.CUST_MOBNO = I.CUST_MOBNO AND M.CUST_MMID = I.CUST_MMID)
AND I.RES_CODE = '02';
elsif I.RES_CODE != '02' then
Insert into APP
(CUST_ACCNO,CUST_MOBNO,CUST_MMID,REMARKS,RES_CODE)
SELECT I.CUST_ACCNO,I.CUST_MOBNO,I.CUST_MMID,i.RES_CODE,'02'
FROM temp I
WHERE I.RES_CODE != '02';
exit whenc1
end loop;
close c1;
end;
/
Didn't you have a discussion just yesterday about Re: Collections:?
As was discussed in your previous thread, if the goal is to improve efficiency, it would be more efficient to get rid of the cursors and to just issue SQL statements to insert all the rows at once. Using collections may be an improvement over slow row-by-row processing but set-based processing will be even more efficient.
In yesterdays thread, multiple people showed you how to use collections. Is there some specific problem/ question that you have? Presumably, the goal of you posting here is to learn how to use collections on your own, not to post all of your procedures one at a time and ask others to rewrite them using collections.
The code you posted can't possibly compile. For example, you have two different declarations of the c1 cursor that query two completely different tables. There is an "exit whenc1" call that doesn't appear to match to any loop. Your code is also rather hard to follow since it is not formatted. If you put the tag \ (6 characteers all lower case) immediately before and after a code snippet, the forum will maintain all the spacing. That makes the code much, much easier to read.
Justin
Similar Messages
-
In Oracle 10g Error while using COLLECT
I getting error while using collect in 10g
SQL> ed
Wrote file afiedt.buf
1 SELECT deptno
2 , COLLECT(ename) AS emps
3 FROM emp
4 GROUP BY
5* deptno
SQL> /
, COLLECT(ename) AS emps
ERROR at line 2:
ORA-00932: inconsistent datatypes: expected NUMBER got -
Please give me the solution.you are using old version of SQL*Plus. if you use later version it will give you correct result.
Edited by: unus on Mar 14, 2010 4:25 AM -
Problem in using COLLECT statment
Hi experts,
getting problem in using COLLECT statement. attaching my code below.
LOOP AT it_final1 INTO wa_final1.
LOOP AT it_final INTO wa_final WHERE vagrp = wa_final1-vagrp AND verwmerkm = wa_final1-verwmerkm.
wa_final1-anzwertg = wa_final-anzwertg.
COLLECT wa_final1 INTO it_final1.
ENDLOOP.
CLEAR: wa_final1, wa_final.
ENDLOOP.
here , i want to use collect statement only for "anzwertg" field from internal table. but 2 more fields also getting compressed .
attaching screen shot
here, original_input and max fields also getting compressed.
could anybody please help me out in this.
Thanks in advance.
Regards
satishHi satish....
collect statement works based on char fields..
by default it will taken char fields as a key fields .........
if any char field is repeated then corresponding numc values will be added....
other wise it will act as a APPEND statement......
Here in ur code there is no char field then how it will caliculate that values...
just check it once..
Regards,
Vamsi.... -
How to use collect statement for below
data : begin of itab,
n(3) type c,
n1 type n,
k(5) type c,
end of itab.
select n n1 from into itab table /zteest.
*internal table has
n n1 k
gar 100 uji
hae 90 iou
gar 90 uji
hae 87 iou
I want
gar 190
hae 177
How to use collect statement as n1 is n ..?
let me know..
Thankstry this..
DATA : BEGIN OF itab OCCURS 0,
n(3) TYPE c,
n1(3) TYPE p DECIMALS 2,
k(5) TYPE c,
END OF itab.
itab-n = 'gar'.
itab-n1 = 100.
itab-k = 'uji'.
COLLECT itab .CLEAR itab.
itab-n = 'hae'.
itab-n1 = 90.
itab-k = 'iou'.
COLLECT itab .CLEAR itab.
itab-n = 'gar'.
itab-n1 = 90.
itab-k = 'uji'.
COLLECT itab .CLEAR itab.
itab-n = 'hae'.
itab-n1 = 87.
itab-k = 'iou'.
COLLECT itab .CLEAR itab. -
Using COLLECT on a internal table
Hello,
I have fetched records from a table into my internal table through, " SELECT * FROM .... INTO TABLE FOR ALL ENTRIES IN ...... "
There are two columns in my internal table against which i need a total of the column. COLLECT sums the amounts . But how can i use COLLECT in this scenario ?
Can anyone kindly guide me ...Thanks
Shehryar DaharHi,
COLLECT add the numeric entries for the corresponding table keys..
Example.
DATA: BEGIN OF ITAB OCCURS 0,
MATNR TYPE MATNR,
COUNT TYPE I,
END OF ITAB.
ITAB-MATNR = 'ABC'.
ITAB-COUNT = 2.
COLLECT ITAB.
ITAB-MATNR = 'ABC'.
ITAB-COUNT = 1.
COLLECT ITAB.
ITAB-MATNR = 'ABCD'.
ITAB-COUNT = 2.
COLLECT ITAB.
ITAB-MATNR = 'ABCD'.
ITAB-COUNT = 3.
COLLECT ITAB.
LOOP AT ITAB.
WRITE: / ITAB-MATNR, ITAB-COUNT.
ENDLOOP.
For more information on Collect, check this site:
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/collect.htm
Hope this would help you out.
Regards,
Varun. -
Need a function to calcultate value using collections
Hi
I have a main table ab ( sno,empid,joindate,sal_mth, sal_yr ,run_date)
a stage table cd (sno,empid,joindate,sal_mth).
Now the catch is for every run( every day run), I need to get all data from ab and roll fwd them to the run date ( only change would be run_date)
Also If in stage table cd we receive data for the combination sno,empid,joindate,sal_mth which is present in ab, we would
change the sal_yr in ab - criteria would be sal_yr:=sal_yr + cd.sal_mth
I have done it but in primitive way using union etc. Would prefer a function to do this using collection.
Any suggestions?
Regards
SHUBHSomething like below ? (to be turned into function as you didn't mention what to return)
procedure roll_fwd(p_run_date in date) is
begin
insert into ab
select a.sno,a.empid,a.joindate,a.sal_mth,a.sal_yr + nvl(c.sal_mth,0) sal_yr,p_run_date
from ab a,cd c
where a.run_date = p_run_date - 1
and a.sno = c.sno(+)
and a.empid = c.empid(+)
and a.joindate = c.joindate(+)
and a.sal_mth = c.sal_mth(+);
end;Regards
Etbin
Edited by: Etbin on 20.2.2011 17:14
No action taken on cd data - if they're lucky, they may get another increase next day ;) -
How to acheive this scnerio in PL/SQl using collections
Hi All,
In my apllication we are handling two types of procedures which runs based on the jobs.
Due to some problem few records where got missed in prouduction.
We have tried to run this jobs manaually one by one and it is taking time to execute..
I have got a suggetsion from my senior to do in a collection and run this packages at a time..
Here is my exact scenerio, can you please help me out to implemnet in collections..
Steps:
Populate the missing records namely ordered, event sequence, Start date, end date, region in to plsql table/collection. ( Hard-coded since this will run the code
for a date which will take less time and take less record).
looping the plsqltable/collection for missing records
Running the procedure p_Daily with startdate and end date parameter
-- if the above executed successfully we need to execute second procedure i.e p_Region procedure by checking records in f_daily_report exist/relevant table
(Id and sequence).
Running the procedure p_region with start date and region id ( checking whether id and sequece is exist f_daily_report table).
end loop
The above steps which i have explained needs to achievd thru collections, can anybody helps me out on this.
Note:
1. All the missing jobs wil fal under differnt date rane groups.
2. For second job i.e p_region i have mentioned that it will run based on start date and region id..This job will run on three differnt region id's..We can find the
region id based on by joining f_region and d_region table. It seems that these misisng records belongs to all three regions
Hope u all understand my scenrio. can you please help me out..
Thanks in advance,
Anoo..Anoo wrote:
Hi,
Hope you have not clear my question..The reason is i want to know how we can achieve my problem in collection
rather than select statement.. Even though if we can get in simple statement is not advisible in my case..That is the reason why i was looking collections...
Rather than providing data is it possible to how we can proceed in collections.That's like saying you want to write poor code that performs slowly rather than fast and performant code.
Without clear explanations and examples of data and output, there doesn't appear to be a valid reason for using collections. The reason you're not getting many responses on your thread is because you're not explaining clearly what is required with examples. Please read {message:id=9360002} for an idea of what people need from you in order to help you. -
Best practices when using collections in LR 2
How are you using collections and collection sets? I realize that each photographer uses them differently, but I'm looking some inspiration because I have used them only very little.
In LR 1 I used collections a bit like virtual Folders, but it doesn't anymore work as naturally in LR2.
In LR 1 it was like:
Travel (1000 images, all Berlin images)
Travel / Berlin trip (400 images, all Berlin trip images)
Travel / Berlin trip / web (200 images)
Travel / Berlin trip / print (100 images)
In LR 2 it could be done like this, but this somehow feels unnatural.
Travel (Collection Set)
Travel / Berlin trip (CS)
Travel / Berlin trip / All (collection, 400 images)
Travel / Berlin trip / web (collection, 200 images)
Travel / Berlin trip / print (collection, 100 images)
Or is this kind of use stupid, because same could be done with keywords and smart collections, and it would be more transferable.
Also, how heavily are you using Collections? I'm kind of on the edge now (should I start using them heavily or not), because I just lost all my collections because I had to build my library from scratch because of weird library/database problems.Basically, i suggest not to use collections to replicate the physical folder structure, but rather to collect images independent of physical storage to serve a particular purpose. The folder structure is already available as a selection means.
Collections are used to keep a user defined selection of images as a persistent collection, that can be easily accessed.
Smart collections are based on criteria that are understood by the application and automatically kept up to date, again as a persistent collection for easy access. If this is based on a simple criterium, this can also, and perhaps even easier, done by use of keywords. If however it is a set of criteria with AND, OR combinations, or includes any other metadata field, the smart collection is the better way to do it. So keywords and collections in Lightroom are complementary to eachother.
I use (smart)collections extensively, check my website www.fromklicktokick.com where i have published a paper and an essay on the use of (smart)collections to add controls to the workflow.
Jan R. -
Interactive Reports using collections - How to control column headings
Hi,
I found a link in the forum somewhere that showed a step by step how to to use collections with Interactive Reports so you can dynamically build the SQL and also control the column headings. Does anyone know where the How-To is ??
If not, I know how to build the SQL dynamically but what is the best way to control the column headings.
Sometimes the report will have 17 columns and other times up to 30 columns.
Thank you, BillHi Bill,
Without knowing more about the PL/SQL code, the underlying tables and the select statements used, it is difficult to say.
I would firstly check that I had indexes on the right column or combination of columns. One minute sounds a lot for a query to me, but that may be ok if the tables are very large and the PL/SQL has to do a fair bit to construct the output. You could also do an Explain Plan for any query to check to see if indexes are being used if they exist - this would also show up any part of a query that takes an inordinate amount of time.
I assume that the PL/SQL is only run once even if the page is reloaded multiple times? However, once the collection has been created, the report itself should be fairly quick as it should be just a simple select over the collection data. Switching on the debug mode should help identify which part is taking the time.
Andy -
Hi ,
To improve the performance of the insert statement i was adviced to use the collections.
I'm not getting any idea on how to use collection concept in my code.
Could you please give me a skelton approach to do that.
The following is the sample code (the logic is same in prod code,instead of for 1 -100000 we have cursor in prod) without using collections
create table pop_tab ( col1 number ,col2 number ,col3 number ,col4 number )
create or replace package test_collect
is
procedure proc_lvl_ld ;
procedure proc_pop_tab (v_var1 number ,v_var2 number ,v_var3 number ,v_var4 number) ;
end test_collect;
create or replace package body test_collect
is
procedure proc_lvl_ld
is
v_cnt number := 1 ;
v_var1 NUMBER ;
v_var2 NUMBER ;
v_var3 NUMBER ;
v_var4 NUMBER;
begin
for i in 1 .. 100000 loop
v_var1 := v_cnt + 1;
v_var2 := v_cnt + 2;
v_var3 := v_cnt + 3;
v_var4 := v_cnt + 4;
v_cnt := v_cnt + 1;
proc_pop_tab (v_var1 ,v_var2,v_var3,v_var4);
end loop;
commit;
exception when others then
DBMS_OUTPUT.PUT_LINE ( 'proc_lvl_load'||sqlcode||','||sqlerrm );
end proc_lvl_ld;
procedure proc_pop_tab (v_var1 number ,v_var2 number ,v_var3 number ,v_var4 number)
is
begin
insert into pop_tab (col1,col2,col3,col4)
values (v_var1,v_var2,v_var3,v_var4) ;
exception when others then
DBMS_OUTPUT.PUT_LINE ( 'proc_pop_tab'||sqlcode||','||sqlerrm );
end proc_pop_tab;
end test_collect;Now i tried a bit using colliection to improve the insert performance and stuck how to use the collections
create or replace package body test_collect
is
procedure proc_lvl_ld
is
TYPE numtab1 IS TABLE OF NUMBER (4) INDEX BY BINARY_INTEGER;
data1 numtab1;
TYPE numtab2 IS TABLE OF NUMBER (4) INDEX BY BINARY_INTEGER;
data2 numtab2;
TYPE numtab3 IS TABLE OF NUMBER (4) INDEX BY BINARY_INTEGER;
data3 numtab3;
TYPE numtab4 IS TABLE OF NUMBER (4) INDEX BY BINARY_INTEGER;
data4 numtab4;
v_cnt number := 1 ;
begin
for i in 1 .. 100000 loop
data1(data1.count +1) := v_cnt + 1;
data2(data2.count +1) := v_cnt + 1;
data3(data3.count +1) := v_cnt + 1;
data4(data4.count +1) := v_cnt + 1;
v_cnt := v_cnt + 1;
--proc_pop_tab (v_var1 ,v_var2,v_var3,v_var4);
end loop;
forall j in 1 ..data1.count
insert into pop_tab
values ( --- How to use the above collection variables here
commit;
exception when others then
DBMS_OUTPUT.PUT_LINE ( 'proc_lvl_load'||sqlcode||','||sqlerrm );
end proc_lvl_ld;
end;Could you please help me out in this and let me know if i'm not clear
Edited by: Smile on Sep 7, 2012 11:37 AMUse:
forall j in 1 ..data1.count
insert into pop_tab
values (data1(j),data2(j),data3(j),data4(j)); Now:
SQL> create or replace package body test_collect
2 is
3 procedure proc_lvl_ld
4 is
5 TYPE numtab1 IS TABLE OF NUMBER (4) INDEX BY BINARY_INTEGER;
6 data1 numtab1;
7 TYPE numtab2 IS TABLE OF NUMBER (4) INDEX BY BINARY_INTEGER;
8 data2 numtab2;
9 TYPE numtab3 IS TABLE OF NUMBER (4) INDEX BY BINARY_INTEGER;
10 data3 numtab3;
11 TYPE numtab4 IS TABLE OF NUMBER (4) INDEX BY BINARY_INTEGER;
12 data4 numtab4;
13 v_cnt number := 1 ;
14 begin
15 for i in 1 .. 100000 loop
16 data1(data1.count +1) := v_cnt + 1;
17 data2(data2.count +1) := v_cnt + 1;
18 data3(data3.count +1) := v_cnt + 1;
19 data4(data4.count +1) := v_cnt + 1;
20 v_cnt := v_cnt + 1;
21 --proc_pop_tab (v_var1 ,v_var2,v_var3,v_var4);
22 end loop;
23 forall j in 1 ..data1.count
24 insert into pop_tab
25 values (data1(j),data2(j),data3(j),data4(j));
26 commit;
27 exception when others then
28 DBMS_OUTPUT.PUT_LINE ( 'proc_lvl_load'||sqlcode||','||sqlerrm );
29
30 end proc_lvl_ld;
31 end;
32 /
Package body created.
SQL> exec test_collect.proc_lvl_ld;
proc_lvl_load-6502,ORA-06502: PL/SQL: numeric or value error: number precision too large
PL/SQL procedure successfully completed.
SQL> Why? You declared associative arrays as NUMBER(4) while values you are trying to assign their elements are in range:
for i in 1 .. 100000 loopIf I change it to:
for i in 1 .. 9998 loopThen:
SQL> create or replace package body test_collect
2 is
3 procedure proc_lvl_ld
4 is
5 TYPE numtab1 IS TABLE OF NUMBER (4) INDEX BY BINARY_INTEGER;
6 data1 numtab1;
7 TYPE numtab2 IS TABLE OF NUMBER (4) INDEX BY BINARY_INTEGER;
8 data2 numtab2;
9 TYPE numtab3 IS TABLE OF NUMBER (4) INDEX BY BINARY_INTEGER;
10 data3 numtab3;
11 TYPE numtab4 IS TABLE OF NUMBER (4) INDEX BY BINARY_INTEGER;
12 data4 numtab4;
13 v_cnt number := 1 ;
14 begin
15 for i in 1 .. 9998 loop
16 data1(data1.count +1) := v_cnt + 1;
17 data2(data2.count +1) := v_cnt + 1;
18 data3(data3.count +1) := v_cnt + 1;
19 data4(data4.count +1) := v_cnt + 1;
20 v_cnt := v_cnt + 1;
21 --proc_pop_tab (v_var1 ,v_var2,v_var3,v_var4);
22 end loop;
23 forall j in 1 ..data1.count
24 insert into pop_tab
25 values (data1(j),data2(j),data3(j),data4(j));
26 commit;
27 exception when others then
28 DBMS_OUTPUT.PUT_LINE ( 'proc_lvl_load'||sqlcode||','||sqlerrm );
29
30 end proc_lvl_ld;
31 end;
32 /
Package body created.
SQL> exec test_collect.proc_lvl_ld;
PL/SQL procedure successfully completed.
SQL> select count(*) from pop_tab
2 /
COUNT(*)
9998
SQL> SY. -
hi all ,
i want to add net value of all the line items which are in the same group
am using collect but am unable to do that.
plz suggest me what to do?
DATA: BEGIN OF del_grp_data occurs 0,
vbeln like vbap-vbeln, " Sales document
grkor like vbap-grkor, " Delivery group
netwr like vbap-netwr, "net value
posnr like vbap-posnr, " Sales document item
End OF del_grp_data.
SELECT vbeln grkor pstyv netwr
posnr
FROM vbap
INTO corresponding fields of TABLE del_grp_data
FOR ALL ENTRIES IN orders_vbeln
WHERE vbeln eq orders_vbeln-vbeln.
loop at del_grp_data.
collect ord_grp_data .
endloop.
Regards,
Amit.Basic form
COLLECT [wa INTO] itab.
Addition:
... SORTED BY f
Cannot Use Short Forms in Line Operations.
Effect
COLLECT allows you to create unique or summarized datasets. The system first tries to find a table entry corresponding to the table key. (See also Defining Keys for Internal Tables). The key values are taken either from the header line of the internal table itab, or from the explicitly-specified work area wa. The line type of itab must be flat - that is, it cannot itself contain any internal tables. All the components that do not belong to the key must be numeric types ( ABAP Numeric Types).
If the system finds an entry, the numeric fields that are not part of the table key (see ABAPNumeric Types) are added to the sum total of the existing entries. If it does not find an entry, the system creates a new entry instead.
The way in which the system finds the entries depends on the type of the internal table:
STANDARD TABLE:
The system creates a temporary hash administration for the table to find the entries. This means that the runtime required to find them does not depend on the number of table entries. The administration is temporary, since it is invalidated by operations like DELETE, INSERT, MODIFY, SORT, ...). A subsequent COLLECT is then no longer independent of the table size, because the system has to use a linear search to find entries. For this reason, you should only use COLLECT to fill standard tables. U
SORTED TABLE:
The system uses a binary search to find the entries. There is a logarithmic relationship between the number of table entries and the search time.
HASHED TABLE:
The system uses the internal hash administration of the table to find records. Since (unlike standard tables), this remains intact even after table modification operations, the search time is always dependent on the number of table entries.
For standard tables and SORTED TABLEs, the system field SY-TABIX contains the number of the existing or newly-added table entry after the APPEND. With HASHED TABLEs, SY-TABIX is set to 0.
Notes
COLLECT allows you to create a unique or summarized dataset, and you should only use it when this is necessary. If neither of these characteristics are required, or where the nature of the table in the application means that it is impossible for duplicate entries to occur, you should use INSERT [wa INTO] TABLE itab instead of COLLECT. If you do need the table to be unique or summarized, COLLECT is the most efficient way to achieve it.
If you use COLLECT with a work area, the work area must be compatible with the line type of the internal table.
If you edit a standard table using COLLECT, you should only use the COLLECT or MODIFY ... TRANSPORTING f1 f2 ... statements (where none of f1, f2, ... may be in the key) enthalten sein). Only then can you be sure that:
-The internal table actually is unique or summarized
-COLLECT runs efficiently. The check whether the dataset
already contains an entry with the same key has a constant
search time (hash procedure).
If you use any other table modification statements, the check for entries in the dataset with the same key can only run using a linear search (and will accordingly take longer). You can use the function module ABL_TABLE_HASH_STATE to test whether the COLLECT has a constant or linear search time for a given standard table.
Example
Summarized sales figures by company:
TYPES: BEGIN OF COMPANY,
NAME(20) TYPE C,
SALES TYPE I,
END OF COMPANY.
DATA: COMP TYPE COMPANY,
COMPTAB TYPE HASHED TABLE OF COMPANY
WITH UNIQUE KEY NAME.
COMP-NAME = 'Duck'. COMP-SALES = 10. COLLECT COMP INTO COMPTAB.
COMP-NAME = 'Tiger'. COMP-SALES = 20. COLLECT COMP INTO COMPTAB.
COMP-NAME = 'Duck'. COMP-SALES = 30. COLLECT COMP INTO COMPTAB.
Table COMPTAB now has the following contents:
NAME | SALES
Duck | 40
Tiger | 20
Addition
... SORTED BY f
Effect
COLLECT ... SORTED BY f is obsolete, and should no longer be used. It only applies to standard tables, and has the same function as APPEND ... SORTED BY f, which you should use instead. (See also Obsolete Language Elements).
Note
Performance:
Avoid unnecessary assignments to the header line when using internal tables with a header line. Whenever possible, use statements that have an explicit work area.
For example, " APPEND wa TO itab." is approximately twice as fast as " itab = wa. APPEND itab.". The same applies to COLLECT and INSERT.
The runtime of a COLLECT increases with the width of the table key and the number of numeric fields whose contents are summated.
Note
Non-Catchable Exceptions:
COLLECT_OVERFLOW: Overflow in an integer field during addition
COLLECT_OVERFLOW_TYPE_P: Overflow in a type P field during addition.
TABLE_COLLECT_CHAR_IN_FUNCTION: COLLECT on a non-numeric field.
Related
APPEND, WRITE ... TO, MODIFY, INSERT
Additional help
Inserting SummarizedTable Lines -
When I first started using Collections, I followed someone's advice and always clicked 'create virtual copy' -- so I now have a huge number of unused/useless VCs that I would like to clear out. Is there any way to 1) filter to show all virtual copies that have not been changed (but keep the ones that I have edited or changed in any way, 2) delete the unchanged virtual copies but keep the collection that holds them intact? I can picture a work-around for the second part by color coding all the unused VCs along with their original, deleting the unedited VCs, going to the folder and selecting all the colored originals, dragging them to the colection and then removing the color lable. Cumbersome, but doable.
Umm no not that i remember. It just randomly started happening. I reformatted the hard drive for mac (journaled) but it was working fine since i did it until now
-
BOM structures in large projects. Use Collective?
Hello All,
I am a little new with this forum. I was a super user in a high volume high mix industry where we used collective production orders quite frequently.
I am now working with highly engineered long term capitol projects.
It looks like a lot of the BOM's are flat and ties to a WBS project number. This makes planning very arduous since we are essentually building components into the routing.
Collective orders since it seems to give order and structure for materials and planning.
I am wondering what similar industries do in this environment. I would welcome any comment regarding the pro's and con's of pushing to change toward using collective more.
Thank YouHi Richard,
please go through the document it may help you little COLLECTIVE ORDER OR DIRECT PRODCUTION - A scenario overview .
Regards,
Venkat. -
When I try to use collect() in a query to try and get a quick and dirty pivot, I get an ORA-00932. Anybody have any suggestions on what could be up? Using 10.2.0.4
select tablespace_name, collect(table_name) as table_name_coll
from all_tables
group by tablespace_name;
Error starting at line 2 in command:
select tablespace_name, collect(table_name) as table_name_coll
from all_tables
group by tablespace_name
Error report:
SQL Error: ORA-00932: inconsistent datatypes: expected NUMBER got -
00932. 00000 - "inconsistent datatypes: expected %s got %s"
*Cause:
*Action:Dylan,
The query works for me. What tool do you use to execute your query? And what is the result when you execute your query in SQL*Plus?
Regards,
Rob. -
Hi
i'm still quite the novice on APEX so bare with me.
my problem is as follows:
I have to develop a page for mass registration of sales, in APEX, and the client would like a tabular form with 20 empty rows in which the client can insert sales data.
i'm developing on apex version 3.0.0.00.20 on a 10g Enterprise Edition Release 10.1.0.5.0 database.
i've tried using collections for the job, but my problem is that i can't get the code to save any changes to the collection??
i've created a on load before header process
that creates a collection named SALGSBUFREG using apex_collection.create_collection_from_query where no rows are returned.
the table i query is the table that the sales data eventually is inserted into.
/** on-load before header process start */
declare
c_coll_name constant varchar2(100) := 'SALGSBUFREG';
c_number_of_rows constant number := 20;
begin
if apex_collection.collection_exists(p_collection_name=>c_coll_name) then
apex_collection.delete_collection(p_collection_name=>c_coll_name);
end if;
apex_collection.create_collection_from_query(
p_collection_name=>c_coll_name,
p_query=>'SELECT varenummer,
antal,
aip_omsaetning,
apotekskode ,
salgsdato,
salgsperiode,
dlibruger_id,
salgsbatch_id,
sygehuskode,
afvist,
indsat,
updateret,
registreringsdato
FROM salgsbuffere
WHERE 1 = 2');
/** create c_number_of_rows empty rows*/
for i in 1 .. c_number_of_rows
loop
apex_collection.add_member (p_collection_name => c_coll_name,
p_c001 => ' ',
p_c002 => ' ',
p_c003 => ' ',
p_c004 => ' ',
p_c005 => null,
p_c006 => ' ',
p_c007 => ' ',
p_c008 => ' ',
p_c009 => ' ',
p_c010 => ' ',
p_c011 => ' ',
p_c012 => ' ',
p_c013 => null
end loop;
end;
/** on-load before header process stop */
i've created a report region called salgs_buf based on the following query:
select c001, c002, c003, c004, c005, c006, c007, c008,c009,c010,c011, c012,c013
from apex_collections
where collection_name = 'SALGSBUFREG'
i've made the report attributes c001 - c005 editable.
finally i've made a on submit - after computations and validations process with the following content:
declare
c pls_integer := 0;
c_coll_name constant varchar2(100) := 'SALGSREGBUF';
begin
for c1 in (
select seq_id from apex_collections
where collection_name = c_coll_name
order by seq_id) loop
c := c+1;
apex_collection.update_member_attribute (p_collection_name=> c_coll_name,
p_seq=> c1.seq_id,p_attr_number =>4,p_attr_value=>wwv_flow.g_f01(c));
apex_collection.update_member_attribute (p_collection_name=> c_coll_name,
p_seq=> c1.seq_id,p_attr_number =>5,p_attr_value=>wwv_flow.g_f02(c));
apex_collection.update_member_attribute (p_collection_name=> c_coll_name,
p_seq=> c1.seq_id,p_attr_number =>6,p_attr_value=>wwv_flow.g_f03(c));
apex_collection.update_member_attribute (p_collection_name=> c_coll_name,
p_seq=> c1.seq_id,p_attr_number =>7,p_attr_value=>wwv_flow.g_f04(c));
end loop;
end;
For some reason the collection dosen't get updated????
any idears why, or am I using the wrong apporach.first off thanks for your help.
I seem to have cracked the nut so to speak, i'm just posting my solution
I've changed the process so that exisisting collections aren't deleted.
/** before header process start**/
DECLARE
c_coll_name CONSTANT VARCHAR2 (100) := 'SALGSBUFREG';
c_number_of_rows CONSTANT NUMBER := 20;
v_row_count_diff NUMBER;
v_row_count NUMBER;
BEGIN
IF NOT apex_collection.collection_exists (c_coll_name)
THEN
apex_collection.create_collection_from_query
(p_collection_name => c_coll_name,
p_query => 'SELECT varenummer,
antal,
aip_omsaetning,
apotekskode,
salgsdato,
salgsperiode,
dlibruger_id,
salgsbatch_id,
sygehuskode,
afvist,
indsat,
updateret,
registreringsdato
FROM salgsbuffere
WHERE 1 = 2'
-- create c_number_of_rows empty rows
FOR i IN 1 .. c_number_of_rows
LOOP
apex_collection.add_member (p_collection_name => c_coll_name,
p_c001 => ' ',
/** vare nr*/
p_c002 => ' ',
/** antal */
p_c003 => ' ',
/** aip_omsaetning*/
p_c004 => ' ',
/** apotekskode */
p_c005 => NULL,
/** salgsdato*/
p_c006 => ' ',
/** salgsperiode */
p_c007 => ' ',
/** dlibruger_id*/
p_c008 => ' ',
/** salgsbatch_id*/
p_c009 => ' ',
/** sygehuskode*/
p_c010 => ' ',
/** afvist*/
p_c011 => ' ',
/** indsat*/
p_c012 => ' ',
/** updateret*/
p_c013 => NULL
/** registrerings dato*/
END LOOP;
-- the empty collection is set to unchanged
apex_collection.reset_collection_changed (c_coll_name);
END IF;
END;
/** before header process stop**/
i've made a on submit and before computation process that populates the collection with the values that i input in the updatable rport region on my page, and it works just fine:
/** on submit and before computation start**/
/* Formatted on 2008/06/11 09:37 (Formatter Plus v4.8.8) */
DECLARE
c_coll_name CONSTANT VARCHAR2 (100) := 'SALGSBUFREG';
c_row_count CONSTANT NUMBER := 20;
v_member_count NUMBER;
BEGIN
IF apex_collection.collection_exists (c_coll_name)
THEN
FOR i IN 1 .. apex_collection.collection_member_count (c_coll_name)
LOOP
apex_collection.update_member_attribute
(p_collection_name => c_coll_name,
p_seq => i,
p_attr_number => 1,
p_attr_value => apex_application.g_f01
(i)
apex_collection.update_member_attribute
(p_collection_name => c_coll_name,
p_seq => i,
p_attr_number => 2,
p_attr_value => apex_application.g_f02
(i)
apex_collection.update_member_attribute
(p_collection_name => c_coll_name,
p_seq => i,
p_attr_number => 3,
p_attr_value => apex_application.g_f03
(i)
apex_collection.update_member_attribute
(p_collection_name => c_coll_name,
p_seq => i,
p_attr_number => 4,
p_attr_value => apex_application.g_f04
(i)
apex_collection.update_member_attribute
(p_collection_name => c_coll_name,
p_seq => i,
p_attr_number => 5,
p_attr_value => apex_application.g_f05
(i)
END LOOP;
END IF;
END;
/** on submit and before computation start**/
Maybe you are looking for
-
Will syncing with iTunes delete all my stuff?
My computer crashed the other day. The HDD was destroyed and I had no choice but to buy a new one and install iTunes again. I still got my 2g Ipod Touch filled with valuable family photos, music and, of course, apps. Nedless to say these are things i
-
Experts, We are in the processing of migrating a Co Cd from Non-SAP system to SAP System and we were planning to take care of the tax thing manually for now and then have it automised. However it looks like when you are doing FB60 - You can enter the
-
Code to get latest purchase requisition
hello, i have to built a report for purchase requisition i got stuck while finding the latest purchase order so how i can solve this problem
-
Hi All Am creating positions and org unit using RH_Object_Create FM and i can see those objid in HRP1000 table but when i come to PP01 it will show me only otype and objid but it will not show that green arrow for object infotype when i use VTA
-
Most recent date (UDATE) from CDHDR table based on CDPOS
Hi, I am working on one object where i stuck with one issue. The requirement is I have to retrieve the most recent date from CDHDR table based on CHANGENR in CDPOS table. Where i am doing FOR ALL ENTRIES on CDPOS table to get the MAX( date )and i got