Associative array declaration Inline?
I would like to declare an associative array with the keys based on the constants using the method inline.
The documentation shows inline declarations of associative array as follows:
var assocArray:Array = {key: "value", key2: "Value2", key3: "Value3"};
the problem here is that the following does not work:
var assocArray:Array = {this.const1: "value", this.const2: "value2", this.const3: "value3"};
To work around this problem, I had to do the following so far:
var assocArray:Array = new Array();
assocArray [this.const1] = 'value ';
assocArray [this.const2] = 'value2 ';
assocArray [this.const3] = "Value3";
How can this be done online?
It cannot be done online.
Tags: Flex
Similar Questions
-
Declaring constant in an associative array
Hi all
is it possible to declare constants on associative array without using a constructor function of a package? Just curious...
Best regards
ValValerie Debonair wrote:
In this case, Init_My_AA is the constructor for the My_AA associative array type. I was wondering if we can achieve the same thing without create such constructor.
It is not a constructor. A constructor is called when the object/variable is created.
The function is simply just that - a function that returns a scalar (not) of a specific data type. Its output is assigned as the value of a constant.
And no - I don't think there is another way to initialize a constant of this type of data.
Consider the following data types and initialization of a value of that type:
create or replace type TNumbers is table of number; / declare type TNumArray is table of number; type TNumAss is table of number index by pls_integer; numList TNumbers := TNumbers(1,2,3,4,5,6,7); numArray TNumArray := TNumArray(1,2,3,4,5,6,7); numAss TNumAss := TNumAss( ???? ); --// what are the parameters for the type? begin DBMS_OUTPUT.put_line( numList.Count ); DBMS_OUTPUT.put_line( numArray.Count ); DBMS_OUTPUT.put_line( numAss.Count ); end; /
The collection both normal table allows you to easily make reference to this definition of data type and initialize it (not scalar) value of this type.
PL/SQL lacks syntax (that I know of) to do the same thing with a type of associative array data more complex. And for this reason, you must use a user-defined function to create each element of the array via an individual code or transfer statement.
-
How to: compare 2 associative arrays element-by-element
After playing, I decided to go with the approach of the two sets of data of their own associative array. The code and the results of this are below. My question is the comparison. For each element within the matrix of order, check all the items in the details table to see if there's a football game. If there is a match > > > move to the next item in the control panel and check all the items in the details table to see if there is a football game. Go until the whole is considered to be a match (in number of rows and values). If no match, take the exit.
Below, you'll see my logic to get both sets of data into their respective tables. The results with a note attached to one of the elements is also pasted here (hereinafter the code).
DECLARE
TYPE details_t () IS RENDERING
SIDE AUTO_RECIPE_DETAILS. SIDE % TYPE.
REF_DES AUTO_RECIPE_DETAILS. REF_DES % TYPE,
PART_NUM AUTO_RECIPE_DETAILS. PART_NUM % TYPE
);
TYPE details_type IS TABLE OF details_t INDEX OF AUTO_RECIPE_DETAILS. PART_NUM % TYPE;
details_recipe details_type;
pid_recipe details_type;
compare_result details_type;
CURSOR details_cur
IS
SELECT A FACE, REF_DES, PART_NUM
OF AUTO_RECIPE_DETAILS
WHERE RECIPE_NAME =' 40617-000001;
CURSOR pid_cur
IS
SELECT cl. SIDE, lacpa. REF_DES, NVL(oecl.COMPONENT_ID, 'NOT APPLIED') AS PART_NUM
OF ORDER_ERP_COMPS_LIST lacpa
RIGHT OUTER JOIN CAD_LOCS cl
ON cl. REF_DES = LACPA. REF_DES
WHERE lacpa. ORDER_NUM = "PSY142420."
AND CL. FAB = '38112';
counter_d number (10): = 0;
counter_p number (10): = 0;
comp_counter number (10): = 0;
BEGIN
FOR rec IN details_cur
LOOP
counter_d: = counter_d + 1;
details_recipe (counter_d). SIDE: = rec. SIDE;
details_recipe (counter_d). REF_DES: = rec. REF_DES;
details_recipe (counter_d). PART_NUM: = rec. PART_NUM;
END LOOP;
FOR rec IN pid_cur
LOOP
counter_p: = counter_p + 1;
pid_recipe (counter_p). SIDE: = rec. SIDE;
pid_recipe (counter_p). REF_DES: = rec. REF_DES;
pid_recipe (counter_p). PART_NUM: = rec. PART_NUM;
END LOOP;
-for each pid_recipe element, double-check each record in details_recipe to see if there is an item matching (record)...
FOR indx_d IN details_recipe. FIRST... details_recipe. LAST
LOOP
DBMS_OUTPUT. Put_line (details_recipe (indx_d). SIDE | ', ' || details_recipe (indx_d). REF_DES | ', ' || details_recipe (indx_d). PART_NUM);
END LOOP;
DBMS_OUTPUT. PUT_LINE ('IN THE SECOND PART OF IT!');
FOR indx_p IN pid_recipe. FIRST... pid_recipe. LAST
LOOP
DBMS_OUTPUT. Put_line (pid_recipe (indx_p). SIDE | ', ' || pid_recipe (indx_p). REF_DES | ', ' || pid_recipe (indx_p). PART_NUM);
END LOOP;
END;
/
RESULT:
DETAILS TABLE
RECIPE FOR THE DETAILS TABLE:
B, R28, 34315-26R7
B, R38, 34315-4990
B, R40, 34152-1R60
B, R45, 34315-1002
B, R46, 34315-3011
B, R48, 34152-1004
B, R55, 34315-5901
B, R64, NOT APPLIED
B, R77, 34315-4992
CONTROL PANEL
THE RECIPE IS CALCULATED IN THE ORDER ITSELF:
B, C01, 39412-334 / / for that one single item-> check all the items from the table (above) details Table and see if an element matches. Move to the next item if there is a match...
B, C02, 39412-334
B, C03, NOT APPLIED
T, C11, 27249-105
T, C13, 35404-104
T, C14, 27531-224
T, C15, 35404-104
T, C18, 27249-105
T, C19, 27531-224
CHANGED:
THIS... is the solution to my original question. I had a little mistake that I set between this and my last post with this code. Just in case a person who could use an example like that falls on this thread.
FOR index_p IN pid_recipe. FIRST... pid_recipe. LAST
LOOP
Result WHEN the OUTPUT = 1;
FOR index_d IN details_recipe. FIRST... details_recipe. LAST
LOOP
IF (pid_recipe (index_p). SIDE = details_recipe (index_d). SIDE)
AND (pid_recipe (index_p). REF_DES = details_recipe (index_d). REF_DES)
AND (pid_recipe (index_p). PART_NUM = details_recipe (index_d). PART_NUM)
THEN
EXIT;
ON THE OTHER
DBMS_OUTPUT. Put_line("IT WAS NOT a MATCH");
result: = 1;
EXIT;
END IF;
END LOOP;
END LOOP;
DBMS_OUTPUT. Put_line('LOOP OUT');
-
Using associative arrays in query
Hi all
Please see my schedule. It works very well
[CODE]
DECLARE
type mechanics_type_tab is table of index varchar2 (15) by varchar2 (15);
l_mechanics_type mechanics_type_tab;
L_BULLETIN t_tfo_wf_varchar_table:=t_tfo_wf_varchar_table();
l_count pls_integer: = 0;
BEGIN
FOR I IN (select bulletin_id, mechancs_type_id
of TFO_BULLETIN_PROMO_MECHANICS
where mechancs_type_id is not null) LOOP
l_count: = l_count + 1;
l_mechanics_type (i.bulletin_id): = i.mechancs_type_id;
l_mechanics_type (i.mechancs_type_id): = i.mechancs_type_id;
L_BULLETIN.extend;
L_BULLETIN (l_count): = i.bulletin_id;
END LOOP;
FOR J IN (SELECT TABLE COLUMN_VALUE (L_BULLETIN)) LOOP - this will change
DBMS_OUTPUT. Put_line ('COLUMN_VALUE =' | l_mechanics_type (J.COLUMN_VALUE));
END LOOP;
/ * does not
Insert into test_table (test1)
SELECT values l_mechanics_type (COLUMN_VALUE) OF TABLE (L_BULLETIN); */
END;
[/ CODE]
instead of the code below:
FOR J IN (SELECT TABLE COLUMN_VALUE (L_BULLETIN)) LOOP - this will change
DBMS_OUTPUT. Put_line ('COLUMN_VALUE =' | l_mechanics_type (J.COLUMN_VALUE));
END LOOP;
When I did as below
[CODE]
insert into test_table (test1) to
SELECT values l_mechanics_type (COLUMN_VALUE) OF TABLE (L_BULLETIN);
[/ CODE]
It does not work. Why it does not work.
Please note that in the real-world scenario, there are several fields to insert for test_table and test1 is one of them.
Just because the associative arrays are not supported in SQL before ORACLE 12 c.
HTH
-
I have a table proj_test .i want to recover the data in the associative array.
How to do?
create table proj_test as select 1 as id, 1 as rn, 'Fred' as nm from dual union all select 1,2,'Bloggs' from dual union all select 2,1,'Scott' from dual union all select 2,2,'Smith' from dual union all select 3,1,'Jim' from dual union all select 3,2,'Jones' from dual
You need not Associative array if you do a bulk of collect. You can use the nested PL/SQL table type.
11g and more
declare
is of type tbl table of the proj_test % rowtype;
tbl l_tbl;
Start
SELECT id, rn, nm bulk collect into l_tbl
of proj_test;
because me in 1.l_tbl.count
loop
dbms_output.put_line
(
RPAD (to_char (l_tbl (i) USER.USER), 10, ' ')
|| RPAD (to_char (l_tbl (i). (RN), 10, ' ')
|| l_tbl (i) .nm
);
end loop;
end;
Before 11 g
declare
type id_tbl is table of the proj_test.id%type;
type rn_tbl is table of the proj_test.rn%type;
type nm_tbl is table of the proj_test.nm%type;
id_tbl l_id;
l_rn rn_tbl;
l_nm nm_tbl;
Start
SELECT id, rn, nm bulk collect into l_id, l_rn, l_nm
of proj_test;
because me in 1.l_id.count
loop
dbms_output.put_line
(
RPAD (to_char (l_id (i)), 10, ' ')
|| RPAD (to_char (l_rn (i)), 10, ' ')
|| l_nm (i)
);
end loop;
end;
-
Cannot run the autonomous block for input of associative array parameter
Hello
I have created an associative array in a package-PKG_CMT_DAP
TYPE r_supply_type_id IS RECORD( supply_type_id varchar2(50)); TYPE t_supply_type_id IS TABLE OF r_supply_type_id INDEX BY BINARY_INTEGER; l_supply_type_id t_supply_type_id;
Later created a test procedure with an input of the above kind parameter
create or replace procedure test_prc(p_in_st_id IN PKG_CMT_DAP.t_supply_type_id) AS v_input1 number; v_input2 number; BEGIN FOR z IN 1..p_in_st_id.COUNT LOOP DBMS_output.put_line(p_in_st_id(z)supply_type_id); END LOOP; END test_prc;
How to update successfully.
Created a stand-alone as block below
DECLARE BEGIN test_prc(p_in_st_id=>(100,200,300)); END;
Above am past in 100,200,300 as an input string, and the expected output should display all the numbers above on the screen.
But it throws the below error
Error report: ORA-06550: line 3, column 1: PLS-00306: wrong number or types of arguments in call to 'TEST_PRC' ORA-06550: line 3, column 1: PL/SQL: Statement ignored 06550. 00000 - "line %s, column %s:\n%s" *Cause: Usually a PL/SQL compilation error. *Action:
Could you please help me where I am doing wrong?
Kind regards
Claudy Kotekal
Claudy,
While calling the procedure, you must declare the variable of type table. Give the values for the elements in the begin block and then pass that variable in the procedure. Something like below:
Declare
in_array PKG_CMT_DAP. r_supply_type_id;
Begin
in_array (1) .supply_type_id: = 100;
in_array (2) .supply_type_id: = 200;
in_array (3) .supply_type_id: = 300;
test_prc (in_array);
end;
NOTE: There might be a few problems with my code syntax, but logic would be same.
Try this and let me know.
Thank you
-
An associative array, how the records using the loop counter?
In the associative array, how the records using the loop counter? for example
declare type population is table of number index by varchar2(64); city_population population; begin city_population('Samillve') := 200; city_population('Lindenhurst') := 300; for i in 1 .. city_population.count loop dbms_output.put_line(city_population(i)); -- compiler error end loop; end; /
That would look like
SQL> ed Wrote file afiedt.buf 1 declare 2 type population is table of number index by varchar2(64); 3 city_population population; 4 l_index varchar2(64); 5 begin 6 city_population('Samillve') := 200; 7 city_population('Lindenhurst') := 300; 8 l_index := city_population.first; 9 while( l_index IS NOT NULL ) 10 loop 11 dbms_output.put_line(city_population(l_index )); 12 l_index := city_population.next(l_index); 13 end loop; 14* end; SQL> / 300 200 PL/SQL procedure successfully completed.
Justin
-
Quoting docs.oracle.com lines
Associative arrays are used to represent sets of data of arbitrary size, with quick search of an individual element without its position in the table and without
having to loop through all the elements in the array. Here is a small example
DECLARE
TYPE population_type IS TABLE OF NUMBER INDEX OF VARCHAR2 (64);
country_population population_type;
continent_population population_type;
howmany NUMBER;
that VARCHAR2 (64);
BEGIN
country_population ('Greenland'): = 100000; -Creates the entry
country_population ('Iceland'): = 750000; -Creates the entry
-Research associated with a value chain
howmany: = country_population ('Greenland');
continent_population ('Australia'): = 30000000;
continent_population ('Antarctica'): = 1000; -Creates the entry
continent_population ('Antarctica'): = 1001; -Replaces the previous value
-Returns "Antarctic" which comes first in alphabetical order.
who: = continent_population. FIRST;
-Returns "Australia", which comes last in the alphabetical order.
who: = continent_population. LAST;
-Returns the value corresponding to the last key, in this
-case of the Australia population.
howmany: = continent_population (continent_population. LAST);
END;
/
my doubt is in what regards the statement "with a quick search of an individual element without its position in the table".can someone give a small relevant example. Therefore the associative arrays is also appropriate for relatively small lookup tables where the collection can be constructed in memory eachtime, a procedure is called? Thanks in advance...>
my doubt is in what regards the statement "with a quick search of an individual element without its position in the table".can someone give a small relevant example.
>
Think of it as gradually close equivalent to a hash of key/value pairs. When you want to insert an item provide you the key, Oracle axe key to find the entry in the hash table. It doesn't matter if the entry is the first, last, or any other arbitrary position in the table.
>
Therefore the associative arrays is also appropriate for relatively small lookup tables where the collection can be constructed in memory eachtime, a procedure is called?
>
The scope of the variables of the procedure is only the duration of the procedure. They are built when the procedure is called and destroyed when the procedure ends.If any associative array created in the procedure must be small to minimize the impact on the performance of the table fill. If the procedure performs complex calculations or ETL one record at a time, it is more efficient to get a value from the array instead of having to re - query a database table for him.
For example, for the United States, a list of 50 State and their full name abbreviations that can be stored in an associative array and procedure could extract the code of the State of a data element, and quickly find the name of the State of the table. It would be faster than executing a query on the database on a lookup table.
-
What is the difference between associative arrays and nested tables?
Hello
What is the difference between associative arrays and nested tables?
nested tables cannot be indexed by other than pls_integer and unlike nested tables table associative cananot be declared at the schema level.
is there any other difference set apart from the diff above 2?user13710379 wrote:
What is the difference between associative arrays and nested tables?Name-value pairs (associative) against a list of values (table standard/nested table).
nested tables cannot be indexed by other than pls_integer
They are not "indexed" the way in which an associative array is indexed. A standard table is referenced by the position of the cell in the table. This position is essentially the offset of the memory of the cell from the start address of the table.
Can not solve a cell in an associative array directly via a memory offset index. You place a cell reference value it by his 'name' (a search in the linked list/hash table).
The following example shows the difference between the pairs of name / value and a list of core values.
SQL> declare 2 --// associative arrays are NAME-VALUE pairs 3 type TArr1 is table of varchar2(10) index by pls_integer; 4 type TArr2 is table of varchar2(10) index by varchar2(10); 5 6 arr1 TArr1; 7 arr2 TArr2; 8 begin 9 arr1(100) := '1st entry'; 10 arr1(1) := '2nd entry'; 11 arr1(5) := '3rd entry'; 12 13 arr2('john') := 'New York'; 14 arr2('jane') := 'Paris'; 15 arr2('jack') := 'London'; 16 17 end; 18 / PL/SQL procedure successfully completed. SQL> SQL> SQL> declare 2 --// standard arrays are lists 3 type TArr3 is table of varchar2(10); 4 type TArr4 is table of number; 5 6 arr3 TArr3; 7 arr4 TArr4; 8 begin 9 arr3 := new TArr3( '1st entry', '2nd entry', '3rd entry' ); 10 11 arr4 := new TArr4( 100, 1, 5 ); 12 end; 13 / PL/SQL procedure successfully completed. SQL>
-
Associative array in Oracle procedure problem
Hello
I searched through the internet and this forum and have not been able to solve a problem using the associative array of values in an IN clause. Everything I read says that I can not 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 get a ' ORA-21700: object does not exist or is marked for deletion "error when trying to access the table, I filled the table. Please note that I checked the table is actually filled during the loop. I capture the error when you are referencing in the SELECT statement.
I stated the following in the ARCHIVE package specification:
TYPE RSType IS REF CURSOR;
TYPE integer_aat IS TABLE OF INTEGER INDEX BY PLS_INTEGER;
Integer_table TYPE TABLE IS OF INTEGER;
The procedure is the following:
PROCEDURE SEL_SEARCH_RESULTS (v_term IN VARCHAR2,
v_categories IN ARCHIVE.integer_aat,
RS ON RSType)
AS
/ * END: Returns the results for the category and key word provided
VARIABLES:
v_categories = array of categories of documents
v_term = keyword entered
RS = game results
*/
tbl_cat ARCHIVE.integer_table: = ARCHIVE.integer_table ();
BEGIN
BECAUSE me in 1... v_categories. COUNTY
LOOP
tbl_cat. EXTEND (1);
tbl_cat (i): = v_categories (i);
END LOOP;
OPEN FOR RS
SELECT A.ID,
B.CATEGORY,
A.FILENAME,
A.DISPLAY_NAME,
A.COMMENTS
OF TBL_ARCHIVE_DOCUMENTS,.
B TBL_ARCHIVE_DOC_CAT,
C TBL_ARCHIVE_DOC_KEYWORDS
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.
Matt905707 wrote:
Thanks for the quick response. I looked at the example suggest you and made the following changes. Now, I get an invalid 'Data Type' error on the "column_value SELECT FROM TABLE (CAST (tbl_cat AS tbl_integer))' statement. I must be missing something simple and I can't put my finger on it.You did not create a SQL type as I said. tbl_integer is still declared in the PLSQL code you have posted.
Reread my initial response and look at the example I posted (the very first thing that is done is to create a SQL type).
-
I'm doing an associative array, where the key is a string and the value is an array of strings.
I tried to declare it like this:
PROCEDURE myProcedure IS
tableau_donnees argument type is varray (200) of VARCHAR2 (20);
Column TYPE IS an ARRAY OF tableau_donnees INDEX BY VARCHAR2 (20);
my_collection columns; -collection of multi dimensional pl/sql
BEGIN
my_collection ('test') (1): = "Hello"; -It is the idea...
"my_collection ('test') (2): = ' 8128 is the number";
my_collection ("some other field' ') (1): = 'foo';
-etc etc.
But I get the error Oracle ORA-06531, reference to an uninitialized collection:
Cause: A service of element or member of a nested table or varray has been referenced (where an initialized collection is necessary) without the collection has been initialized.
Action: Initialize the collection with an appropriate constructor or assignment of the whole object.
I tried to use 'extend()' initialize the varray, but no help...
my_collection('test').extend (200);
-----
I also tried this:
PROCEDURE myProcedure IS
Data TYPE of TABLE IS OF VARCHAR2 (20);
Column TYPE IS an ARRAY OF data INDEX BY VARCHAR2 (20);
my_collection columns; -collection of multi dimensional pl/sql
But it's always the same. I am quite new to PL/SQL, if any help would be great!
-j900685 wrote:
I'm doing an associative array, where the key is a string and the value is an array of strings.create or replace procedure myProcedure is type data_array is varray(200) of varchar2(20); type coltype is table of data_array index by varchar2(20); my_collection coltype; begin my_collection('test') := data_array('hello','8128 is the number'); my_collection('some other field') := data_array('foo'); end; /
And if you want to add elements in varray:
create or replace procedure myProcedure is type data_array is varray(200) of varchar2(20); type coltype is table of data_array index by varchar2(20); my_collection coltype; begin my_collection('test') := data_array('hello'); my_collection('test').extend; my_collection('test')(2) := '8128 is the number'; my_collection('some other field') := data_array('foo'); end; /
Or:
create or replace procedure myProcedure is type data_array is varray(200) of varchar2(20); type coltype is table of data_array index by varchar2(20); my_collection coltype; begin my_collection('test') := data_array(); -- initialize my_collection('test').extend; my_collection('test')(1) := 'hello'; my_collection('test').extend; my_collection('test')(2) := '8128 is the number'; my_collection('some other field') := data_array('foo'); end; /
SY.
-
join an associative array with table
I'm new to associative arrays.
Here, I'm doing the equivalent of as follows:
And join this table with T1 and the corresponding records to get top 10create table mytable as select n1,padding from T1 where rownum <=5; Table created.
Now with the assicative bays1 SELECT * FROM 2 ( 3 SELECT 4 T1.n1 5 , T1.small_vc 6 , mytable.padding 7 FROM 8 mytable 9 , T1 10 WHERE 11 mytable.n1 = T1.n1 12 ) 13* WHERE ROWNUM <= 10;
Of course the encoding isn't fair. Also, I want to display the first 10 results set.1 DECLARE 2 type array is table of T1%rowtype index by binary_integer; 3 l_data array; 4 l_rec T1%rowtype; 5 BEGIN 6 SELECT 7 * 8 BULK COLLECT INTO 9 l_data 10 FROM T1 11 WHERE ROWNUM <=5; -- the top 5 records 12 FOR i IN 1..l_data.count 13 LOOP 14 BEGIN 15 -- 16 SELECT 17 * 18 INTO 19 l_rec 20 FROM 21 T1 22 WHERE 23 T1.n1 = l_data(i).n1; 24 EXCEPTION 25 WHEN OTHERS THEN 26 DBMS_OUTPUT.PUT_LINE(to_char(SQLCODE) || ' - ' || substr(SQLERRM,1,200)); 27 END; 28 END LOOP; 29* END; [email protected]> / -1422 - ORA-01422: exact fetch returns more than requested number of rows -1422 - ORA-01422: exact fetch returns more than requested number of rows -1422 - ORA-01422: exact fetch returns more than requested number of rows -1422 - ORA-01422: exact fetch returns more than requested number of rows -1422 - ORA-01422: exact fetch returns more than requested number of rows
Thank you
MichTalebzadeh mich wrote:
Does it fast enough and I think it is necessary for using the pipeline to multiple joins functions to update the tables of FACTS so to speak.
A pipeline returns data that are not indexed. So by default, using data from a pipeline function involves a full production table scan. That's why native SQL tables are better than a pipeline - as these are accessible and used optimally (via the index partitions, bitmaps, clusters, etc.).
Since PTFS uses memory structures as associative arrays do, what are the main benefits of using TFP compared to the associative arrays in addition to the fact that in MFP memory structures are presented in the SQL format?
Not the same structure. An associative array is typically a list linked and "indexed" differently.
A normal array is accessible by compensation. Let's say it's an array of bytes 4 IEEE floats. 1st entry is at position 0 in the structure of memory. The 2nd entry at position 4. Etc.
Index number of the table is used to determine the offset of this table cell in the structure of memory.
An associative array is "indexed" using strings or dates or numbers (not sequential). Thus a structure like a linked list must be used. Access to the range means a search in this linked to the match index list and then read the value of this cell in the table.
The associative arrays do exist in the SQL engine. It is a unique data structure of PL/SQL engine.
As to the benefits of a pipeline - this is when the data must be processed and plain vanilla SQL is not able to do this and PL/SQL is required.
Simple example. A flat web service XML data structure. A table of pipeline can use UTL_HTTP to make the service web call, retrieve the XML code and that the output data as rows and columns - in effect turning a web service interface into something that looks like a SQL table and can be used as if it were a table SQL.
Reading Tom on the use of pipelines comments:
http://asktom.Oracle.com/pls/asktom/f?p=100:11:2814739467100916:P11_QUESTION_ID:19481671347143Also when can I use associative arrays functions insteard table in pipeline?
Associative arrays are useful for the only PL/SQL data. For example, which deals with the pair name / value that are placed by a customer and that are used to determine which query or process data. For the majority of the PL/SQL code and the treatment, associative arrays are not necessary. And often wrongly used that developers do not seem to understand what an associative array is and how it differs from a normal table structure.
-
Oracle 11.2.0.2.0
Using UTL_FILE, I can read the text file inot successfully in the associative array.
Now, I need to perform an advanced treatment of the values that is easily done with SQL, but for this the values should be in nested, no associative table. Is it possible a secret in another?
Thank you.
P.S. I am aware of the external tables and other means of data processing, but what I basically need is the ability to make SQL on associative arrays.declare infile utl_file.file_type; v_line varchar2(100); v_max varchar2(100); i integer:=1; type t_lines is table of varchar2(100) index by binary_integer; tab_lines t_lines; begin begin inFile := utl_file.fopen('ORADUMP','table.dat','R'); loop utl_file.get_line(infile,v_line); tab_lines(i) := v_line; i:=i+1; dbms_output.put_line(v_line); end loop; exception when no_data_found then utl_file.fclose(infile); when others then dbms_output.put_line(dbms_utility.format_error_backtrace); dbms_output.put_line('error ' || sqlcode || ' '||sqlerrm); end; --How to do something like this? --select max(column_value) into v_max from table(tab_lines); end; /
Nagornyi wrote:
I'd use a table nested from the beginning, but how to fill only one value at a time, during the reading of the file? Sorry, I didn't do well the answer in these examples...Basic idea
declare l_nested_table sys.odcivarchar2list default sys.odcivarchar2list(); begin l_nested_table.extend; l_nested_table(l_nested_table.count) := some_value; end; /
-
How to create an associative array
Is it necessary to creat a table associated with?index by BINARY_INTEGER
CREATE OR REPLACE TYPE WEBINST.string_state_table AS TABLE OF varchar2(100) ;
Yes,
You must use the index by clause to create an associative array. Other wise, it is called as a nested table.
Read this
http://download.Oracle.com/docs/CD/B28359_01/AppDev.111/b28370/Collections.htm#i34563
See how you can declare the different collections
http://download.Oracle.com/docs/CD/B28359_01/AppDev.111/b28370/Collections.htm#CJAJEIBA
G.
-
Error in the pl/sql block using associative arrays
Hello
I tried the following block of code using associative arrays.
and the error isDECLARE TYPE NumTab IS TABLE OF NUMBER INDEX BY BINARY_INTEGER; CURSOR c1 IS SELECT empno FROM emp; empnos NumTab; rows NATURAL := 10; BEGIN OPEN c1; FOR i in empnos.first..empnos.last LOOP /* The following statement fetches 10 rows (or less). */ FETCH c1 BULK COLLECT INTO empnos LIMIT rows; EXIT WHEN c1%NOTFOUND; DBMS_OUTPUT.PUT_LINE ( empnos.next(i)); END LOOP; CLOSE c1; END;
could you please let me know where I am going wrongDECLARE * ERROR at line 1: ORA-06502: PL/SQL: numeric or value error ORA-06512: at line 8
and please guide me where we use these associative arrays.
Thank youTry this
DECLARE TYPE NumTab IS TABLE OF emp%rowtype INDEX BY PLS_INTEGER; CURSOR c1 IS SELECT * FROM emp; empnos NumTab; rows INTEGER := 10; BEGIN OPEN C1; LOOP FETCH c1 BULK COLLECT INTO empnos LIMIT rows; EXIT WHEN c1%NOTFOUND; FOR i IN 1..empnos.count LOOP DBMS_OUTPUT.PUT_LINE(empnos(i).empno || '/' || empnos(i).ename); END LOOP; END LOOP; END;
Maybe you are looking for
-
my iphone 6 is disabled. can I recover the data
my iphone 6 is turned off after that I entered the password OK 'evil' has little time. I can recover the data that I didn't use icloud or itunes? I searched on the internet and there are some applications that claim to be able to recover data lost on
-
ssl_error_rx_record_too_long
I can't open facebook4 days does not open facebook with filter anonymox other opens slowlyBut ssl_error_rx_record_too_long please see the anonymox of the error to tell you how many times I had a problem, but do not treat
-
xLOUD and ClearPhase technology software
Hi guys,. I formatted my system and clean the windows installed, but I couldn't find any xLOUD and ClearPhase software. Is there someone who will download these two programs? Thank you..
-
It is an ancient game I want to play again for old times sake, but my laptop is a 64-bit that the installer says that it is not compatible with. Is there any compatibility mode setting that helps?
-
My XP PC will not connect to my printer Epson...
My Dell Dimension 1100 Windows XP in the connect to my modem with a cable Ethernet RJ45 and we have 2 laptops connected via Wifi. We have an Epson Stylus sx430 wireless printer and it not connecting to my pc (Dell Dimension 1100) have to I do? PS: tw