[JS] Adding methods to associative arrays
I have an associative array. I want to add a method that returns an array of all the names of the associative array. The problem is that it returns the name of the method, too. Is it all so he can only return the property names and not the methods? In the code below, I would like to myEveryItem item to return a table of two, not three.
RangePresets = {}; RangePresets.everyItem = getEveryItem; RangePresets["[Default]"] = new RangePreset(578,800); RangePresets["Daily Dose"] = new RangePreset(360, 600); myEveryItem = RangePresets.everyItem(); // RangePreset Constructor function RangePreset(hr,vr){ this.horizontalRange = hr; this.verticalRange = vr; } function getEveryItem(){ var ei = []; for (x in this) ei.push(x); return ei; }
You can use Object.reflect.properties, but which will give you proto, County, classand take into account outside your own properties.
You can also test: if (object [x].constructor.name == "Function") to exclude functions.
Substances
Tags: InDesign
Similar Questions
-
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.
-
Add items to an associative array
I would like to add items at the end of an associative array. The approach I take is this:
Is there a better way to do it? As with a kind of method?myArray(myArray.LAST + 1) = <some_value>
Thank you.Watch the demo here:
http://www.morganslibrary.org/reference/arrays.html
It shows precisely how do.The complete library is at http://www.morganslibrary.org/library.html
-
Hi all
I searched through this forum trying to find I need information about the associative arrays with an index of varchar2 without success. What I'm looking for is a way to get the index or the 'key' values in the table without knowing what they are. Which means, I wouldn't know the index value in the design of the table, but would be able to use the values during execution. For those who are familiar with Java, it would be like calling the method keySet() of a map object.
So if I have a table of TYPE COLUMN_ARRAY IS TABLE OF VARCHAR2 (4000) INDEX OF VARCHAR2 (100) is it possible to dynamically get the index values without knowing what they are?
Any help is appreciated.
Thank youHello
declare i Number := 1; begin ... i := Array_List.Next(i); ...
Kind regards
Christian Balz
-
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
-
What is the preferred means of data transmission in the associative array of the nested table record vs
Choose between Nested Tables and associative arrays
The two nested tables and associative arrays (formerly index - by tables) use similar index notation, but they have different characteristics when it comes to persistence and ease of passing parameters.
Nested tables can be stored in a column of data, but can of associative arrays. Nested tables can simplify the SQL operations where you would normally join a single-column table with a larger table.
Associative arrays are appropriate for relatively small lookup tables where the collection can be constructed in memory whenever a procedure is called or a package is initialized. They are good for the collection of the information volume is unknown beforehand, because there is no fixed limit on their size. Their index values are more flexible, as associative array indices can be negative, can be no sequential and can use values of string instead of numbers.
PL/SQL automatically converts between the bays of the host and the associative arrays that use values of digital keys. The most effective way to move the collections to and from the database server is to implement data values in associative arrays, and then use these associative arrays with erections in bulk (the
FORALL
statement orBULK
COLLECT
clause).With the help of documents and Collections of PL/SQL
Read this:
-
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;
-
Error renaming dates to an associative array of type date
Hi all
I am facing issue while assigning dates in an associative array of type date:
Oracle version:
SQL > select * from v version $;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
AMT for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - ProductionStored procedure, I try to write is as follows
- create or replace procedure (jp1)
- p_start_date default date trunc(sysdate,'MM')
- p_end_date date default trunc (sysdate)
- )
- is
- number of l_no_of_days;
- type t_date_id is table of date
- index by pls_integer;
- l_date_id_arr t_date_id;
- Start
- l_no_of_days: = p_end_date - p_start_date;
- for i from 0
- .. l_no_of_days - 1
- loop
- l_date_id_arr: = p_start_date + i;
- dbms_output.put_line (p_start_date + i);
- end loop;
- end;
- /
I get error on line 14 when compiling it. and the error message is as follows:
JP1 PROCEDURAL errors:
LINE/COL ERROR
-------- -----------------------------------------------------------------
14/5 PL/SQL: statement ignored
14/22 PLS-00382: expression is of the wrong typeWhile studying this, I tried the value of (p_start_date + i) using dbms_output.put_line and the output is so date itself.
- create or replace procedure (jp1)
- p_start_date default date trunc(sysdate,'MM')
- p_end_date date default trunc (sysdate)
- )
- is
- number of l_no_of_days;
- type t_date_id is table of date
- index by pls_integer;
- l_date_id_arr t_date_id;
- Start
- l_no_of_days: = p_end_date - p_start_date;
for i from 0... l_no_of_days-1
- loop
- -l_date_id_arr: = p_start_date + i;
- dbms_output.put_line (p_start_date + i);
- end loop;
- end;
- /
output of the
- exec jp1
is as follows:
1ST DECEMBER 13
2 DECEMBER 13
3 DECEMBER 13
DECEMBER 4, 13
5 DECEMBER 13
DECEMBER 6, 13
7 DECEMBER 13
DECEMBER 8, 13
9 DECEMBER 13
DECEMBER 10, 13
DECEMBER 11, 13
DECEMBER 12, 13
13 DECEMBER 13
14 DECEMBER 13
15 DECEMBER 13
16 DECEMBER 13
17 DECEMBER 13
18 DECEMBER 13
I see the release date itself. so why he throws error while the same assignment to an associative array of type date.
I tried Google too for the same but without success.
Any help is appreciated in this regard not or any pointer another thread on the internet or in this forum.
Thanks in advance
Jagdeep Seven
Read associative arrays:
- create or replace procedure (jp1)
- p_start_date default date trunc(sysdate,'MM')
- p_end_date date default trunc (sysdate)
- ) is
- number of l_no_of_days;
- type t_date_id is table of date
- index by pls_integer;
- l_date_id_arr t_date_id;
- Start
- l_no_of_days: = p_end_date - p_start_date;
- because me in 0.l_no_of_days - 1
- loop
- l_date_id_arr (I): = p_start_date + i;
- dbms_output.put_line (p_start_date + i);
- end loop;
- end;
----
Ramin Hashimzade
-
Associative array as a type of database
As it is very well create an associative array inside a stored procedure:
type urltype is table of varchar2(32767) index by varchar2(30);
Can it be created as a type of database at the level of the schema?
Brian.McGinity wrote:
As it is very well create an associative array inside a stored procedure:
- type urltype is the table of index varchar2 (32767) by varchar2 (30);
Can it be created as a type of database at the level of the schema?
Non - associative arrays are a function of PL/SQL.
See table 5-1 in the doc of the PL/SQL language for a description of each type of collection and where (pl/sql, sql, etc.) they can be used.
http://docs.Oracle.com/CD/E11882_01/AppDev.112/e25519/composites.htm#CHDBHJEI
-
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
-
Associative array of index files by varchar2 - PLS 00382
I have a SQL anonymous block that creates a report. At the end of each section, I need to summarize the data by "renting". The list of locations is finished (approx. 15 in a table) and not all sections will have data for each location, but I want the locations to order the same so I thought I'd use an associative array to store summary data. But when I try to initialize the associative array (I simply put the slots in the array in the "correct" order) I receive PLS-00382 expression is of the wrong type.
Here is the code (the lines where the error occurs are in bold):
TYPE summary_data () IS RENDERING
Summary1 NUMBER,
NUMBER of summary2
NUMBER of summary3
);
Summ_arr TYPE IS TABLE of summary_data INDEX OF VARCHAR2 (5);
location_summary summ_arr;
aLoc VARCHAR2 (5);
PROCEDURE init_summ (aSummArr IN OUT summ_arr) IS
BEGIN
aSummArr.Delete;
BEGIN
FOR in aLoc (select name - name is VARCHAR2 (5))
table
control key)
LOOP
aSummArr (aLoc) .summary_1: = 0;
aSummArr (aLoc) .summary_2: = 0;
aSummArr (aLoc) .summary_3: = 0;
END LOOP;
EXCEPTION
-exception handling
END;
END;
If this is not allowed, or I do something wrong? I tried substituting:
Summ_arr TYPE IS TABLE of summary_data INDEX OF VARCHAR2 (5);
with
Summ_arr TYPE IS TABLE of summary_data INDEX table.key%TYPE;
Nothing helps.
Thanks in advance for your help with this.
ANNUAL GENERAL MEETINGALOC is a record variable. You need to refrence the column in the file said. So, something like this:
aSummArr(aLoc.name).summary_1 := 0;
Cheers, APC
-
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.
-
Difference between an associative array and Nested table
Hello
Can you please tell me, what is the main differences between associative array and Nested table. I'm not sure, in this case we are to use.
Thank you and best regards,
Sanjeev.user13483989 wrote:
HelloCan you please tell me, what is the main differences between associative array and Nested table. I'm not sure, in this case we are to use.
Did you happen to read the documentation, explain its good enough!
http://docs.Oracle.com/CD/E11882_01/AppDev.112/e25519/composites.htm#LNPLS005Aman...
Maybe you are looking for
-
Why Javascript does not work properly?
I'm working on a web page and try this script, but it does not work (although it works fine in IE). The code is given below: My function is: function validateNumber() { var x=window.event.keyCode; //alert(x); if(!(x>=48 && x<=57)) { alert("Please typ
-
Satellite P100-st9772: what parts are scalable?
I'm really interested in getting this machine (P100-st9772) primarily for use in games. But for the cost I want to be able to upgrade the video card, RAM and anything else besides. Is it possible to upgrade?Also Toshiba do ship in Ireland or South Af
-
Driver CD/DVD for the Satellite A100-785
Hello. For our school, we bought 10 laptops. These PCs come with windows vista Home Basic version. We need to install windows xp sp2 on them, but the problem is that we don't have the drivers. The recovery cd theat comes with those pc is windows vist
-
Neo V Screen Shots problem after update of the ICS.
How to take screenshots in NEO V after ICS update... Help, please
-
Windows Messenger does not open, I get error saying Windows Live messenger stops working