Would PL/SQL Associative Arrays solve my problem
Hi guys,
I'm new to PL/SQL development really, although i have some limited knowledge that i've relied on for the last couple of years to get by. Anyway, i'll try my best to describe my problem and how i'd like to solution it ...........
I have a table of information that holds a column for decscriptive names of payments and another column holding a difference value, for example :
employee_number | payment_name | difference
00001 | salary | 200.20
00001 | shift | 20.21
00002 | salary | 10.01
00002 | shift | 5.02
00003 | salary | 15.02
00003 | shift | 4.00I'd like to manipulate the way this data is presented, via DBMS_OUTPUT in a summary fashion counting the number of differences between ranges, for example :
payment_name | 0.00 to 10.00 | 10.01 to 100.00 | 100.01 to 99999.99
salary | | 2 | 1
shift | 2 | 1 |I thought it might be possible to use an approach in PL/SQL to mimic this table structure and populate it via a cursor looping through my initial recordset and posting the total count in the associated columns as required. Once the cursor had finished populating the PL/SQL table / array etc i could base my DBMS_OUTPUT on this data.
Or am i completely barking up the wrong tree, would there be a better, more efficient way to solution the problem. I've been reading up on PL/SQL Collections http://docs.oracle.com/cd/B10501_01/appdev.920/a96624/05_colls.htm#19661 but can't really determine is this is a) the correct approach or b) should i try using an associative array, nested table or varray?
Thanks in advance guys, just need a pointer in the right direction.
It sounds like you can just pivot the data
SELECT payment_name,
SUM( CASE WHEN difference BETWEEN 0 and 10 THEN 1 ELSE 0 END ) "0.00 to 10.00",
SUM( CASE WHEN difference BETWEEN 10.01 and 100 THEN 1 ELSE 0 END ) "10.01 to 100.00",
SUM( CASE WHEN difference BETWEEN 100.01 and 99999.99 THEN 1 ELSE 0 END ) "100.01 to 99999.99"
FROM table_name
GROUP BY payment_nameYou can then do whatever you want with the data this query returns.
Justin
Similar Messages
-
PL/SQL Associative Arrays Plus.
Hello, in the next version of ODP.NET support for PL/SQL Associative Arrays of Records ?
Roberto.It's not a direct example of calling a SP that takes a VARRAY of OBJECTs, but it should get you headed down the right path:
http://www.oracle.com/technology/obe/hol08/dotnet/udt/udt_otn.htm
However, for performance reasons you should certainly consider using Associative Arrays even if this means slicing up your RECORDs into multiple arrays of each one containing a field of the RECORD. You can do a performance comparison of this technique vs using VARRAYS with your particular data to see if this is required. -
PL/SQL Associative Array as INPUT Parameter
Hi,
Just wondering if anyone out there has a good example of how to get VB.NET (using ODP.NET 9.2.0.4) to pass an Associative Array as an Input parameter to a stored procedure (not for bulk binds)? Specifically, I'm looking for an example of how a VB Strong Typed Collection would be passed through the PLSQLAssociativeArray Collection Type.
I've managed to get a test to work by passing a 1-D String Array through the ODP.NET layer to the PL/SQL AssociativeArray parameter. But I've had zero success trying to get the Collection from VB through ODP.NET.
Thanks in advance for any help.
Todd.For example, if I wanted to return a list of customer ids and names into A PLSQL Associative Array, how would I do it. I know how to return a list of customer ids into a PLSQL associative aray using the code below but I have to specify the maximum number of elements and the maximum size of each of the elements. Is there any way around this?
Dim prmOutCustomerIdList As New OracleParameter
With prmOutCustomerIdList
.ParameterName = "oCustomerIdList"
.CollectionType = OracleCollectionType.PLSQLAssociativeArray
.OracleDbType = OracleDbType.Varchar2
.Direction = ParameterDirection.Output
.Size = 5
.ArrayBindSize = New Integer(4) {10, 10, 10, 10, 10}
End With -
Need sql query to solve the problem?
Hi,
My table contains data which is mentioned below:
Region
Country
DeviceType
Brand
ModelExt
AttributeGroup
AttributeType
AttributeValue
NULL
NULL
A/V Receiver
Sony
STRD560Z
Input keys order
Input Key name on control panel_key order
Asdfg.1.1
NULL
NULL
A/V Receiver
Sony
STRD560Z
Input keys order
Input Key name on control panel_key order
Input.TV
NULL
NULL
A/V Receiver
Sony
STRD560Z
Input keys order
Input key Name on Display_key Order
ASDFG.1.in
NULL
NULL
A/V Receiver
Sony
STRD560Z
Input keys order
Input key Name on Display_key Order
Input.Tv.IN
NULL
NULL
A/V Receiver
Sony
STRD560Z
Input keys order
Input key Name on Display_key Order
RTYU.1
And i need O/p like
Region
Country
DeviceType
Brand
ModelExt
AttributeGroup
Input Key name on control panel_key order
Input key Name on Display_key Order
NULL
NULL
A/V Receiver
Sony
STRD560Z
Input keys order
Asdfg.1.1
ASDFG.1.in
NULL
NULL
A/V Receiver
Sony
STRD560Z
Input keys order
Input.TV
Input.Tv.IN
NULL
NULL
A/V Receiver
Sony
STRD560Z
Input keys order
RTYU.1
Please help. Req. is urgent.
Regards,
PuneethYou can use the CASE expression to pivot the AttributeType column.
Examples for CASE expression usage:
http://www.sqlusa.com/bestpractices/training/scripts/casefunction/
A second possibility is the PIVOT operator:
http://technet.microsoft.com/en-us/library/ms177410(v=sql.105).aspx
Instead of the COUNT or SUM operators, use MIN or MAX operators.
Kalman Toth Database & OLAP Architect
SQL Server 2014 Database Design
New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014 -
REF CURSOR to Associative Array
I have a procedure that builds up a collection (associative array / index-by table). Is there any way to hand the collection over to ODP.NET without putting the contents into a temporary table? REF CURSOR seems to fit, but I cannot find the syntax to OPEN a REF CURSOR for the collection.
I am trying to turn the GetResourceGroup() a_Resources parameter into a ref cursor in the example below (which, as I understand it, would also hold the collection in memory until the cursor is closed).
Alternatively, is there a direct method? I.e. is it possible to get the collection directly into a DataTable or similar?
Any advice gratefully received,
Peter
TYPE RsrcRow IS RECORD
ResourceId Resource.ResourceId%TYPE,
ResourceName Resource.ResourceName%TYPE
TYPE Resources IS TABLE OF RsrcRow INDEX BY VARCHAR2(80);
PROCEDURE GetResourceGroup(
a_ResourceType IN VARCHAR2,
a_Resources OUT Resources
IS
l_LocalCollection Resources;
BEGIN
GetResourcesByType(a_ResourceType, l_LocalCollection);
-- Return resource set (need to port this to ODP.NET).
a_Resources := l_LocalCollection;
RETURN;
END GetResourceGroup;odp.net does not have collection support right now.
PL/SQL Associative Array should be available in next release (see other forum threads)
1. Support for Varchar2 indexes is unlikely (since OCI does not provide such functionality). Which means you can only return an C style "array" like structure at best.
2. Your 'GetResourceGroup' need to return REF CURSOR (or other primitive type like VARCHAR2), until Associative Array become available.
FB -
Associative Arrays, Indexes vs. Full Table Scans
Hello,
I just started using ODP.Net to connect my .Net Web Service to our Oracle Database. The reason why I switched to ODP.Net is support for arrays. If I wanted to pass in arrays to the procedure I had to pass it in through a varchar2 in a CSV formatted string.
ex. "123,456,789"
So now I'm using ODP.net, passing in PL/SQL Associative Arrays then converting those arrays to nested tables to use within queries.
ex.
OPEN OUT_CURSOR FOR
SELECT COLUMN1, COLUMN2
WHERE COLUMN_ID IN (SELECT ID FROM TABLE(CAST(ASSOC_ARR_TO_NESTED(IN_ASSOC_ARR) AS NESTED_TBL_TYPE)))
It uses the array successfully however what it doesn't do is use the index on the table. Running the same query without arrays uses the index.
My colleague who works more on the Oracle side has posted this issue in the database general section (link below). I'm posting here because it does seem that it is tied to ODP.Net.
performance - index not used when call from service
Has anyone ever experienced this before?You have to use a cardinality hint to force Oracle to use the index:
/*+ cardinality(tab 10) */See How to use OracleParameter whith the IN Operator of select statement -
How do u create a datatable from PLSQL Associative Arrays returned from SP
Using C# 4.0 ODP.NET 11g, vs2010 on Windows XP.
Have a procedure that takes two input values and returns 35 PL\SQL Associative Arrays (pl/sql tables). I am currently able to call the proc and have it returned the values. i end up with 35 arrays each 35 elements in length.
I want to create a datatable from them but am at a lost on how to do so.
This what i have
Oracle.DataAccess.Client.OracleCommand oCommand = new Oracle.DataAccess.Client.OracleCommand();
oCommand.CommandText = ProcName;
oCommand.CommandType = CommandType.StoredProcedure;
//Input Parameters
OracleParameter param1 = oCommand.Parameters.Add("p_orderid",OracleDbType.Int32);
param1.Direction = ParameterDirection.Input;
param1.Value = OrderID;
OracleParameter param2 = oCommand.Parameters.Add("p_testinstanceid", OracleDbType.Int32);
param2.Direction = ParameterDirection.Input;
param2.Value = TestInstanceID;
//Output Parameters
OracleParameter param3 = oCommand.Parameters.Add("program_id", OracleDbType.Int32);
param3.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
param3.Direction = ParameterDirection.Output;
param3.Size = 50;
OracleParameter param4 = oCommand.Parameters.Add("normyear", OracleDbType.Varchar2);
param4.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
param4.Direction = ParameterDirection.Output;
param4.Size = 50;
param4.ArrayBindSize = new int[50];
// set the bind size value for each element
for (int i = 0; i < 50; i++)
param4.ArrayBindSize[i] = 10;
...33 more output parameters all PLSQLAssociativeArray type
oCommand.ExecuteNonQuery();
OracleDataAdapter da = new OracleDataAdapter(oCommand);
//Fill the DataTable
da.Fill(dt);
The datatable is empty. What am i doing wrong? Or this there a better way to get the output values to end up in a datatable. Note that when i examine the parameters in oCommand i see that they all the the right out values.I have multiple where conditions which needs the same subqueryThat is where the Subquery Factoring Clause comes in handy, because then
»Oracle Database optimizes the query by treating the query name as either an inline view or as a temporary table«
with temp as (
subquery
select 1
from table1
where col1 in (select * from temp)
and col2 in (select * from temp)
and col3 in (select * from temp) -
Associative Array problem in Oracle Procedure
Hi,
I've searched through the internet and this forum and haven't been able to resolve a problem using associative array values within an IN clause. Everything I've read states that I can't use the associative array directly in the SQL statement. I have to convert it to a table and then I can use it. Unfortunately, I'm receiving an "ORA-21700: object does not exist or is marked for delete" error when trying to access the table I've populated from the array. Please note that I have verified the table is actually being populated during the loop. I'm catching the error when referencing it in the SELECT statement.
I've declared the following in the ARCHIVE package specification:
TYPE RSType IS REF CURSOR;
TYPE integer_aat IS TABLE OF INTEGER INDEX BY PLS_INTEGER;
TYPE integer_table IS TABLE OF INTEGER;
The procedure is as follows:
PROCEDURE SEL_SEARCH_RESULTS (v_term IN VARCHAR2,
v_categories IN ARCHIVE.integer_aat,
rs OUT RSType)
AS
/* PURPOSE: Return Search Results for the Category and Keyword Provided
VARIABLES:
v_categories = Document Categories array
v_term = Keyword entered
rs = Result Set
tbl_cat ARCHIVE.integer_table := ARCHIVE.integer_table();
BEGIN
FOR i IN 1 .. v_categories.COUNT
LOOP
tbl_cat.EXTEND(1);
tbl_cat(i) := v_categories(i);
END LOOP;
OPEN rs FOR
SELECT A.ID,
B.CATEGORY,
A.FILENAME,
A.DISPLAY_NAME,
A.COMMENTS
FROM TBL_ARCHIVE_DOCUMENTS A,
TBL_ARCHIVE_DOC_CAT B,
TBL_ARCHIVE_DOC_KEYWORDS C
WHERE A.ID = B.ID
AND A.ID = C.ID
AND B.CATEGORY IN (SELECT * FROM TABLE(tbl_cat))
AND C.KEYWORD = v_term
ORDER BY A.ID;
END SEL_SEARCH_RESULTS;
Any help would be greatly appreciated and thanks in advance,
MattThank you for the quick response. I looked at the example you suggested and made the following changes. Now I'm receiving an "Invalid datatype" error on the "SELECT column_value FROM TABLE(CAST(tbl_cat AS tbl_integer))" statement. I must be missing something simple and I just can't put my finger on it.
PROCEDURE SEL_SEARCH_RESULTS (v_term IN VARCHAR2,
v_categories IN ARCHIVE.integer_aat,
rs OUT RSType)
AS
/* PURPOSE: Return Search Results for the Category and Keyword Provided
VARIABLES:
v_categories = Document Categories array entered
v_term = Keyword entered
rs = Result Set
TYPE tbl_integer IS TABLE OF INTEGER;
tbl_cat tbl_integer;
BEGIN
FOR i IN 1 .. v_categories.COUNT
LOOP
tbl_cat.EXTEND(1);
tbl_cat(i) := v_categories(i);
END LOOP;
OPEN rs FOR
SELECT A.ID,
B.CATEGORY,
A.FILENAME,
A.DISPLAY_NAME,
A.COMMENTS
FROM TBL_ARCHIVE_DOCUMENTS A,
TBL_ARCHIVE_DOC_CAT B,
TBL_ARCHIVE_DOC_KEYWORDS C
WHERE A.ID = B.ID
AND A.ID = C.ID
AND B.CATEGORY IN (SELECT column_value FROM TABLE(CAST(tbl_cat AS tbl_integer)))
AND C.KEYWORD = v_term
ORDER BY A.ID;
END SEL_SEARCH_RESULTS; -
i have a for loop inside of while loop.when i press stop for while loop, i also would like to stop for loop.how can i solve this problem?thanks
Hi fais,
Following through with what JB suggested. The steps involved in replacing the inner for loop with a while loop are outlined below.
You can replace the inner for loop with a while by doing the following.
1) Right-click of the for loop and select "Repalce" then navigate to the "while loop".
2) Make sure the tunnels you where indexing on with the for loop are still indexing.
3) Drop an "array size" node on your diagram. Wire the array that determines the number of iterations your for loop executes into this "array size".
4) Wire the output of the array size into the new while loop.
5) Set the condition terminal to "stop if true".
6)Drop an "OR" gate inside the while loop and wire its output to the while loops condition terminal.
7) C
reate a local of the boolean "stop" button, and wire it into one of the inputs of your OR gate. This will allow you to stop the inner loop.
8) Drop a "less than" node inside the inner while loop.
9) Wire your iteration count into the bottom input of the "less than".
10) Wire the count (see step 4 above) into the top input of the less than. This will stop the inner loop when ever the inner loop has processed the last element of your array.
Provided I have not mixed up my tops and bottoms this should accomplish the replacement.
I will let others explain how to takle this task using the "case solution".
Ben
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction -
How to use Associative Array in sql query?
Hello,
I have a problem on using Associative Array variable on query; and my query is similar to the one below;
TYPE OTHERGENERICS IS TABLE OF NUMBER(10) INDEX BY BINARY_INTEGER;
othersGenerics OTHERGENERICS;
CURSOR cursor_othersGenerics IS
select master.GENERICCODEID
from ASMTRG_ARTICLEMASTER master
join ASMTRG_ARTICLEMAP map on MAP.ARTICLECODEID = MASTER.ID
group by MASTER.GENERICCODEID
minus
select FGG.GENERICCODEID
from asmtrg_icfocusgroup fg
join asmtrg_icfocusgrpchannel fgc on FGC.GROUPID = FG.ID and fgc.isactive=1
join asmtrg_icfocusgengroup fgg on FGG.GROUPID = FG.ID and FGg.ISACTIVE=1
where fgc.channelid=1 and fg.isactive = 1
group by FGG.GENERICCODEID;
BEGIN
OPEN cursor_othersGenerics;
FETCH cursor_othersGenerics BULK COLLECT INTO othersGenerics;
CLOSE cursor_othersGenerics;
SELECT icfrd.*,
CASE
WHEN EXISTS(select ta.genericcodeid from <???XXX???> ta where ta.genericcodeid = icfgrp.genericcodeid) THEN -1
ELSE icfrd.icfgroupid
END CLASSIFICATION
FROM ASMTRGVIW_ICFOCUSREPORTDATA icfrd
LEFT JOIN ASMTRG_ICFOCUSGROUP icfgrp on icfrd.ICFGROUPID = icfgrp.ID
WHERE (channelId IS NULL OR icfrd.CHANNELID = channelId)
AND (asmCodeId IS NULL OR icfrd.ASMCODEID = asmCodeId)
AND (yearId IS NULL OR icfrd.YEARID = yearId)
AND (monthId IS NULL OR icfrd.MONTHID = monthId)
END;
By the way this is a part of my function.
The "othersGenerics" is my associative array variable and <???XXX???> is the place where I need to use my "othersGenerics" array to check. So far I've tried
"select ta.genericcodeid from table(cast(otherGenerics as OTHERGENERICS)) ta where ta.genericcodeid = icfgrp.genericcodeid",
"select ta.genericcodeid from table(otherGenerics) ta where ta.genericcodeid = icfgrp.genericcodeid",
"select ta.genericcodeid from otherGenerics ta where ta.genericcodeid = icfgrp.genericcodeid"
and these are not working.
What is your suggestions?Your type will have to be created as an independent object in your schema. So CREATE TYPE cannot be in your function declaration, it has to be outside it. (And then the line inside your declaration that defines the type will have to be removed.)
But now I can see that you use this array as a kind of "temporary lookup table" - you populate the array and then use it for lookup in your select statement. An alternative way of doing this could be like this completely without arrays:
with othergenerics as (
select master.GENERICCODEID
from ASMTRG_ARTICLEMASTER master
join ASMTRG_ARTICLEMAP map on MAP.ARTICLECODEID = MASTER.ID
group by MASTER.GENERICCODEID
minus
select FGG.GENERICCODEID
from asmtrg_icfocusgroup fg
join asmtrg_icfocusgrpchannel fgc on FGC.GROUPID = FG.ID and fgc.isactive=1
join asmtrg_icfocusgengroup fgg on FGG.GROUPID = FG.ID and FGg.ISACTIVE=1
where fgc.channelid=1 and fg.isactive = 1
group by FGG.GENERICCODEID
SELECT icfrd.*,
CASE
WHEN EXISTS(select ta.genericcodeid from othergenerics ta where ta.genericcodeid = icfgrp.genericcodeid) THEN -1
ELSE icfrd.icfgroupid
END CLASSIFICATION
FROM ASMTRGVIW_ICFOCUSREPORTDATA icfrd
LEFT JOIN ASMTRG_ICFOCUSGROUP icfgrp on icfrd.ICFGROUPID = icfgrp.ID
WHERE (channelId IS NULL OR icfrd.CHANNELID = channelId)
AND (asmCodeId IS NULL OR icfrd.ASMCODEID = asmCodeId)
AND (yearId IS NULL OR icfrd.YEARID = yearId)
AND (monthId IS NULL OR icfrd.MONTHID = monthId)
...The with clause (subquery factoring) you can think of as a kind of temp table called othergenerics created "on-the-fly".
The optimizer may decide to actually create a temp table for you and use in the lookup, or it may decide to rewrite the query into suitable joins or nested loops or hashing - whatever the optimizer decides will be the optimal way of doing things :-)
So unless you use your array other places in your function, I would recommend dropping the array completely, skip populating an array, and instead use a with clause for your temporary lookup. -
How can i use one SQL statement to solve problem?
How can i use one SQL statement to solve the question below?
For a Table named A, there is a column named F(char type).
Now select all the records where F like '%00' and update their F value to '%01'
Just one SQL statement.Do not use PL/SQL block.
How to do that?
Thanks.What is the data volume for this table?
Do you expect lots of rows to have '%00' as their value?
Following two statements come to mind. Other experts would be able to provide better alternatives:
If you have index on SUBSTR(f, 2):
UPDATE A
SET f = SUBSTR(f,
1,
length(f) - 2) || '01'
WHERE substr(f,
-2) = '00';If most of the rows have pattern '%00':
UPDATE A
SET f = SUBSTR(f,
1,
length(f) - 2) ||
DECODE(SUBSTR(f,
-2),
'00',
'01',
SUBSTR(f,
-2)); -
Associative array related problem
Hi All,
When I am trying to use assotiative array in a select statement I recieve the following error:
ORA-06550: line 9, column 22:
PLS-00201: identifier 'COL1' must be declared
ORA-06550: line 9, column 22:
PLS-00201: identifier 'COL1' must be declared
ORA-06550: line 9, column 10:
PL/SQL: ORA-00904: : invalid identifier
ORA-06550: line 9, column 3:
PL/SQL: SQL Statement ignored
Here is the example
--create table MyTable (col1 varchar2(255), col2 varchar2(255))
declare
type m_ttMyTable
is table of MyTable%rowtype index by MyTable.col1%type;
m_tMyTable m_ttMyTable;
m_sCol2 varchar2(255);
begin
select m_tMyTable (col1).col2 /* works with ocntant: select m_tMyTable */('col1').col2
into m_sCol2
from MyTable
where rownum = 1;
end;
--drop table MyTableAny ideas how to workaround this?
ThanksThe only collection types SQL can query are ones defined in SQL using CREATE TYPE. That excludes associative arrays, as they are PL/SQL-only constructs. I'd recommend a nested table collection.
Some more suggestions:
www.williamrobertson.net/documents/collection-types.html -
Associative Array (Object) problems
Here is the function i'm dealing with
i'm reading in a delimited string and using indexed arrays to
break them up and assign the keys and values to an associative
array in a loop.
i'm using variables in the loop and the array loads as
expected in the loop
but outside the loop, the only key is the variable name and
the value is undefined
this is true using dot or array notation, as well as literal
strings for the keys
any help is appreciated
watchSuspendData = function (id, oldval, newval):String {
//the incoming suspendData string is delimited by the
semicolon;
//newval is: firstValue=Yes;captivateKey=1
var listSuspendData:Array = newval.split(";"); // convert it
to a list of key/value pairs
if (listSuspendData.length > 0){
//line 123: listSuspendData.length is: 2
for (i=0; i < listSuspendData.length; i++){ //for each
key/value pair
var keyValArray:Array = new Array();
var myNameValue:String = listSuspendData
//line 127: listSuspendData is: firstValue=Yes
keyValArray = myNameValue.split("="); // split 'em on the
equal sign
var myKey:String = keyValArray[0];
var myVal:String = keyValArray[1];
//keyValArray[0] is: firstValue
//keyValArray[1] is: Yes
// store the key and the value in associative array
suspendDataArray.myKey = myVal;
trace("line 134: suspendDataArray is: " +
suspendDataArray.myKey);
// trace is line 134: suspendDataArray is: Yes on the first
pass and 1 on the second
//the below loop always returns one array key: myKey and the
value as undefined
for(x in suspendDataArray){
trace("x is: " + x); //x is: myKey
trace("the val is: " + suspendDataArray.x); //the val is:
undefined
} //end for
return newval;on lines 12-13 i assign the key=value pair to string
variables
then on lines 17-18 i assign those values to the associative
array using dot notation
the trace seems to work there
the problem is that when the procedure exits the for loop,
the associative array only has one key (myKey) and no value
(undefined)
all the documentation i've read shows using these types of
arrays with either non-quoted property names like:
myAssocArray.myKey = "somevalue";
or
myAssocArray[myKey] = "somevalue";
i tried assigning the key/value pairs directly from the
indexed arrays, but the result was always undefined
like this:
suspendDataArray.keyValArray[0] = keyValArray[1]
or
suspendDataArray[keyValArray[0]] = keyValArray[1]
i even tried building a string in the loop and trying to
assign all the pairs at once using the curly brace
this is pretty wierd behavior for actionscript or i'm missing
something basic here
thanks for looking -
Returning collection-associative array from pl-sql procedure
CREATE OR REPLACE procedure test_ganesh( p_deptno IN number,gana out PARTIES_RESULT)
is
query varchar2(200);
PARTY_ID varchar2(200);
PARTY_CODE varchar2(200);
PARTY_NAME varchar2(200);
PARTY_SEQ VARCHAR2(200);
counter number;
TYPE PARTIES IS TABLE OF varchar2(2000) index by binary_integer;
txn_parties PARTIES;
type PARTIES_RESULT IS TABLE OF PARTIES index by binary_integer;
total_result PARTIES_RESULT;
TYPE EmpTyp IS REF CURSOR;
p_du EmpTyp;
p_cursor EmpTyp;
global_counter number;
begin
global_counter:=1;
counter:=1;
open p_cursor FOR
select A.ref_no
from ot_lc_txn_details A
where rownum <12;
LOOP
FETCH p_cursor INTO query;
EXIT WHEN p_cursor%NOTFOUND;
counter:=1;
open p_du FOR
select party_id,party_code,seq_no,party_name from ot_txn_party where ref_no=query;
LOOP
FETCH p_du INTO PARTY_ID,PARTY_CODE,PARTY_SEQ,PARTY_NAME;
EXIT WHEN p_du%NOTFOUND;
txn_parties(counter):=PARTY_ID || '&&&' || PARTY_CODE || '&&&'||PARTY_SEQ || '&&&' || PARTY_NAME;
counter:=counter+1;
END LOOP;
CLOSE p_du;
total_result(global_counter):=txn_parties;
global_counter:=global_counter+1;
END LOOP;
CLOSE p_cursor;
--open gana FOR SELECT * FROM table(cast(total_result as PARTIES_RESULT)) ;
end;
The error comes at line one, PLS-00905- object PARTIES_RESULT is invalid.
i have used the create type thing to create this type.
if i remove the out parameter it works, no compilation error.
Questions i) How to return the associative array as out parameter?
ii)Am i doing aynthing qrong here?
iii) Can i open a ref cursor to this associative array and then return that ref_cursor?
Please anyone reply back, Thanks in advance
Message was edited by:
user649602As an example:
SQL> create type PARTIES is table of varchar2(2000);
2 /
Type created.
SQL> create or replace procedure proc1(p_deptno number,gana out parties) as
2 begin
3 select ename
4 bulk collect into gana
5 from emp
6 where deptno = p_deptno;
7 end;
8 /
Procedure created. -
i just updated my latest java but the update is causing problems with some external devices. So i would like to uninstall this latest java update and get back the previous one. That should solve to problems with my external device.
Is this possible and how do i do that?
Anyone who responds thanks for that!
Juko
I am running
Hardware Overview:
Model Name: Mac Pro
Model Identifier: MacPro1,1
Processor Name: Dual-Core Intel Xeon
Processor Speed: 2,66 GHz
Number of Processors: 2
Total Number of Cores: 4
L2 Cache (per Processor): 4 MB
Memory: 6 GB
Bus Speed: 1,33 GHz
Boot ROM Version: MP11.005D.B00
SMC Version (system): 1.7f10
Serial Number (system): CK7XXXXXXGP
Hardware UUID: 00000000-0000-1000-8000-0017F20F82F0
System Software Overview:
System Version: Mac OS X 10.7.5 (11G63)
Kernel Version: Darwin 11.4.2
Boot Volume: Macintosh HD(2)
Boot Mode: Normal
Computer Name: Mac Pro van Juko de Vries
User Name: Juko de Vries (jukodevries)
Secure Virtual Memory: Enabled
64-bit Kernel and Extensions: No
Time since boot: 11 days 20:39
Message was edited by HostJava 6 you can't as Apple maintains it, and Java 7 you could if you uninstall it and Oracle provides the earlier version which they likely won't his last update fixed 37 remote exploits.
Java broken some software here and there, all you'll have to do is wait for a update from the other parties.
Maybe you are looking for
-
I have three different libraries. How can I combine them?
Downloading more music onto my Mac, but they show up in different libraries on my ipod. Is there a way to combine the libraries? Thanks
-
Problem with CS3 Master Collection on new Box & WinXP
I just got a new computer, specs given bellow, that I just installed CS3 Master Collection. The installation was reported as successful but when I try to run any of the CS3 programs (Flash, Photoshop, etc) the process starts (I checked this with Wid
-
Can send but not receive comcast emails with Verizon MIFI jetpack
I am unable to receive comcast email using outlook 2007 using my new Verizon MIFI4620L Jetpack. When I disconnect from the Jetpack, I am able to receive emails using my neighbor's wireless router. I am able to send email using the MIFI Jetpack. When
-
Trouble creating a MS Word doc
I am trying to dynamically create a MSWord document: <cfheader name="Content-Disposition" value="attchment; filename=coordSheet.doc"> <cfcontent type="application/msword"> Text here. It opens word fine, but when I go to save as, it saves as .htm even
-
Is there any way to take away this symbol?
I have a spreadsheet with many different formulas, I fill out the spreadsheet every week and the meantime the spreadsheet does not contain the information Have it this symbol it's looks messy,