Managing statistics for object collections used as table types in SQL
Hi All,
Is there a way to manage statistics for collections used as table types in SQL.
Below is my test case
Oracle Version :
SQL> select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
SQL> Original Query :
SELECT
9999,
tbl_typ.FILE_ID,
tf.FILE_NM ,
tf.MIME_TYPE ,
dbms_lob.getlength(tfd.FILE_DATA)
FROM
TG_FILE tf,
TG_FILE_DATA tfd,
SELECT
FROM
TABLE
SELECT
CAST(TABLE_ESC_ATTACH(OBJ_ESC_ATTACH( 9999, 99991, 'file1.png', NULL, NULL, NULL),
OBJ_ESC_ATTACH( 9999, 99992, 'file2.png', NULL, NULL, NULL)) AS TABLE_ESC_ATTACH)
FROM
dual
) tbl_typ
WHERE
tf.FILE_ID = tfd.FILE_ID
AND tf.FILE_ID = tbl_typ.FILE_ID
AND tfd.FILE_ID = tbl_typ.FILE_ID;
Elapsed: 00:00:02.90
Execution Plan
Plan hash value: 3970072279
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 194 | 4567 (2)| 00:00:55 |
|* 1 | HASH JOIN | | 1 | 194 | 4567 (2)| 00:00:55 |
|* 2 | HASH JOIN | | 8168 | 287K| 695 (3)| 00:00:09 |
| 3 | VIEW | | 8168 | 103K| 29 (0)| 00:00:01 |
| 4 | COLLECTION ITERATOR CONSTRUCTOR FETCH| | 8168 | 16336 | 29 (0)| 00:00:01 |
| 5 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 6 | TABLE ACCESS FULL | TG_FILE | 565K| 12M| 659 (2)| 00:00:08 |
| 7 | TABLE ACCESS FULL | TG_FILE_DATA | 852K| 128M| 3863 (1)| 00:00:47 |
Predicate Information (identified by operation id):
1 - access("TF"."FILE_ID"="TFD"."FILE_ID" AND "TFD"."FILE_ID"="TBL_TYP"."FILE_ID")
2 - access("TF"."FILE_ID"="TBL_TYP"."FILE_ID")
Statistics
7 recursive calls
0 db block gets
16783 consistent gets
16779 physical reads
0 redo size
916 bytes sent via SQL*Net to client
524 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
2 rows processed Indexes are present in both the tables ( TG_FILE, TG_FILE_DATA ) on column FILE_ID.
select
index_name,blevel,leaf_blocks,DISTINCT_KEYS,clustering_factor,num_rows,sample_size
from
all_indexes
where table_name in ('TG_FILE','TG_FILE_DATA');
INDEX_NAME BLEVEL LEAF_BLOCKS DISTINCT_KEYS CLUSTERING_FACTOR NUM_ROWS SAMPLE_SIZE
TG_FILE_PK 2 2160 552842 21401 552842 285428
TG_FILE_DATA_PK 2 3544 852297 61437 852297 852297 Ideally the view should have used NESTED LOOP, to use the indexes since the no. of rows coming from object collection is only 2.
But it is taking default as 8168, leading to HASH join between the tables..leading to FULL TABLE access.
So my question is, is there any way by which I can change the statistics while using collections in SQL ?
I can use hints to use indexes but planning to avoid it as of now. Currently the time shown in explain plan is not accurate
Modified query with hints :
SELECT
/*+ index(tf TG_FILE_PK ) index(tfd TG_FILE_DATA_PK) */
9999,
tbl_typ.FILE_ID,
tf.FILE_NM ,
tf.MIME_TYPE ,
dbms_lob.getlength(tfd.FILE_DATA)
FROM
TG_FILE tf,
TG_FILE_DATA tfd,
SELECT
FROM
TABLE
SELECT
CAST(TABLE_ESC_ATTACH(OBJ_ESC_ATTACH( 9999, 99991, 'file1.png', NULL, NULL, NULL),
OBJ_ESC_ATTACH( 9999, 99992, 'file2.png', NULL, NULL, NULL)) AS TABLE_ESC_ATTACH)
FROM
dual
tbl_typ
WHERE
tf.FILE_ID = tfd.FILE_ID
AND tf.FILE_ID = tbl_typ.FILE_ID
AND tfd.FILE_ID = tbl_typ.FILE_ID;
Elapsed: 00:00:00.01
Execution Plan
Plan hash value: 1670128954
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 194 | 29978 (1)| 00:06:00 |
| 1 | NESTED LOOPS | | | | | |
| 2 | NESTED LOOPS | | 1 | 194 | 29978 (1)| 00:06:00 |
| 3 | NESTED LOOPS | | 8168 | 1363K| 16379 (1)| 00:03:17 |
| 4 | VIEW | | 8168 | 103K| 29 (0)| 00:00:01 |
| 5 | COLLECTION ITERATOR CONSTRUCTOR FETCH| | 8168 | 16336 | 29 (0)| 00:00:01 |
| 6 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 7 | TABLE ACCESS BY INDEX ROWID | TG_FILE_DATA | 1 | 158 | 2 (0)| 00:00:01 |
|* 8 | INDEX UNIQUE SCAN | TG_FILE_DATA_PK | 1 | | 1 (0)| 00:00:01 |
|* 9 | INDEX UNIQUE SCAN | TG_FILE_PK | 1 | | 1 (0)| 00:00:01 |
| 10 | TABLE ACCESS BY INDEX ROWID | TG_FILE | 1 | 23 | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
8 - access("TFD"."FILE_ID"="TBL_TYP"."FILE_ID")
9 - access("TF"."FILE_ID"="TBL_TYP"."FILE_ID")
filter("TF"."FILE_ID"="TFD"."FILE_ID")
Statistics
0 recursive calls
0 db block gets
16 consistent gets
8 physical reads
0 redo size
916 bytes sent via SQL*Net to client
524 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
2 rows processed
Thanks,
B
Thanks Tubby,
While searching I had found out that we can use CARDINALITY hint to set statistics for TABLE funtion.
But I preferred not to say, as it is currently undocumented hint. I now think I should have mentioned it while posting for the first time
http://www.oracle-developer.net/display.php?id=427
If we go across the document, it has mentioned in total 3 hints to set statistics :
1) CARDINALITY (Undocumented)
2) OPT_ESTIMATE ( Undocumented )
3) DYNAMIC_SAMPLING ( Documented )
4) Extensible Optimiser
Tried it out with different hints and it is working as expected.
i.e. cardinality and opt_estimate are taking the default set value
But using dynamic_sampling hint provides the most correct estimate of the rows ( which is 2 in this particular case )
With CARDINALITY hint
SELECT
/*+ cardinality( e, 5) */*
FROM
TABLE
SELECT
CAST(TABLE_ESC_ATTACH(OBJ_ESC_ATTACH( 9999, 99991, 'file1.png', NULL, NULL, NULL),
OBJ_ESC_ATTACH( 9999, 99992, 'file2.png', NULL, NULL, NULL)) AS TABLE_ESC_ATTACH)
FROM
dual
) e ;
Elapsed: 00:00:00.00
Execution Plan
Plan hash value: 1467416936
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 5 | 10 | 29 (0)| 00:00:01 |
| 1 | COLLECTION ITERATOR CONSTRUCTOR FETCH| | 5 | 10 | 29 (0)| 00:00:01 |
| 2 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
With OPT_ESTIMATE hint
SELECT
/*+ opt_estimate(table, e, scale_rows=0.0006) */*
FROM
TABLE
SELECT
CAST(TABLE_ESC_ATTACH(OBJ_ESC_ATTACH( 9999, 99991, 'file1.png', NULL, NULL, NULL),
OBJ_ESC_ATTACH( 9999, 99992, 'file2.png', NULL, NULL, NULL)) AS TABLE_ESC_ATTACH)
FROM
dual
) e ;
Execution Plan
Plan hash value: 4043204977
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 5 | 485 | 29 (0)| 00:00:01 |
| 1 | VIEW | | 5 | 485 | 29 (0)| 00:00:01 |
| 2 | COLLECTION ITERATOR CONSTRUCTOR FETCH| | 5 | 10 | 29 (0)| 00:00:01 |
| 3 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
With DYNAMIC_SAMPLING hint
SELECT
/*+ dynamic_sampling( e, 5) */*
FROM
TABLE
SELECT
CAST(TABLE_ESC_ATTACH(OBJ_ESC_ATTACH( 9999, 99991, 'file1.png', NULL, NULL, NULL),
OBJ_ESC_ATTACH( 9999, 99992, 'file2.png', NULL, NULL, NULL)) AS TABLE_ESC_ATTACH)
FROM
dual
) e ;
Elapsed: 00:00:00.00
Execution Plan
Plan hash value: 1467416936
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 2 | 4 | 11 (0)| 00:00:01 |
| 1 | COLLECTION ITERATOR CONSTRUCTOR FETCH| | 2 | 4 | 11 (0)| 00:00:01 |
| 2 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
Note
- dynamic sampling used for this statement (level=2)I will be testing the last option "Extensible Optimizer" and put my findings here .
I hope oracle in future releases, improve the statistics gathering for collections which can be used in DML and not just use the default block size.
By the way, are you aware why it uses the default block size ? Is it because it is the smallest granular unit which oracle provides ?
Regards,
B
Similar Messages
-
Error while doing Bulk Collect to a table type
I'm using a Table type to accumulate resultset from a loop and finally return the records in the table type as a ref cursor to the front end.
But when I'm using Bult collect to insert into the table type object it keeps throwing an error
'PLS-00597: expression 'TAB_CALENDAR_AVAIL_RESULTSET' in the INTO list is of wrong type'. Can someone help me to let me know what could be the reason for this error. I'm not able to proceed further, please help.
Here is the code.
CREATE OR REPLACE PACKAGE hotel
AS
TYPE calendar_cursor IS REF CURSOR;
TYPE type_calendar_avail is RECORD(
HOTEL_ID AVAILABILITY_CALENDAR.hotel_id%TYPE,--varchar2(4), --AVAILABILITY_CALENDAR.hotel_id%TYPE,
AVAIL_DATE AVAILABILITY_CALENDAR.AVAIL_DATE%TYPE ,
TOTAL_COUNT number
TYPE type_calendar_avail_resultset IS TABLE OF type_calendar_avail;
tab_calendar_avail_resultset type_calendar_avail_resultset ; -- declare variable of type type_calendar_avail_resultset
PROCEDURE sp_get_calendar_results (
sallhotelswithavaildate VARCHAR2,
ilengthofstay NUMBER,
sorcowner VARCHAR2,
all_unittypes VARCHAR2, --DBMS_SQL.VARCHAR2S
calendar_resultset OUT calendar_cursor
-- tab_calendar_avail_resultset out type_calendar_avail_resultset
PROCEDURE sp_get_calendar_results (
sallhotelswithavaildate VARCHAR2,
ilengthofstay NUMBER,
-- ivariant NUMBER,
sorcowner VARCHAR2,
all_unittypes VARCHAR2, --DBMS_SQL.VARCHAR2S
calendar_resultset OUT calendar_cursor
AS
sbuf VARCHAR2 (200);
sepr VARCHAR2 (1);
shotelwithdate VARCHAR2 (200);
shotelid VARCHAR2 (10);
savaildate VARCHAR2 (8);
sactualavaildate VARCHAR2 (8);
pos NUMBER;
istart NUMBER;
sstartdate VARCHAR2 (8);
senddate VARCHAR2 (8);
squery VARCHAR2 (32767) := '';
sunittypecond VARCHAR2 (500) := '';
sunitdesccond VARCHAR2 (500) := '';
v_unit_cond a_unit_cond;
tempunitcond VARCHAR2 (50) := '';
BEGIN
istart := 1;
LOOP
tempunitcond := hotel.stringtokenizer (all_unittypes, istart, '|');
IF tempunitcond IS NOT NULL
THEN
v_unit_cond (istart) := tempunitcond;
istart := istart + 1;
END IF;
EXIT WHEN tempunitcond IS NULL;
END LOOP;
sunitdesccond := hotel.get_unit_description_cond (v_unit_cond);
DBMS_OUTPUT.put_line ('unit description : ' || sunitdesccond);
sbuf := sallhotelswithavaildate;
sepr := '|';
istart := 1;
LOOP
shotelwithdate := hotel.stringtokenizer (sbuf, istart, sepr);
EXIT WHEN shotelwithdate IS NULL;
shotelid :=
SUBSTR (shotelwithdate, 1, INSTR (shotelwithdate, ',') - 1);
savaildate :=
SUBSTR (shotelwithdate, INSTR (shotelwithdate, ',') + 1);
squery :=
' SELECT MIN (ad.avail_date) '
|| ' FROM wvo_fonres.fpavail_daily ad'
|| ' WHERE ad.hotel_id = '
|| shotelid
|| ' AND ad.days_left >= '
|| ilengthofstay
|| ' AND ad.avail_date >= '
|| savaildate;
IF UPPER (sorcowner) = 'N'
THEN
squery :=
squery
|| ' AND ad.ORC_TYPE != ''R'' and ad.ORC_TYPE != ''P'' and ad.ORC_TYPE != ''E'' ';
END IF;
squery := squery || ' AND ( ' || sunitdesccond || ') ';
EXECUTE IMMEDIATE squery
INTO sactualavaildate;
DBMS_OUTPUT.put_line ('Actual available Date: ' || sactualavaildate);
hotel.sp_get_startdate_enddate (sactualavaildate,
--ivariant,
sstartdate,
senddate
sunittypecond := hotel.get_unittype_cond (v_unit_cond, sorcowner);
-- execute immediate
squery :=
'select HOTEL_ID, AVAIL_DATE, ' || sunittypecond || ' AS TOTAL_COUNT '
|| ' FROM AVAILABILITY_CALENDAR A '
|| 'WHERE '
|| 'AVAIL_DATE >= '''
|| sstartdate
|| ''' '
|| 'AND '
|| 'AVAIL_DATE <= '''
|| senddate
|| ''' '
||'AND '
|| 'A.HOTEL_ID IN ('
|| shotelid
|| ') '
|| 'AND ('
|| sunittypecond
|| '> 0) '
|| -- where total available count of unit type is greater than 0
' ORDER BY AVAIL_DATE'; --order clause
open calendar_resultset for squery;
fetch calendar_resultset BULK COLLECT INTO tab_calendar_avail_resultset;
istart := istart + 1;
END LOOP;
COMMIT;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
NULL;
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line
(SQLERRM (SQLCODE));
RAISE;
END sp_get_calendar_results;
END hotel;
/1. put tags [co[/b][b]de] and [co[/b][b]de] around your code, so it's readable
B. what does "hotel.get_unittype_cond (v_unit_cond, sorcowner)" actually retun?
and third, try this for the array declaration:
tab_calendar_avail_resultset type_calendar_avail_resultset := type_calendar_avail_resultset ; () ; -
How to use Temporary Table in PL-SQL
In MySQL there is no Temporary table concept.
So for intermediate calculation I have created a table as below
create table SequenceTempTable
SessionId VARCHAR(50),
Sequence VARCHAR(500),
CreatedDate DATE
) ENGINE=MEMORY;
Whenever I invoke a SP, I load the data into SequenceTempTable using Session Id as below
CREATE PROCEDURE `GetSequence`(
IN Start_Date VARCHAR(25),
IN End_Date VARCHAR(25)
BEGIN
SELECT UUID() INTO v_SessionId;
INSERT INTO SequenceTempTable values (v_SessionId,'1,2,5,3',now());
required code
DELETE FROM SequenceTempTable WHERE SessionId = v_SessionId;
COMMIT;
END;
i.e. I have created a table as temporary table (created once),
and load the data using Session Id and once session specific intermediate computation done,
I deleted the session specific data.
Could you give me examples of How to use Temporary table in PL-SQL code with respect to my above example.
Because I have gone through creating Temporary table but I stuck with use in PL-SQL. I mean to say Is there any need of creating table in advance before invoking SP.
And one more thing as in MySQL temp table I created which is using MEMORY engine i.e. this table will always be in MEMORY so there is no need of writing data on disk.
Regards
SanjeevHi Sanjeev
Read about GTT here
http://www.oracle-base.com/articles/8i/TemporaryTables.php
GTT always contains just session specific data. \
In case you want to use the GTT in the same session again you can use option
ON COMMIT PRESERVE ROWS;
Or if it is used just once in the session use can use
ON COMMIT DELETE ROWS;
Do remember that for GTT the data of one session can not be accessed in other session.
Also you can go away with Delete from GTT if not used again in same session.
Regards
Arun -
DESKI Report using Temp tables in MS- SQL server 2005
Hi,
I am trying to create a Free hand SQL DESKI report using temp tables in MS SQL Server-2005, I am using ODBC connection.
When I run the report, I am getting the error
u201CConnection or SQL sentence error (DA0005) No column or data to fetchu201D
Ex:
Select *
into #t1
from region
select * from #t1
drop table #t1
Please help.
Regards,
PratikPratik, the SQL does not seem right. BTW you can only retreive data via Deski Free hand SQL. Also try to use OLE DB connection.
-
Syntax error when creating a user-defined table type in SQL Server 2012
Why am I getting a syntax error when creating a user-defined table type in SQL Server 2014?
CREATE TYPE ReportsTableType AS TABLE
( reportId INT
, questionId INT
, questionOrder INT );
Results:
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'AS'.Hope these posts could help,
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/37a45a9a-ed8c-4655-be93-f6e6d5ef44be/getting-incorrect-syntax-while-creating-a-table-type-in-sql-server-2008-r2?forum=transactsql
Regards, Dineshkumar,
Please Mark as Answer if my post answers your question and
Vote as Helpful if it helps you -
Inserting oracle objects / collection using JDBC
Hi people,
I want to insert objects with collections(nested tables) into oracle database using my java JDBC. I believe there are two ways, one using strong types and the other as weak. I am using the weak types.
This is what I have got so far:
create or replace type town_ty as object(
name varchar2(20)
create or replace type country as object (
name varchar2(20),
towns town_ty
create table country_tab of country_ty;
Can any one kindly give or show me an example how to insert data into the above table using weak typed JDBC?
Thanks very muchHi
You should find what you are looking for in the samples provided here http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/advanced/advanced.html.
HTH
Chris -
Need for garbage collection using Webdynpro Binary Cache?
Dear Sirs,
I am using the Wiki guide, Exporting Table Data Using On-Demand Streams to export table data to Excel. (this is using Webdynpro binary cache)
Everything is working fine, however I would like to check prior to transport to production, if i need to do any garbage collection using this solution.
My biggest fear is if the all the excel files generated are stored forever, thus filling up the disk space or memory and crashing the production server.
Can anyone give me advice ?
best regards,
Jørgen Ruud<b>Hi
Check This URL
Memory Usage
http://help.sap.com/saphelp_nw04/helpdata/en/98/f73c41325fa831e10000000a1550b0/frameset.htm
Resource Management
http://help.sap.com/saphelp_nw04/helpdata/en/15/d73f41d900db2be10000000a1550b0/frameset.htm
Regards
Chandran S</b> -
Need to Improve pefromance for select statement using MSEG table
Hi all,
We are using a select statement using MSEG table
which takes a very long time to run the program which is scheduled in back ground.
Please see the history below.;
1) Previously this program was using SELECT-ENDSELECT statement inside the loop i.e.
LOOP AT I_MCHB.
To get Material Doc. Details
SELECT MBLNR
MJAHR
ZEILE INTO (MSEG-MBLNR,MSEG-MJAHR,MSEG-ZEILE)
UP TO 1 ROWS
FROM MSEG
WHERE CHARG EQ I_MCHB-CHARG
AND MATNR EQ I_MCHB-MATNR
AND WERKS EQ I_MCHB-WERKS
AND LGORT EQ I_MCHB-LGORT.
ENDSELECT.
Endloop.
The program was taking 1 hr for 20 k data
2)The above statement was replaced by ALL ENTRIES to remove the SELECT-ENDSELECT from the loop.
***GET MATERIAL DOC NUMBER AND FINANCIAL YEAR DETAILS FROM MSEG TABLE
SELECT MBLNR
MJAHR
ZEILE
MATNR
CHARG
WERKS
LGORT
INTO TABLE I_MSEG
FROM MSEG
FOR ALL ENTRIES IN I_MCHB
WHERE CHARG EQ I_MCHB-CHARG
AND MATNR EQ I_MCHB-MATNR
AND WERKS EQ I_MCHB-WERKS
AND LGORT EQ I_MCHB-LGORT.
3)After getting the further technical analysis from BASIS team , And with the suggestion to optimize the program by changing the INDEX RANGE SCAN to
MSEG~M.
SELECT MBLNR
MJAHR
ZEILE
MATNR
CHARG
WERKS
LGORT
INTO TABLE I_MSEG
FROM MSEG
FOR ALL ENTRIES IN I_MCHB
WHERE MATNR EQ I_MCHB-MATNR
AND WERKS EQ I_MCHB-WERKS
AND LGORT EQ I_MCHB-LGORT.
At present the program is taking 3 to 4 hrs in back ground .
The table is complete table scan using index
MSEG~M.
Please suggest to improve the performance of this
many many thanks
deepakThe benchmark should be the join, and I can not see how any of your solutions can be faster than the join
SELECT .....
INTO TABLE ....
UP TO 1 ROWS
FROM mchb as a
INNER JOIN mseg as b
ON amatnr EQ bmatnr
AND awerks EQ bwerks
AND algort EQ blgort
And acharg EQ bcharg
WHERE a~ ....
The WHERE condition must come from the select on MCHB, the field list from the total results
you want.
If you want to compare, must compare your solutions plus the select to fill I_MCHB.
Siegfried
Edited by: Siegfried Boes on Dec 20, 2007 2:28 PM -
How do i able to get data for unit price using RSEG table?
Dear All,
How do i able to get data for unit price in RSEG table?Hi Thiru,
Please check the logic in thread http://scn.sap.com/thread/1347964
Hope this helps.
Regards,
Deepak Kori -
How to use Oracle Table Type values in Select Statement.
Hi,
I am fetching initial set of values into Oracle Table of Records Type and want to use list of values in the Select statement.
For example, try something like the following:
TYPE t_record IS RECORD (
ID TABLEA.ID%type,
NO TABLEA.NO%type,
v_record t_record;
TYPE t_table IS TABLE OF v_record%TYPE;
v_table t_table;
-- Code to populate the values in v_table here.
SELEC ID,NO, BULK COLLECT INTO <some other table variabes here> FROM TABLEA
WHERE ID IN v_table(i).ID;
I want to know how to use the values from Oracle Table Type in the Select Statement.Something like this:
create or replace type t_record as object (
id number,
no number
CREATE or replace type t_table AS TABLE OF t_record;
set serveroutput on
declare
v_table t_table := t_table();
v_t1 t_table := t_table();
begin
v_table.extend(1);
v_table(1).ID := 1;
v_table(1).No := 10;
v_table.extend(1);
v_table(2).ID := 2;
v_table(2).ID := 20;
SELEC t_record (ID,NO) BULK COLLECT INTO v_t1
from TableA
FROM TABLEA
WHERE ID IN (select t.ID from table(v_Table) t);
for i in 1..v_t1.count loop
dbms_output.put_line(v_t1(i).ID);
dbms_output.put_line(v_t1(i).No);
end loop;
end;
/Untested!
P;
Edited by: bluefrog on Mar 5, 2010 5:08 PM -
How to use nested table types with XDK
Im using Oracles XDK (xml development kit) to create xml-documents from data in database.4
Problem: I need to use nested tables but when trying to create nested table types I get error: A Table type may not contain a nested table type or VARRAY.
Hope I make myself clear! Are there any solutions or workarounds to this problem?
Help appreciated, thanks!Jesper,
I asked similar question last year (search for Tapsell, you will see my posting). Under 8.1.7 the "nesting" seems restricted to one level down. Thus you cannot create a type using another object that itself includes a nested table. Under Oracle 9, against which most current examples seem based, this limitation is removed making things easier. Under 8.1.7 the workaround I have used is to use the CAST syntax. This is not as neat, but it works. -
Need links for creation varaibles using different processing types....
Hi All,
can you provide me links for creation of variables using diiferent processing types...
it would be grateful if you peovide any links which covers all most all the topics in bi reporting....
Thanks All.Hi,
Pl refer to following link as well
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b0b25093-b548-2e10-0cba-fcac7890585f?QuickLink=index&overridelayout=true
Customer exit for text variables
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes/sdn_oss_bw_bex/~form/handler%7b5f4150503d3030323030363832353030303030303031393732265f4556454e543d444953504c4159265f4e4e554d3d343131313235%7d
http://help.sap.com/saphelp_nw04/helpdata/en/61/579b3c494d8e15e10000000a114084/content.htm
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes/sdn_oss_bw_bex/~form/handler%7b5f4150503d3030323030363832353030303030303031393732265f4556454e543d444953504c4159265f4e4e554d3d313535373530%7d
Thanks and regards
Kiran -
Hi,
i want to read/write from/to a table type in pl sql procedure.
I have this:
in the declaration of package I have:
......more code more code...
type type1 is record ( field1 varchar2(4000), field2 varchar2(4000), filed3 number);
rec type1;
type table_example is table of rec%type index by binary_integer;
...more code more code...
In the body of my package i have a procedure in which i want to write/read into/from table_ex (table_ex is a variable of type table_example;)
How could i do?
Could you all post some code of example (in particular i want to update fields of table_ex)?
Please help.
ThanksHi,
I think you need some package for manage simple task againts your table. It's called package API. I created a package API for example for you (this package it's only a little example):
Example table:
-- Create table
create table TEST
AD_TEST NUMBER(10) not null,
NM_TEST VARCHAR2(30) not null
-- Create/Recreate primary, unique and foreign key constraints
alter table TEST
add constraint PK_TEST_1 primary key (AD_TEST)
using index;Sequence...
-- Create sequence
create sequence SEQ_TEST
minvalue 1
maxvalue 99999999999999999999
start with 1
increment by 1
cache 20;Package API for table test
CREATE OR REPLACE PACKAGE pack_api_test IS
TYPE t_ref_cur IS REF CURSOR;
PROCEDURE proc_ins_test(p_ad_test OUT test.ad_test%TYPE,
p_nm_test IN test.nm_test%TYPE,
p_return OUT NUMBER,
p_message OUT VARCHAR2);
PROCEDURE proc_upd_test(p_ad_test IN test.ad_test%TYPE,
p_nm_test IN test.nm_test%TYPE,
p_return OUT NUMBER,
p_message OUT VARCHAR2);
PROCEDURE proc_sch_test(p_rec_test OUT test%ROWTYPE,
p_ad_test IN test.ad_test%TYPE,
p_return OUT NUMBER,
p_message OUT VARCHAR2);
PROCEDURE proc_lis_test(p_ad_test IN test.ad_test%TYPE,
p_nm_test IN test.nm_test%TYPE,
p_query OUT t_ref_cur,
p_return OUT NUMBER,
p_message OUT VARCHAR2);
END pack_api_test;
CREATE OR REPLACE PACKAGE BODY pack_api_test IS
-- Package constants
P_RETURN_SUCCESFUL CONSTANT NUMBER(4) := 0;
P_RETURN_ERROR CONSTANT NUMBER(4) := 1;
P_MESSAGE_SUCCESFUL CONSTANT VARCHAR2(100) := 'Succesful';
PROCEDURE proc_ins_test(p_ad_test OUT test.ad_test%TYPE,
p_nm_test IN test.nm_test%TYPE,
p_return OUT NUMBER,
p_message OUT VARCHAR2) IS
BEGIN
p_return := P_RETURN_SUCCESFUL;
p_message := P_MESSAGE_SUCCESFUL;
INSERT INTO test a
(a.ad_test,
a.nm_test)
VALUES
(seq_test.NEXTVAL,
p_nm_test)
RETURNING ad_test INTO p_ad_test;
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
p_return := P_RETURN_ERROR;
p_message := 'Record already exists';
WHEN OTHERS THEN
p_return := P_RETURN_ERROR;
p_message := SQLERRM;
END proc_ins_test;
PROCEDURE proc_upd_test(p_ad_test IN test.ad_test%TYPE,
p_nm_test IN test.nm_test%TYPE,
p_return OUT NUMBER,
p_message OUT VARCHAR2) IS
generic_error EXCEPTION;
data_not_updated_error EXCEPTION;
v_rec_test test%ROWTYPE;
BEGIN
p_return := P_RETURN_SUCCESFUL;
p_message := P_MESSAGE_SUCCESFUL;
proc_sch_test(p_rec_test => v_rec_test,
p_ad_test => p_ad_test,
p_return => p_return,
p_message => p_message);
IF p_return <> 0 THEN
RAISE generic_error;
END IF;
UPDATE test a SET a.nm_test = p_nm_test WHERE ad_test = p_ad_test;
IF (SQL%ROWCOUNT = 0) THEN
RAISE data_not_updated_error;
END IF;
EXCEPTION
WHEN generic_error THEN
NULL;
WHEN data_not_updated_error THEN
p_return := P_RETURN_ERROR;
p_message := 'Data not updated';
WHEN OTHERS THEN
p_return := P_RETURN_ERROR;
p_message := SQLERRM;
END proc_upd_test;
PROCEDURE proc_sch_test(p_rec_test OUT test%ROWTYPE,
p_ad_test IN test.ad_test%TYPE,
p_return OUT NUMBER,
p_message OUT VARCHAR2) IS
BEGIN
p_return := P_RETURN_SUCCESFUL;
p_message := P_MESSAGE_SUCCESFUL;
SELECT * INTO p_rec_test FROM test a WHERE a.ad_test = p_ad_test;
EXCEPTION
WHEN NO_DATA_FOUND THEN
p_return := P_RETURN_ERROR;
p_message := 'Record doesn''t exist';
WHEN OTHERS THEN
p_return := P_RETURN_ERROR;
p_message := SQLERRM;
END proc_sch_test;
PROCEDURE proc_lis_test(p_ad_test IN test.ad_test%TYPE,
p_nm_test IN test.nm_test%TYPE,
p_query OUT t_ref_cur,
p_return OUT NUMBER,
p_message OUT VARCHAR2) IS
v_ds_sql VARCHAR2(4000);
BEGIN
p_return := P_RETURN_SUCCESFUL;
p_message := P_MESSAGE_SUCCESFUL;
v_ds_sql := v_ds_sql || 'SELECT * ';
v_ds_sql := v_ds_sql || 'FROM test ';
v_ds_sql := v_ds_sql || 'WHERE 1 = 1 ';
IF (p_ad_test IS NOT NULL) THEN
v_ds_sql := v_ds_sql || 'AND ad_test = ' || p_ad_test || ' ';
END IF;
IF (p_nm_test IS NOT NULL) THEN
v_ds_sql := v_ds_sql || 'AND nm_test like ''' || p_nm_test || ''' ';
END IF;
OPEN p_query FOR v_ds_sql;
EXCEPTION
WHEN OTHERS THEN
p_return := P_RETURN_ERROR;
p_message := SQLERRM;
END proc_lis_test;
END pack_api_test;
/Regards, -
Authorisation check for Object F_BL_BANK using transaction F110
Hi
Can you help me with transaction F110. The object F_BL_BANK has been linked on SU24 to transaction F110. It has also been set for Check/maintain.
There is no authorisation check for this object using F110.
How can we resolve the issue.Hi
We are on 4.6
I linked the object but the program is not doing an authority check The F_BL_BANK object has the following linked to it
. . . Check F_BKPF_BUP Accounting Document: Authorization for Posting Periods
. . . Check/maintain F_BL_BANK Authorization for House Banks and Payment Methods
. . . Check F_KNA1_APP Customer: Application Authorization
. . . Check F_KNA1_BED Customer: Account Authorization
. . . Check F_KNA1_BUK Customer: Authorization for Company Codes
. . . Check F_KNA1_GEN Customer: Central Data
. . . Check F_KNA1_GRP Customer: Account Group Authorization
. . . Check F_LFA1_APP Vendor: Application Authorization
. . . Check F_LFA1_BEK Vendor: Account Authorization
. . . Check F_LFA1_BUK Vendor: Authorization for Company Codes
. . . Check F_LFA1_GEN Vendor: Central Data
. . . Check F_LFA1_GRP Vendor: Account Group Authorization
. . . Check F_PAYR_BUK Check Management: Action Authorization for Company Codes
. . . Check/maintain F_REGU_BUK Automatic Payment: Activity Authorization for Company Code
. . . Check/maintain F_REGU_KOA Automatic Payment: Activity Authorization for Account Type
. . . Check PLOG Personnel Planning
. . . Check P_ABAP HR: Reporting
Ther are more objects but these are the key ones The object also has a custom object in that was build by SAP called ZLSCH Payment method We want the system to do a check on the payment method -
Error while saving for Objective setting using tcode phap_catalog_pa.
while executing tcode phap_catalog_pa, i get the error "Table HRPAD605 is not part of customizing Object PDST T.
However, when I proceeded further to use the catalog, I am not able to make any changes and the error message i get is "Data was not saved Message no. HRHAP00_TEMPLATE003".
I also executed the solution mentioned in previous threads on the same problem i.e. run the program "RHSOBJCH" and executed the adjusting entries but to no avail.
I have SAP_ALL authorization profile assigned to me.
Would be really helpful if someone could share their insights on solutions to rectify this problem.
Regards,
KalpanaHi Kalpana,
Check the configuration whether you have done it correctly or not.
And try to upload one template which is existing on the system. Download it and upload it as a template.
If the problem is still there then it will be some configuration issues.
Thanks & Regards,
Ganesh R K
Maybe you are looking for
-
F4 help Not Working in Portal but working in RSRT and BEx
Hi All, We have a report in which a customized infoobject is used as one of the selection criteria. This field is a navigational attribute of main infoobject. There are other two navigational attributes of this infoobjects as well in the selection cr
-
Newbee - question fpr scripting
Hi, I'm new to scripting Acrobat and JavaScript (besides some Web-JS), but familiar to scripting InDesign (CS to CS3 with AppleScript). Now I'm on the challenge to do some Acrobat scripting. Please let me know, if my problem could basicallybe solved
-
Over the last week I have started to have problems waking up my iMac. The problem occurs randomly with the following symptoms: - the screen stays dark but the hard drive and fan start, with the fan gradually building to a dull roar. I have reset the
-
Problem with blinking chart in tabcontrol
Hello everybody, I'm working with a vi where on several tabs charts are embedded. If a chart of a tab that is not in the foreground is set to blinking, the corresponding chart can be seen on the active tab. Is there a solution to this problem, or is
-
Client/server, applet/server
Hi I have a question about server/client programming in java. I have been programming a shortest path algorithm, but it takes to long time to rune this peace of code on the client. So I want to move it to the server. The client is an applet but also