PL/SQL - Using a variable as a table name
I have a procedure like this -
PROCEDURE insert_food IS
BEGIN
INSERT INTO food_table
SELECT *
FROM fruit_table;
END insert_food;
So this proceudre would insert all the records in the 'fruit_table' into the 'food_table'.
Would there be any way to store the 'fruit_table' as a variable and use that in the script?
Something like -
PROCEDURE insert_food IS
table_name varchar(11) := 'fruit_table';
BEGIN
INSERT INTO food_table
SELECT *
FROM table_name;
END insert_food;
Any help would be great!
create or replace PROCEDURE insert_food IS
table_name1 varchar(11) := 'emp';
BEGIN
execute immediate 'INSERT INTO emp2
SELECT *
FROM '||table_name1||'';
commit;
END insert_food;then
exec insert_food;
Similar Messages
-
How to use a variable as a table name in PL/SQL?
Hello all.
I was given one day to wrote a piece of PL/SQL code to do a query. That is,
First select two columns from one table and use them to build another table's name, then
join the two tables. I'm not sure if variables can be used in the select list, if possible,
how to reference them?
-- My code is
DECLARE
tablename varchar2(40);
CURSOR c1 IS
select a.sourcesystemcode, a.adminorganizationno from cdb1.organization_mapping a
where exists( select 1 from cdb1.organization_mapping b where
a.cdborganizationno = b.cdborganizationno and a.adminorganizationno != b.adminorganizationno)
order by a.cdborganizationno,a.adminorganizationno;
v_src_sys_cod cdb1.organization_mapping.sourcesystemcode%TYPE;
v_adm_org_no cdb1.organization_mapping.adminorganizationno%TYPE;
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO v_src_sys_cod, v_adm_org_no;
EXIT WHEN c1%NOTFOUND;
tablename := 'ODS1.SRC_' || v_src_sys_cod || v_adm_org_no || 'ACTORG_CURR';
select c.cdborganizationno, c.sourcesystemcode, c.adminorganizationno, c.sourceorganizationno, d.ibkcde, d.orgnam
from cdb1.organization_mapping c inner join tablename d on c.sourceorganizationno = d.orgidt;
END LOOP;
CLOSE c1;
END;
The error message says "... the table or view does not exist... line 18, column 66..."
It says the variable "tablename" wasn't build or build incorrectly.
Please give the solution.If the TABLEs being queried are already known, and it is just a matter of which one to query, perhaps you can CREATE a VIEW that uses all the TABLEs with a UNION ALL, and include an identifier COLUMN.
CREATE VIEW SRC_ALL_ACTORG_CURR
AS
SELECT 'aa' Name, ibkcde, orgnam FROM SRC_aa_ACTORG_CURR UNION ALL
SELECT 'bb' Name, ibkcde, orgnam FROM SRC_bb_ACTORG_CURR UNION ALL
SELECT 'cc' Name, ibkcde, orgnam FROM SRC_cc_ACTORG_CURR UNION ALL
SELECT 'dd' Name, ibkcde, orgnam FROM SRC_dd_ACTORG_CURR UNION ALL
SELECT 'ee' Name, ibkcde, orgnam FROM SRC_ee_ACTORG_CURR;
Then, in you query:
select c.cdborganizationno, c.sourcesystemcode, c.adminorganizationno, c.sourceorganizationno, d.ibkcde, d.orgnam
from cdb1.organization_mapping c inner join SRC_ALL_ACTORG_CURR d on c.sourceorganizationno = d.orgidt and d.Name = v_src_sys_cod || v_adm_org_no; -
Use a variable as a table name with NATIVE SQL
Hi all,
I am trying to execute a SELECT statement in order to fetch data from an external Oracle DB table to SAP with the following instructions:
EXEC SQL.
SELECT cityfrom, cityto
INTO STRUCTURE :wa
FROM spfli
WHERE mandt = :sy-mandt AND
carrid = :p_carrid AND connid = :p_connid
ENDEXEC.
However, I need to indicate the external table name from a variable instead of the solution above. That is, declaring a variable and store the name of the table (e.q. spfli) in it. The resulting ABAP code would be something like:
EXEC SQL.
SELECT cityfrom, cityto
INTO STRUCTURE :wa
FROM <VARIABLE>
WHERE mandt = :sy-mandt AND
carrid = :p_carrid AND connid = :p_connid
ENDEXEC.
Does anybody know if is possible to do that?
If not, is there any other solution?
Thank you in advanceYes, as Suhas said, you could use the ADBC API and his class CL_SQL_CONNECTION to achieve this...
Here is a small example:
PARAMETERS: p_carrid TYPE spfli-carrid,
p_connid TYPE spfli-connid.
DATA:
l_con_ref TYPE REF TO cl_sql_connection,
l_stmt TYPE string,
l_stmt_ref TYPE REF TO cl_sql_statement,
l_dref TYPE REF TO data,
l_res_ref TYPE REF TO cl_sql_result_set,
l_col1 TYPE spfli-carrid,
l_col2 TYPE spfli-connid,
l_wa TYPE spfli.
CONSTANTS:
c_tabname TYPE string VALUE 'SPFLI'.
* Create the connecction object
CREATE OBJECT l_con_ref.
* Create the SQL statement object
CONCATENATE 'select * from' c_tabname 'where carrid = ? and connid = ?'
INTO l_stmt SEPARATED BY space. "#EC NOTEXT
l_stmt_ref = l_con_ref->create_statement( ).
* Bind input variables
GET REFERENCE OF l_col1 INTO l_dref.
l_stmt_ref->set_param( l_dref ).
GET REFERENCE OF l_col2 INTO l_dref.
l_stmt_ref->set_param( l_dref ).
* Set the input value and execute the query
l_col1 = p_carrid.
l_col2 = p_connid.
l_res_ref = l_stmt_ref->execute_query( l_stmt ).
* Set output structure
GET REFERENCE OF l_wa INTO l_dref.
l_res_ref->set_param_struct( l_dref ).
* Show result
WHILE l_res_ref->next( ) > 0.
WRITE: / 'Result:', l_wa-carrid, l_wa-connid.
ENDWHILE.
* Close the result set object
l_res_ref->close( ).
Otherwise you can also use the FM DB_EXECUTE_SQL...
Kr,
m. -
How to use bind variable value for table name in select statement.
Hi everyone,
I am having tough time to use value of bind variable for table name in select statement. I tried &p37_table_name. ,
:p37_table_name or v('p37_table_name) but none worked.
Following is the sql for interactive report:
select * from v('p37_table_name') where key_loc = :P37_KEY_LOC and
to_char(inspection_dte,'mm/dd/yyyy') = :P37_INSP_DT AND :p37_column_name is not null ;
I am setting value of p37_table_name in previous page which is atm_state_day_insp.
Following is error msg:
"Query cannot be parsed, please check the syntax of your query. (ORA-00933: SQL command not properly ended) "
Any help would be higly appreciated.
RajInterestingly enough I always had the same impression that you had to use a function to do this but found out from someone else that all you need to do is change the radio button from Use Query-Specific Column Names and Validate Query to Use Generic Column Names (parse query at runtime only). Apex will substitute your bind variable for you at run-time (something you can't normally do in pl/sql without using dynamic sql)
-
MySQL - In a Query, Using a Variable as a Table Name
Hello,
The code I have attached works. However, I would like to
replace the table name "tractors" with the variable "$result". How
do I do this? (It doesn't work if I just type "$result" where
"tractors" is.)
Thanks,
JohnArizonaJohn wrote:
> The code I have attached works. However, I would like to
replace the table
> name "tractors" with the variable "$result". How do I do
this?
You can't. In the code you have given $result is a MySQL
database result
resource. You need to extract the actual value from the
result resource
in the same way as you have done by using
mysql_fetch_array().
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS4",
"PHP Solutions" & "PHP Object-Oriented Solutions"
http://foundationphp.com/ -
Create index in SQL using a variable
Hello, need to programatically create an index in a SQL script using a variable for the tablespace name.
VARIABLE ts_name VARCHAR2(50)
BEGIN
SELECT tablespace_name INTO :ts_name
from user_indexes
where TABLE_NAME = 'PREFERRED_CUSTOMER';
end;
How would I now issue a create index statement like the one below but substituting the tablespace name with the ts_name variable from above?
CREATE UNIQUE INDEX XAK2PREFERRED_CUSTOMER ON FOCUS.PREFERRED_CUSTOMER (PREFERRED_CUST_NUM) TABLESPACE FOCUSPCIX;
Thank you,
DavidI am upgrading a customer database to unicode and I need to convert certain columns to NCHAR base. I am using an alter table command to do this. To make it fasted I need to drop indexes and recreate them at the end. Not all of our customers have used the default tablespace naming conventions so rather than having to change the script each time I was hoping to make the tablespace name portion of the create index DDL dynamic. Thank you,
David -
SQL*LOADER(8I) VARIABLE SIZE FIELD를 여러 TABLE에 LOAD하기 (FILLER)
제품 : ORACLE SERVER
작성날짜 : 2004-10-29
==================================================================
SQL*LOADER(8I) VARIABLE SIZE FIELD를 여러 TABLE에 LOAD하기 (FILLER)
==================================================================
PURPOSE
SQL*LOADER 에서 variable length record와 variable size field를 가진 data
file 을 여러 table에 load하는 방법을 소개하고자 한다.
( 8i new feature인 FILLER 절 사용)
Explanation
SQL*LOADER SYNTAX
여러 table에 load하고자 할때에는 control file에 아래와 같이 하면 된다.
INTO TABLE emp
INTO TABLE emp1
fixed length field을 가진 data file을 여러 table에 같은 data을 load하고자
한다면 아래와 같다.
INTO TABLE emp
(empno POSITION(1:4) INTEGER EXTERNAL,
INTO TABLE emp1
(empno POSITION(1:4) INTEGER EXTERNAL,
위와 같이 양쪽 table의 empno field에 각각의 load할 data로부터 1-4까지를
load 할수 있다. 그러나 field의 길이가 가변적이라면 위와 같이 POSITION 절을
각 field에 사용할 수 없다.
Example
예제 1>
create table one (
field_1 varchar2(20),
field_2 varchar2(20),
empno varchar(10) );
create table two (
field_3 varchar2(20),
empno varchar(10) );
load할 record가 comma로 나누어지며 길이가 가변적이라고 가정하자.
<< data.txt >> - load할 data file
"this is field 1","this is field 2",12345678,"this is field 4"
<< test.ctl >> - control file
load data infile 'data.txt'
discardfile 'discard.txt'
into table one
replace
fields terminated by ","
optionally enclosed by '"' (
field_1,
field_2,
empno )
into table two
replace
fields terminated by ","
optionally enclosed by '"' (
field_3,
dummy1 filler position(1),
dummy2 filler,
empno )
dummy1 field는 filler로 선언되었다. filler로 선언하면 table에 load하지 않는다.
two라는 table에는 dummy1이라는 field는 없으며 position(1)은 current record의
처음부터 시작해서 첫번째 field을 dummy1 filler item에 load한다는 것을 말한다.
그리고 두번째 field을 dummy2 filler item에 load한다. 세번째 field인, one이라는
table에 load되었던 employee number는 two라는 table에도 load되는 것이다,
<< 실행 >>
$sqlldr scott/tiger control=test.ctl data=data.txt log=test.log bindsize=300000
$sqlplus scott/tiger
SQL> select * from one;
FIELD_1 FIELD_2 EMPNO
this is field 1 this is field 2 12345678
SQL> select * from two;
FIELD_3 EMPNO
this is field 4 12345678
예제 2>
create table testA (c1 number, c2 varchar2(10), c3 varchar2(10));
<< data1.txt >> - load할 data file
7782,SALES,CLARK
7839,MKTG,MILLER
7934,DEV,JONES
<< test1.ctl >>
LOAD DATA
INFILE 'data1.txt'
INTO TABLE testA
REPLACE
FIELDS TERMINATED BY ","
c1 INTEGER EXTERNAL,
c2 FILLER CHAR,
c3 CHAR
<< 실행 >>
$ sqlldr scott/tiger control=test1.ctl data=data1.txt log=test1.log
$ sqlplus scott/tiger
SQL> select * from testA;
C1 C2 C3
7782 CLARK
7839 MILLER
7934 JONES
Reference Documents
<Note:74719.1> -
Use of quotes in a table name?
Hello,
It seems Oracle treats a table name with and without quotes differently.
SQL> create table abc (x integer);
SQL> create table "abc" (y integer);
These two commands result in two different tables as can be seen from the following commands:
SQL> desc abc;
SQL> desc "abc";
However, I cannot get the list of tables.
SQL> select * from tab where tname like '%abc%';
returns just one row.
SQL> select * from all_objects where object_name like '%abc%' also does not show me abc and "abc" as two separate tables.
Q1. Is there a way to obtain the proper list?
Q2. What is the proper qualifier for specifing a table name? For example, SQL Server supports "[" and "]" around the table name. However, I could not find the equivalent grammar for PL/SQL.
The following command works (by trial and error):
SQL> select * from (abc);
However, the following doesn't:
SQL> drop table (abc);
which means that "(" and ")" are not the qualifiers.
Thank you in advance for your help.
PradeepImport and export and the other tools use quotes so
that objects will be properly re-created as they were
originally specified, even if some one uses reserved
words or case sensitive names. At least they should. I recently had a customer using FoxPro (!) to access my Oracle Datawarehouse and he named one of his column "ALTER" (age in german). Then he complained that my database is not working because he was getting an Oracle error (ORA-00936: missing expression)!
However, if some developer made me
type:
SELECT "MyCol1", "MyCol2", ...
FROM "HisTable"
WHERE "SomeStrangeColumnName" = 42every time,
I would think seriously of homocide :-).I know the feeling :-) -
Using a parameter for a table name?
In SQL Server, can you use a parameter for a table name? I'm working with Visual C# and want to do something like this:
SELECT MAX(ItemID) FROM @TableName;
Can this be done?
(Basically, I have three separate methods within a class--one for each table I have; and each one will perform the above query but on different table names. I'd like to see if there is a way that I can have just one method that will allow me to specify
the table name.)As pointed out in other posts, you can. But a more relevant question is whether you should.
A table in a relational database is supposed to model a unique entity, and each column in the table is supposed to model a unique attribute. This is not always how it is, but it is from this model a relational database is designed.
From this angle, having a dynamic table name does not really make sense for application code. (Administrative actions is a different story.) Think of it this way: have you ever wanted to make the class name dynamic in C#?
Admittedly, it is different in .NET, because everything inherits from System.Object, but in a relational database there is no inheritence.
Anyway, if you are using stored procedures, you should have one stored procedure per table. Physically, in the plan cache, there will be one query plan per table, no matter how you do it.
If you are submitting SQL statements from your application, it is a different matter. In this case, I find it difficult to object if you have a class that performs generic actions against tables. Then you build the SQL string in the client code.
However, no matter how you do it, you need to be careful to avoid SQL injection. We had the example:
DECLARE @TableName nvarchar(50),@sqlCommand nvarchar(max)
SET @TableName = ' ItemInformation'
SET @sqlCommand = 'SELECT MAX(ItemID) FROM ' + @TableName
EXEC (@sqlCommand)
But what if we have:
SET @TableName = ' sys.objects; SHUTDOWN WITH NOWAIT; --'
As long as we do it in T-SQL, we can (and we should do!) this to prevent SQL injection:
SET @sqlCommand = 'SELECT MAX(ItemID) FROM ' + quotename(@TableName)
If you build your SQL strings in C#, you will need to employ other checks. There is only an issue if the user can inject data somewhere, but your generic class will not have knowledge of this, and must assume the worst.
Erland Sommarskog, SQL Server MVP, [email protected] -
ORA-01722: invalid number caused with SQL using bind variable
Hi,
Im am hoping that someone can help me resolve a problem thats only just services and is being experienced on quite a few clients.
our application uses C++ exes and makes OCI calls to the database.
what has happened in the last week or so, there has been quite a few invalid number errors being received on a prod server but strangly enough we cannot reproduct the error on our UAT system.
The sql is using bind variables and the information in the trace file shows that a number is being used for the bind variable, here is an extract from one trace file:
for some schemas, the bind variable value is some currupted value, i think:
oacdty=01 mxl=32(21) mxlc=00 mal=00 scl=00 pre=00
oacflg=03 fl2=1206001 frm=01 csi=178 siz=32 off=0
kxsbbbfp=9a8d62b8 bln=32 avl=03 flg=05
value="Â*d"
but on another schema, the value used is:
Bind#0
oacdty=01 mxl=32(32) mxlc=00 mal=00 scl=00 pre=00
oacflg=03 fl2=1206001 frm=01 csi=178 siz=32 off=0
kxsbbbfp=c5f92718 bln=32 avl=04 flg=05
value="2101"
however both produce invalid number errors.
I am relatively inexperienced as a DBA so would appreciate as much help as i can get.Could you post your sql statement that is being run.
Also post the query plan from your uat system and the one from your production system (They are likely to be different)
You can export the stats from your production system and run them in your uat system. If you do this, then the execution plans should be the same on both systems(dbms_stats) and if you have the same data you should run into the same problem on uat as in production.
The root cause of this type of problem is having a column in a table which holds values which are of different datatypes. Typically there is a condition in the where clause which indicates that for example only numeric columns should be retrieved from the column which holds multiple data types. However since the optimizer is free to rewrite the query any way it sees fit, (It does not necessarily execute in the order the sql statement is written) it does not filter this data first, and therefore you hit non-numeric data and run into the invalid number error.
You can use little techniques like using an inline view with rownum in the column list, to perform the first filter. This ensures that the inline view is executed on its own, rather than being merged (materialized) with the rest of the query.
A quick temporary solution is to use a comparison like to_char(column_name) = variable
Make sure your comparisons are correct and it doesn't negatively impact on performance of the query -
Using variable as a table name
hi i want to use a variable as table in plsql block
like
declare cursor c1
select to_char(to_date(substr(appl_uid,21,2),'MM'),'MON')||'_'|| as v_Tab,ename from my_table;
v_ename = varchar(55);
vv_table =varchar(6);
begin
open c1
fetch c1 into vv_table,v_ename
select ename into v_ename from vv_table;
DBMS_OUTPUT.PUT_LINE (v_ename);
close c1
end;
please help me to correct this blockAs mentioned by BlueShadow above the following statement will fail if the table has more then one row.
EXECUTE IMMEDIATE 'select ename from ' || vv_table INTO v_ename;So I would suggest you use ref curosr to execute a SELECT dynamically which is likely to return more then one row.
SQL> create table my_table (appl_uid VARCHAR2(30),ename varchar2(30));
Table created.
SQL> insert into my_table values ('123456789012345678901234567890','SCOTT');
1 row created.
SQL> insert into my_table values ('123456789012345678901123456789','WARD');
1 row created.
SQL> create table nov_ (ename varchar2(30));
Table created.
SQL> insert into nov_ values ('SMITH');
1 row created.
SQL> insert into nov_ values ('JAMES');
1 row created.
SQL> insert into nov_ values ('JONES');
1 row created.
SQL> create table dec_ (ename varchar2(30));
Table created.
SQL> insert into dec_ values ('ALLEN');
1 row created.
SQL> insert into dec_ values ('ADAMS');
1 row created.
SQL> insert into dec_ values ('KING');
1 row created.
SQL> commit;
Commit complete.
SQL> set serveroutput on
SQL> declare
2 cursor c1 is
3 select to_char(to_date(substr(appl_uid, 21, 2), 'MM'), 'MON') || '_' as v_tab,ename
4 from my_table;
5 type ref_cur is ref cursor;
6 c2 ref_cur;
7 v_ename varchar(55);
8 begin
9 for rec in c1 loop
10 open c2 for 'select ename from ' || rec.v_tab;
11 DBMS_OUTPUT.PUT_LINE('********************'||rec.v_tab||'********************');
12 loop
13 fetch c2 into v_ename;
14 exit when c2%notfound;
15 DBMS_OUTPUT.PUT_LINE(v_ename);
16 end loop;
17 close c2;
18 end loop;
19 end;
23 /
********************DEC_********************
ALLEN
ADAMS
KING
********************NOV_********************
SMITH
JAMES
JONES
PL/SQL procedure successfully completed.And at last as suggested by fellow members that it is a bad idea, I would agree and suggest you to relook your design.
Edited by: zahid79 on Jul 22, 2010 10:28 PM -
I am very much new to PL/SQL to pardon my neivte.
I would like to have some PL/SQL code that uses
bind variables for insert statements and than issue
commit's after a specific number of inserts.
For example.
desc xxx.taba
a number
b varchar2(20)
I want to do someting like this:
declare
l_start number default dbms_utility.get_time;
create or replace procedure insert_xxx(commit in number)
begin
for i in 1 .. 1000
loop
:a:=i;
:b:=dbms_random.string('P', 20);
intert into xxx :a :b;
if i/mod=(number passed into to proc)
commit
end loop;
dbms_output.put_line
(round((dbms_utility.get_time-l_start)/100, 2) ||
' Seconds...' );
end;
end;
Can somebody help me out with the correct syntax
as I know it's incorrect.A few remarks
- procedures don't have hidden variables defined in the outside world, as procedures are black boxes, which communicate only with the outside world
using the actual parameter list
- procedures don't commit. The caller should always commit!!!
- procedures don't commit every <n> records. A commit finalizes a logical unit of work, not a technical one.
If I would have been your supervisor and you would have presented this code, I would have fired you on the spot.
Committing inside a loop also increases the likelihood of ora-1555 errors.
So: remove the current parameter
a and b should be formal parameters of the procedure
Inside the procedure it should read
insert into xxx values (a, b)
Sybrand Bakker
Senior Oracle DBA -
SQL Statement error - ORA-00903: invalid table name
Hi
I have written a sql script that gets executed from a form within e-business suite. Unfortunately, the script is falling over with an error:
unknown command beginning "MERGE INTO..." - rest of line ignored.
unknown command beginning "USING edop..." - rest of line ignored.
unknown command beginning "ON (elw.ro..." - rest of line ignored.
unknown command beginning "WHEN MATCH..." - rest of line ignored.
For a list of known commands enter HELP
and to leave enter EXIT.
SET ELW.billed_flag = t.billed_flag,
ERROR at line 2:
ORA-00903: invalid table name the actual statement that is causing the issue is:
MERGE INTO edopaif.table1 elw
USING edopaif.tablw2 t
ON (elw.rowid = t.LOAD_WORKING_ROWID)
WHEN MATCHED THEN
UPDATE
SET ELW.billed_flag = t.billed_flag,
ELW.last_bill_generated = t.last_bill_generated,
ELW.last_bill_type = t.last_bill_type,
ELW.load_month = t.load_month,
ELW.BILL_TRANSACTION_ID = t.bill_transaction_id
WHEN NOT MATCHED THEN
INSERT(error_meaning)
VALUES('ROWID error with ins_ptia');The version of e-business suite that we are using is: 11.5.10.2.
The version of the Oracle database that we are using is:
Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
PL/SQL Release 9.2.0.6.0 - Production
CORE 9.2.0.6.0 Production
TNS for IBM/AIX RISC System/6000: Version 9.2.0.6.0 - Production
NLSRTL Version 9.2.0.6.0 - Production
Please note that I am able to successfully run the statement directly connected as the APPS schema in the database - the error only occurs when the script is run from the forms front-end (which is really confusing me).
Many thanks
PaulHi
I've modified the script to include only the statement that is erroring and it still errors when executed from the front end application.
Next I re-wrote the statement to use PL/SQL instead of the MERGE statement, to do the update, and the script completes succesfully, i.e.:
DECLARE
CURSOR cu_lw IS
SELECT t.billed_flag,
t.last_bill_generated,
t.last_bill_type,
t.load_month,
t.bill_transaction_id,
t.load_working_rowid
FROM table2 t;
BEGIN
FOR rec_cu_lw IN cu_lw LOOP
UPDATE table1 elw
SET ELW.billed_flag = rec_cu_lw.billed_flag,
ELW.last_bill_generated = rec_cu_lw.last_bill_generated,
ELW.last_bill_type = rec_cu_lw.last_bill_type,
ELW.load_month = rec_cu_lw.load_month,
ELW.BILL_TRANSACTION_ID = rec_cu_lw.bill_transaction_id
WHERE elw.rowid = rec_cu_lw.load_working_rowid;
END LOOP;
END;
/I am still unsure as to why the MERGE statement is failing when executed in the front end, but completes in the backend with no issues at all. Obviously I would prefer to use the MERGE statement instead of PL/SQL to do the update.
Thanks
Paul -
SQL query to return list of table names.
Hi all,
I'm looking for a query that will return a list of the table names that exist in my Microsoft Access database.
Any ideas?http://forum.java.sun.com/thread.jsp?forum=31&thread=348287
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/DatabaseMetaData.html
I would suggest you strat to use the search at the upper right.
You can leave it blank and the advanced search will appear.
You can then select the specific areas you want to search. -
Using a variable in an instance name
Hey all,
Simple question:
I'm trying to use a variable to call on different instance names:
var picCaller:uint=2;
material_mc.addChild(pic_""+picCaller+"");
The code in red is the issue in question. In this example, I'm trying to add a child called "pic_2", with the number two called from the variable "picCaller"
Any assistance is greatly appreciated.
Thanks!Just for context, here is what I'm trying to do:
I have jpegs in my library and I want to add them to the stage when they're needed, so just to add one image, here is the code I have:
var pic_1=new pic1(0,0);
var image_1:Bitmap=new Bitmap(pic_1);
material_mc.addChild(image_1);
I want to put the above into a loop so that I dont have to repeat those three lines for every image in my library like so:
var pic_1=new pic1(0,0);
var image_1:Bitmap=new Bitmap(pic_1);
var pic_2=new pic2(0,0);
var image_2:Bitmap=new Bitmap(pic_2);
var pic_3=new pic3(0,0);
var image_3:Bitmap=new Bitmap(pic_3);
var pic_4=new pic4(0,0);
var image_4:Bitmap=new Bitmap(pic_4);
var pic_5=new pic5(0,0);
var image_5:Bitmap=new Bitmap(pic_5);
var pic_6=new pic6(0,0);
var image_6:Bitmap=new Bitmap(pic_6);
var pic_7=new pic7(0,0);
var image_7:Bitmap=new Bitmap(pic_7);
the variable "picNum" is the total amount of images that in the library, each one exported as "pic1", "pic2", "pic3" respectively.
var picNum:uint=7;
var picCaller:uint=1;
var picMC:MovieClip = new MovieClip();
picMC=this["pic_"+picCaller];
for (var i:int = 1; i <= picNum; i=i+1)
var "pic_"+i = new image_i(0, 0);
var image:Bitmap = new Bitmap("pic_"+i);
Thanks so much for your help.
Maybe you are looking for
-
Dear Experts, Iam filling the table node by column by column.Let us suppose first column has 10 records.Second column records starting with 11'th row.If any body have idea.Plz give rpl. Thanks, Santhosh
-
Hi Portal Gurus Can anyone tell me if it's possible to run report painter/writer reports from the portal? Points always awarded. Thanks in advance, Lee
-
Baan Logistic and SAP Finacial
Hi Friends, we are working on an old BaaN c4 system. Now we intend do migrate to SAP. For the first we want to introduce the SAP finance Module, so the user can slowly get used to the SAP System and then later the logistics. I heard of many customer
-
Completely lost - Crash ALL the time
Hi I am completely lost and really need Dreamweaver to run without crashing all the time... I have websites, some newer some made with Dreamweaver MX. Some pages can be opened and some cannot without crashes??? I run on Windows Vista Ultimate, and al
-
Mass user upload through LSMW and ECATT
Hi Experts, How to upload mass users using LSMW and ECATT. How to use these tcodes and can some one tell me how role mapping is done with these tcodes. I havent't used these before and please giveme the procedure or steps if some one has got. Your an