Record Groups Vs Plsql table
Hi,
In forms, I am storing some values in a plsql table(like an array). Everytime a value is chosen in the filter, I do a sequential search of the table to retrieve my values. As this is a single table the search is taking a long time.I would like to replace this with multiple run time record groups. My question is whether the storing and retrieval from record groups are in any way faster or slower than retrieval from a table? I dont know the exact row number. So I have to do a sequential read of the record group also. So it will be something like :
for i in 1..10 loop
v := get_group_char_Cell('col name',i);
end loop;
Is this faster than
for i in 1..10 loop
v := tab(i).col;
end loop;
Ps: The record group could be smaller than the table as it will be multiple. Table will be always be one.
Thanks in Advance.
Hi ,
I have a filter which has certain values. When the value is chosen, I need to look thru either the table or record group sequentially to get the matched record and apply it. We want to make this process as fast as possible. Hence the question of using plsql table vs record groups vs GLOBAL table. I was given to understand that if the global table is indexed it could be as fast or faster than the plsql table. The advantage in using GLOBAL table might be that I can directly select the value instead of retrieving the entire PLSQL table and compare the values.
EG -
for i in 1..tab.count loop
tab(i).col = val;
end loop
select col into v from GLOBAL_TAB where col1 = val;
So which you think would be faster? Also consider the record groups.
Thanks in Advance.
Similar Messages
-
HOW TO create a temp table or a record group at run time
i have a a tabular form and i dont want to allow the user entering duplicate
records while he is in insert mode and the inserted records are new and not exsisting in the database.
so i want to know how to create a temp table or a record group at run time to hold the inserted valuse and compare if they are exsiting in previous rows or no.
please help!As was stated above, there are better ways to do it. But if you still wish to create a temporary block to hold the inserted records, then you can do this:
Create a non-database block with items that have the same data types as the database table. When the user creates a new record, insert the record in the non-database block. Then, before the commit, compare the records in the non-database block with those in the database block, one at a time, item by item. If the record is not a duplicate, copy the record to the database block. Commit the records, and delete the records in the non-database block. -
Delete last record in plsql table
TYPE r_LOOPElement IS RECORD (TermID NUMBER
TYPE t_LOOPType IS TABLE OF r_LOOPElement INDEX BY BINARY_INTEGER;
i_CustomerLoop t_LOOPType ;
i_CustomerLoop(1).TermID=1;
i_CustomerLoop(2).TermID=2;
i_CustomerLoop(3).TermID=3;based on some conditions, i need to delete the last record from i_CustomerLoop
whichi s the best way to do it. because i will sometimes have duplicate values for TermID in this plsql table.Hi,
See [Deleting Collection Elements (DELETE Method)|http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/collections.htm#CJAFGFIG]
Regards, -
Open cursor for PLSQL table of records
Is it possible to open a cursor for all data in a PLSQL table of records?
something like
cursor c (p1 number) is select * from <plsqltab>
where <plsqltab>.col = p1There is no such thing as a PL/SQL table. Yes, I know that many calls this structure in PL/SQL a table. And that is exactly where all this confusion stems from.. and trying to treat such a "table" as an Oracle table using SQL.
The correct terms are dynamic array (indexed by integer) or dynamic associative array (indexed by varchar). And an array is nothing like a table ito RDBMS processing.
Yes, you can run SQLs against arrays. But it is "expensive". Why? Because the data sits inside PL/SQL Engine. Not in the SQL Engine. The data is in a PL/SQL defined structure. Not a SQL defined structure.
So.. the data needs to be shipped from the PL/SQL Engine to the SQL Engine and converted into a format that the SQL Engine can understand and use.
Also, once shipped and converted the SQL structure is not indexed. Which means that the only option is a full table scan of that structure.
So you need to ask yourself why do you want to use SQL against a PL/SQL array? As soon as you do that, you are saying "Hey, this PL/SQL table ain't good enough and I need to process it using SQL".
So why then does that data sit inside a PL/SQL array and not in a SQL table?
Oracle provides you with the ability to create temporary session tables. These can be indexed. SQL can be run against them without all the "expenses" that are associated with running SQL against a PL/SQL array.
PL/SQL arrays is a great tool. But only when it is the right tool to use. When someone says he/she needs SQL to use this tool, then I question the choice of the tool. Make sure you use the right tool for the job. -
Grouping records in an internal table
Dear all,
Pls follow the code and suggest me to get the specified format.
Consider that i have created a view to populate the reqd data and collect those in an internal table and do a calculation for one field and modify the internal table.
when i pass this internal table to the function reuse_alv_grid , it throws out a report. But if i need to group the records of the internal table based on three fields, can i do that , if so , how should i do that, if not what method shud i adopt to get the grouped listing in ALV.
kindly give your views.
Code goes here..........
select distinct edatu j_3akvgr6 mvgr4 matnr bismt vbeln auart bstkd bstkd_e ihrez_e
bstdk_e bstdk bezei vrvez brgew ntgew volum werks kwmeng j_3asize posnr
INTO CORRESPONDING FIELDS OF TABLE itabdelshd
from ZVDELISHED
where J_3AKVGR6 IN CUSTOMER AND AUART IN ORDTYP
AND BISMT IN STYLE AND MATNR in FGMtrl AND bstdk_e IN PLNDATE
AND J_3ASIZE IN GRIDVAL and werks in plant and mvgr4 in ppmon and
bstkd in cpono and vbeln in Sales.
LOOP AT itabdelshd INTO wadelshd.
select sum( wmeng ) as tqty into wasumqty-tqty
from vbep where edatu = wadelshd-edatu and vbeln = wadelshd-vbeln
and j_3asize = wadelshd-j_3asize.
select sum( lfimg ) as dqty into wasumqty-dqty
from lips where vbelv = wadelshd-vbeln and j_3asize = wadelshd-j_3asize
wadelshd-PLND_QTY = wasumqty-tqty - wasumqty-dqty.
wadelshd-PLND_QTY = wadelshd-wmeng - wadelshd-lfimg.
wadelshd-COLOR = wadelshd-j_3asize(4).
MODIFY itabdelshd FROM wadelshd.
ENDLOOP.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.Dear Jorge,
It is working out, But i need to do the sum for the grouped data, for instance , if the below data is grouped data seen in the alv,
sales ord | color line.Item| Ord.qty | Pld.Qty | Date "
| 0001000551 | 002V | 100 | 6,800.000 | 1,200.000 | 25.09.2006"
| 0001000551 | 002V | 100 | 6,800.000 | 2,500.000 | 25.09.2006"
| 0001000551 | 002V | 100 | 6,800.000 | 3,100.000 | 25.09.2006"
| 0001000551 | 003K | 200 | 3,200.000 | 700.000 | 25.09.2006"
| 0001000551 | 003K | 200 | 3,200.000 | 1,200.000 | 25.09.2006"
| 0001000551 | 003K | 200 | 3,200.000 | 1,300.000 | 25.09.2006"
and if want to sum the the planed qty based on the line.Item Grouping, meaning, can i get the report in the below form.
sales ord | color line.Item| Ord.qty | Pld.Qty | Date "
| 0001000551 | 002V | 100 | 6,800.000 | 6,800.000 | 25.09.2006"
| 0001000551 | 003K | 200 | 6,800.000 | 3,200.000 | 25.09.2006"
what should i do to get this form. -
Difference between empty plsql record and null plsql record
Hi there,
I am kinda getting confused with empty plsql record and null plsql record.
How do I assign plsql record to be empty and to be null?
create type emp_obj as object (enum number, ename varchar2);
CREATE OR REPLACE TYPE emp_type AS TABLE OF emp_obj;
ThanksFirst of all, do not use term PL/SQL record in this context. Record type in PL/SQL is completely different from object type. Secondly, there are 2 states of a nested table:
1. Unintialized:
SQL> create or replace
2 type emp_obj_type as object(enum number, ename varchar2(10));
3 /
Type created.
SQL> create or replace
2 type emp_tbl_type as table of emp_obj_type
3 /
Type created.
SQL> declare
2 v_emp_tbl emp_tbl_type;
3 begin
4 v_emp_tbl.extend;
5 end;
6 /
declare
ERROR at line 1:
ORA-06531: Reference to uninitialized collection
ORA-06512: at line 4
SQL> 2 Empty:
SQL> set serveroutput on
SQL> declare
2 v_emp_tbl emp_tbl_type := emp_tbl_type();
3 begin
4 dbms_output.put_line('Nested table v_emp_tbl has ' || v_emp_tbl.count || ' element(s).');
5 end;
6 /
Nested table v_emp_tbl has 0 element(s).
PL/SQL procedure successfully completed.
SQL> NULL aplies to nested table element, not to nested table itself:
SQL> declare
2 v_emp_tbl emp_tbl_type := emp_tbl_type();
3 begin
4 v_emp_tbl.extend;
5 if v_emp_tbl(1) is null
6 then
7 dbms_output.put_line('Nested table v_emp_tbl first element is NULL.');
8 end if;
9 end;
10 /
Nested table v_emp_tbl first element is NULL.
PL/SQL procedure successfully completed.
SQL> SY. -
Insert statement does not insert all records from a partitioned table
Hi
I need to insert records in to a table from a partitioned table.I set up a job and to my surprise i found that the insert statement is not inserting all the records on the partitioned table.
for example when i am using select statement on to a partitioned table
it gives me 400 records but when i insert it gives me only 100 records.
can anyone help in this matter.INSERT INTO TABLENAME(COLUMNS)
(SELECT *
FROM SCHEMA1.TABLENAME1
JOIN SCHEMA2.TABLENAME2a
ON CONDITION
JOIN SCHEMA2.TABLENAME2 b
ON CONDITION AND CONDITION
WHERE CONDITION
AND CONDITION
AND CONDITION
AND CONDITION
AND (CONDITION
HAVING SUM(COLUMN) > 0
GROUP BY COLUMNS -
How to create APEX report from data in PLSQL table
Hi, I have a procedure that is creating/inserting records into multidimensional pslql table. I want to create a report and graph based on the data stored in plsql table. Can someone please advice how to can I select this data in apex OR point me to any sample code?
Thanks
AaliHi,
try to google something about ORACLE TABLE CAST
SELECT ot.yourcolumn
FROM
TABLE(CAST(yourplsqltablevariable AS userdefinedoracletype)) otE.g.
http://it.toolbox.com/blogs/oracle-guide/using-a-plsql-table-in-sql-11013
Regards,
R. -
Need Help : Urgent : Making one of the record Bold in a Table
Hi Frds,
I am new to OAF.......
I am facing the issue that i have to make one of the record bold in a table...........
By using the query, i m trying to display the payslip
It contains the list of Earnings ,Deductions and NetPay amount..........
this is the part of the query........
select payment_date,element_name,arabic_name,val,balance from
select '0' flag,assignment_id,null payment_date,'Payslip for the Month' element_name,to_char(payment_date,'Month-YYYY')arabic_name,
null val, null balance from xx_payroll_info
where 1 =1
and payment_date = last_day(:2)
and assignment_id = (select assignment_id from xx_people_reporting_info
where person_id = :1)
union all
select '1'flag,assignment_id,payment_date,element_name,arabic_name,
value val,null,balance
from xx_payslip_details_mv
where 1 = 1
and payment_date = last_day(:2)
and earn_deduct = ('E')
and assignment_id in (select assignment_id from xx_people_reporting_info)
union all
select '2' flag,assignment_id,payment_date,'Earnings-Total',null,sum(value) val,null
from xx_payslip_detail_mv
where 1 =1
and payment_date = last_day(:2)
and earn_deduct = 'E'
and assignment_id in (select assignment_id from xx_people_reporting_info
where 1 =1
and person_id = :1 )
group by assignment_id,payment_date
My Requirement is : I have to make the Payslip For the month of , Date, Earnings-Total into Bold..... How can i do this.... plz... help me out in this......
Thanks &Regards,
JayaHi Jaya,
Set CSS Class property as OraDataText for respectiveb column.
OR
/In Controller PR
import oracle.cabo.style.CSSStyle;
CSSStyle customCss = new CSSStyle();
customUnCss.setProperty("text-transform","uppercase");
customUnCss.setProperty("font","bold 16px \"Trebuchet MS\", Verdana, sans-serif");//# -red
OAMessageStyledTextBean styledTextBean =(OAMessageStyledTextBean)webBean.findIndexedChildRecursive("POCommentsItem");
if(styledTextBean!=null)
styledTextBean.setInlineStyle(customUnCss);
Thanks,
Dilip -
How to improve performance using bulk collects with plsql tables or arrays
Hi All,
my procedure is like this
declare
cursor c1 is select ----------------------
begin
assigning to variables
validations on that variables
--50 validations are here --
insert into a table
end;
we have created indexes on primary keys,
i want to use
DECLARE
CURSOR a_cur IS
SELECT program_id
FROM airplanes;
TYPE myarray IS TABLE OF a_cur%ROWTYPE;
cur_array myarray;
BEGIN
OPEN a_cur;
LOOP
FETCH a_cur BULK COLLECT INTO cur_array LIMIT 100;
***---------can i assign cursor data to the plsql table variables or array***
***validate on the pl sql variable as---***
i
nsert into a table
EXIT WHEN a_cur%NOTFOUND;
END LOOP;
CLOSE a_cur;
END;
Edited by: Veekay on Oct 21, 2011 4:28 AMFastest way often is this:
insert /*+append */
into aTable
select * from airplanes;
commit;The select and insert part can even be done in parallel if needed.
However if the oparation is complex or the dataset is very very very very very large or the programmer is decent but not excellent then the bulk approach should be considered. It is often a pretty stable and linear scaling approach.
The solution depends a little on the database version.
LOOP
FETCH a_cur BULK COLLECT INTO cur_array LIMIT 100;
EXIT WHEN a_cur.count = 0;
forall i in a_cur.first.. a_cur.last
insert into aTable (id)
values (a_cur(i));
END LOOP;
...If you have more then one column then you might need a single collection for each column. Other possibilities depend on the db version.
Also: do not exit using a_cur%NOTFOUND. This is wrong! You might loose records from the end of the data set. -
Count the Records in an internal table without a loop.
How do i count the number of records in an internal table without using the loop statement.
The Describe statement give the total no. of records in the internal table.But i want the count of the key fields in the internal table
For eg
Row Field
1 A
2 A
3 A
4 B
5 B
6 C
Count of A = 3
Count of B = 2
Count of C = 1Dilip,
I think isn't posible. Only 3 ideas:
1ª, make other table "table2", similar to your actual table.
table2[] = yourtable[].
delete table2 where key <> 'A'.
describe table table2 lines contA.
But depending the amount of data, you may have problems in performance or memory consumption...
2ª, make other table, only with the keys fields and a count field,
data begin table2
key_field1,
cont type i.
end data.
when you append lines to yourdata, make a collect to this table:
table2-keys = yourtable-keys.
table2-cont = 1.
collect table2.
But only works if you can modify the program where data is appended, and you may be carefull when data is deleted :-(...
3ª if your data if filled in a select, you may fill the table2 of point 2ª, making a similar select but:
select keyfields count( * ) into table table2
from ...
where (the same you have to fill your original table...)
group by keys.
But you have the same problem is data is deleted later...
I hope that any of the three is useful for you...
Edited by: Diego Alvarez on Jan 5, 2010 5:09 PM -
What are record groups for?
hi,
Could anybody tell me what is the main purpose of creating record groups whith statements like: create_group_from_query, populate_group, ...
Every time we want to access any records we can use blocks which are based on tables or views which are in Oracle Data Base. So what is the reason of creating record groups?
please explain my that issue:)
Grzegorzhi grzegorz,
Record Group is one which is used with LOVs and List Items.
for the use of LOV & List items u must have to define record group through whis the List items or LOV is belogs to that group.
A record group built from a query can store records from database tables much like a database view, with the added advantage that the record group is local to Form Builder, rather than existing in the database.
To know more about record group, form builder's help is good way,
Regards
Chandan -
How to get the plsql table data into output cursor
Hi,
Could anybody please help me.
Below is an example of the scenario..
CREATE OR REPLACE PACKAGE chck IS
PROCEDURE getdata(dept_no IN VARCHAR2,oc_result_cursor OUT sys_REFCURSOR);
TYPE get_rec is record (ename varchar2(20),
eno number(12));
TYPE t_recs IS TABLE OF get_rec INDEX BY BINARY_INTEGER;
emp_tab t_recs;
END chck;
CREATE OR REPLACE PACKAGE BODY chck AS
PROCEDURE getdata(dept_no IN VARCHAR2,oc_result_cursor OUT sys_REFCURSOR)
is
BEGIN
select ename, eno
bulk collect into emp_tab
from emp;
open oc_result_cursor for select * from table(emp_tab); -- I believe something is wrong here ....
END;
END chck;
the above package is giving me an error:
LINE/COL ERROR
10/29 PL/SQL: SQL Statement ignored
10/43 PL/SQL: ORA-22905: cannot access rows from a non-nested table
item
let me know what needs to be changed
Thanks
Manjumanjukn wrote:
once i get the data into a plsql table, how to get this plsql table data into the cursor?There is no such thing as a PL/SQL table - it is an array.
It is nothing at all like a table. It cannot be indexed, partitioned, cluster, etc. It does not exist in the SQL engine as an object that can be referenced. It resides in expensive PGA memory and needs to be copied (lock, stock and barrel) to the SQL engine as a bind variable.
It is an extremely primitive structure - and should never be confused as being just like a table.
Its use in SQL statements is also an exception to the rule. Sound and valid technical reasons need to justify why one want to push a PL/SQL array to the SQL engine to run SELECT 's against it. -
Using Global variable in Record Group
Hi,
I have a requirement where in I need to pull a column name from a table and then use that value in the select statement of a record group. I have tried using global variables but it is not working. Here is the record group I would like to use.
RG_DOMAIN is based on LOV_DOMAIN
SELECT :GLOBAL.DOMAIN_COLUMN_NAME, DESCRIPTION FROM
DM_T_DOMAIN_VALUES
WHERE DOMAIN_NAME := BLOCK.ATTRIBUTE;
In the Key-Listval I have a select statement in which does this :
SELECT DOMAIN_COLUMN
INTO :GLOBAL.DOMAIN_COLUMN_NAME
FROM DM_T_DOMAIN_RULES WHERE DOMAIN_NAME = :BLOCK.ATTRIBUTE;
SHOW_LOV('LOV_DOMAIN');
The problem is I am not getting the value I am just getting the Domain_column name. For example for Domain_name 'CALC_TYP' the Domain_column is COLUMN_10 and I just see COLUMN_10 my LOV when I want to see the value of COLUMN_10 from the DM_T_DOMAIN_VALUES table.
I tried using Name_in and Copy but not working. Can anyone suggest a solution?
ThanksFrancois ,
I tried this but I am getting error saying record group does not exist. Can you tell me what should I go in Populate_group... and show_lov..maybe I am doing something wrong?
Declare
LC$Req Varchar2(512) ;
Begin
LC$Req := 'SELECT ' || :GLOBAL.DOMAIN_COLUMN_NAME || ' FROM ....' ;
Create_Group_From_Query( rg_group, LC$Req ) ;
Populate_group(RG_DOMAIN); ?? --- is this correct?
Show_Lov(LOV_DOMAIN) ; -- and is this correct?
End; -
Using plsql tables in select statement of report query
Hi
Anyone have experience to use plsql table to select statement to create a report. In otherwords, How to run report using flat file (xx.txt) information like 10 records in flat files and use this 10 records to the report and run pdf files.
thanks in advance
sureshhi,
u can use the utl_file package to do that using a ref cursor query in the data model and u can have this code to read data from a flat file
declare
ur_file utl_file.file_type;
my_result varchar2(250);
begin
ur_file := UTL_FILE.FOPEN ('&directory', '&filename', 'r') ;
utl_file.get_line(ur_file, my_result);
dbms_output.put_line(my_result);
utl_file.fclose(ur_file);
end;
make sure u have an entry in ur init.ora saying that your
utl_file_dir = '\your directory where ur files reside'
cheers!
[email protected]
Maybe you are looking for
-
With Intel and Nokia working together on a new Mobile OS, where does this put Maemo updates for the n900 in the future? It will start to come out in Q2 2010, so will it work on the n900 as it stands? If tnis post is a cure to your issue, please MARK
-
I got a HDTV LCD TV for X-mas last year and just recently it has been getting this gray line along the top of the display and then the picture gets kinda distorted. I looked all over for information but unfortunately,like normal, I can not get my que
-
I have been rendering out to .mov files using QuickTime conversion out of Final Cut Pro. However, each time I try to import this .mov file as an asset in DVD Studio Pro it gives me an error stating incompatible format. How do I need to be rendering o
-
Firmware - Commonly Asked Questions
When Spiderman 3 was released on Blu-ray disc, a fairly large stir was created when it was discovered that the movie would not work correctly in all Blu-ray players. In most cases, players simply weren’t able to access many of the additional feature
-
Document splitting affecting posting
Hi, While executing the postings through TBB1, getting error "Balancing field Profit Center in line item 001 not filled". Also tried maintaining a default Profit center for the Forex Position account through 3KEH. Pls help..