Table Name Substitution with a varaible
I have the following procedure....
LOOP
FETCH table_cur INTO table_rec;
EXIT WHEN NOT table_cur%FOUND;
TableID := table_rec.TableName;
Office := table_rec.OfficeNum;
Client := table_rec.CliNum;
IF Office = 'Y' AND Client = 'Y' Then
UPDATE TableID
SET OfficeNum = (SELECT OfficeNum
FROM Comd02a
WHERE Comd02a.CliNum = TableID.CliNum
AND Comd02a.LoanNum = TableID.LoanNum);
END IF;
END LOOP;
CLOSE table_cur;
TableID is a vaiable and I keep coming back with an error... How
do I make a reference to a table through a variable...
Thanks in Advance
Sally
null
Brian Lelek (guest) wrote:
: Rashmi Rungta (guest) wrote:
: : Hi,
: : You cannot make a direct reference to a table name thru a
: : variable. You have to use dynamic sql.
: : Hope it helps. Let me know if you need further information on
: how
: : to use dynamic sql.
: : Rashmi
: : Sally (guest) wrote:
: : : I have the following procedure....
: : : LOOP
: : : FETCH table_cur INTO table_rec;
: : : EXIT WHEN NOT table_cur%FOUND;
: : : TableID := table_rec.TableName;
: : : Office := table_rec.OfficeNum;
: : : Client := table_rec.CliNum;
: : : IF Office = 'Y' AND Client = 'Y' Then
: : : UPDATE TableID
: : : SET OfficeNum = (SELECT OfficeNum
: : : FROM
: Comd02a
: : : WHERE Comd02a.CliNum =
: TableID.CliNum
: : : AND Comd02a.LoanNum =
: : TableID.LoanNum);
: : : END IF;
: : : END LOOP;
: : : CLOSE table_cur;
: : : TableID is a vaiable and I keep coming back with an
error...
: : How
: : : do I make a reference to a table through a variable...
: : : Thanks in Advance
: : : Sally
: The previous response is correct. You must use dynamic SQL.
: With dynamic SQL, you create a string in a varchar field that
: contains the SQL statement. Then you pass that string to
Oracle
: for execution. I think that orange and white book has a good
: explanation of dynamic SQL. My copy of the book is not here,
: but I can look it up in a few days if you are still having
: trouble.
: By the way, you may want to consider using a "cursor for
loop".
: This code is more simple because you don't need and OPEN,
FETCH,
: EXIT, or CLOSE. See below:
: FOR table_rec IN table_cur
: LOOP
: END LOOP;
: Brian
Hello,
Yes, you need to use dynamic SQL. If you are using oracle 7 or
8.0.x, you can use the bundled package dbms_sql to do the dynamic
SQL. If you are using 8i (8.1.5), the PL/SQL is improved to do
the dynamic SQL directly. You can now do for example:
begin
execute immediate 'update '
Similar Messages
-
Table Name Substitution with a variable
I have the following procedure....
LOOP
FETCH table_cur INTO table_rec;
EXIT WHEN NOT table_cur%FOUND;
TableID := table_rec.TableName;
Office := table_rec.OfficeNum;
Client := table_rec.CliNum;
IF Office = 'Y' AND Client = 'Y' Then
UPDATE TableID
SET OfficeNum = (SELECT OfficeNum
FROM Comd02a
WHERE Comd02a.CliNum = TableID.CliNum
AND Comd02a.LoanNum = TableID.LoanNum);
END IF;
END LOOP;
CLOSE table_cur;
TableID is a vaiable and I keep coming back with an error... How
do I make a reference to a table through a variable...
Thanks in Advance
Sally
nullHi Sally,
The way this is usually handled in Oracle is to use the DBMS_SQL
package provided with the database to run Dynamic SQL, although
I hear that Oracle 8.1.5 (8i) supports Dynamic SQL without the
use of the DBMS_SQL package. I can only personally tell you
that DBMS_SQL has worked like a charm for me on several
occasions. You'll find reference to this package in several
places, but the best place for explanation is the Oracle Press
book: Oracle PL/SQL Programming.
Hope that helps,
Rob
Sally (guest) wrote:
: I have the following procedure....
: LOOP
: FETCH table_cur INTO table_rec;
: EXIT WHEN NOT table_cur%FOUND;
: TableID := table_rec.TableName;
: Office := table_rec.OfficeNum;
: Client := table_rec.CliNum;
: IF Office = 'Y' AND Client = 'Y' Then
: UPDATE TableID
: SET OfficeNum = (SELECT OfficeNum
: FROM
Comd02a
: WHERE Comd02a.CliNum = TableID.CliNum
: AND Comd02a.LoanNum =
TableID.LoanNum);
: END IF;
: END LOOP;
: CLOSE table_cur;
: TableID is a vaiable and I keep coming back with an error...
How
: do I make a reference to a table through a variable...
: Thanks in Advance
: Sally
null -
Need to know schema name and table name associated with a column-URGENT
Hi folks,
I need to know the schema name and the table name associated with a column. Though jdbc has the api to getTableName and getSchemaName, some database vendor like oracle does return empty upon call of mentioned methods. I found that oracle driver does not support that
Can any one give me the solution? It is urgent. Or do you suggest any third pary jdbc driver which can provide those?
Thanks
AngelinaAngelina,
Your question has been discussed several times previously in this forum. Search this forum's archives for "getTableName". Oracle JDBC driver does not implement this (because "it is not feasible" -- according to Oracle).
First of all, I would suggest that you could probably change your application's logic so that you would not need this functionality (but I guess that is not feasible either, right :-)
Alternatively, you could try querying the Oracle database data dictionary.
Good Luck,
Avi. -
MTL Table name mapped with IC_ITEM_MST_B in oracle apps r12
Hi Experts,
Can anyone suggest me the MTL table name mapped with IC_ITEM_MST_B table in oracle apps with all the columns.
thanks,Response to: I don't see this option "Periodic Sequences in Format" under "Payment Instruction Format" table. I can see only Payment File Information.
You are maybe missing this (from Implementation Guide):
"Note: If no payment system is selected or entered for the Payment
System field in the Payment System subtab of the Update Payment
Process Profile page, then the Periodic Sequences in Format region is
not displayed."
The payment system must be selected at the time you create the profile. It does not seem to allow adding afterwards.
Edited by: user11974306 on Jan 25, 2013 1:49 PM
Edited by: user11974306 on Jan 25, 2013 1:49 PM -
ALL_TAB_COLUMNS table name showing with fancy characters
Dear All
when i execure followowing query and got a table name as BIN$eeHkLT/tL+PgRAAhKBTEWA==$0
select * from all_tab_columns
where column_name like '%APPLICATIONORDER%'
Please let me know what is this and how to select the data from it
thanking youits recycle bin ; please refer to oracle documentation to understand this feature;
see below from oracle documentaion : (http://www.oracle.com/technology/pub/articles/10gdba/week5_10gdba.html)
Managing the Recycle Bin
If the tables are not really dropped in this process--therefore not releasing the tablespace--what happens when the dropped objects take up all of that space?
The answer is simple: that situation does not even arise. When a tablespace is completely filled up with recycle bin data such that the datafiles have to extend to make room for more data, the tablespace is said to be under "space pressure." In that scenario, objects are automatically purged from the recycle bin in a first-in-first-out manner. The dependent objects (such as indexes) are removed before a table is removed.
Similarly, space pressure can occur with user quotas as defined for a particular tablespace. The tablespace may have enough free space, but the user may be running out of his or her allotted portion of it. In such situations, Oracle automatically purges objects belonging to that user in that tablespace.
In addition, there are several ways you can manually control the recycle bin. If you want to purge the specific table named TEST from the recycle bin after its drop, you could issue
PURGE TABLE TEST;
or using its recycle bin name:
PURGE TABLE "BIN$04LhcpndanfgMAAAAAANPw==$0";
This command will remove table TEST and all dependent objects such as indexes, constraints, and so on from the recycle bin, saving some space. If, however, you want to permanently drop an index from the recycle bin, you can do so using:
purge index in_test1_01;
which will remove the index only, leaving the copy of the table in the recycle bin.
Sometimes it might be useful to purge at a higher level. For instance, you may want to purge all the objects in recycle bin in a tablespace USERS. You would issue:
PURGE TABLESPACE USERS;
You may want to purge only the recycle bin for a particular user in that tablespace. This approach could come handy in data warehouse-type environments where users create and drop many transient tables. You could modify the command above to limit the purge to a specific user only:
PURGE TABLESPACE USERS USER SCOTT;
A user such as SCOTT would clear his own recycle bin with
PURGE RECYCLEBIN;
You as a DBA can purge all the objects in any tablespace using
PURGE DBA_RECYCLEBIN;
As you can see, the recycle bin can be managed in a variety of different ways to meet your specific needs. -
I want to create a PLSQL process that deletes rows from a table I identified by an item.
This does not work....throws the Error:
ORA-06550: line 4, column 29: PL/SQL: ORA-00903: invalid table name ORA-06550: line 4, column 1: PL/SQL: SQL Statement ignored
declare
begin
delete from staging.:P110_TABLE_NAME;
end;
What am I doing wrong here in the P110_TABLE_NAME substitution?
Edited by: user581839 on Dec 23, 2008 4:32 PMTry it this way
declare
begin
Execute immediate 'delete from staging.' || trim( :P110_TABLE_NAME);
end;Varad -
Table names for with holding tax
Hi all,
please can any body tellme few table names for withholding tax
thankshii...
you can use...
A399 Withholding tax code - country-specific
others are
/CCEE/FISISTGRD Reasons for Reversal enabling to change t
/CCEE/SIFICUSTPR Mapping table for customer procedure numb
A399 Withholding tax code - country-specific
BSIUDTT HR-US: BSI test data (tax record)
BTXEMPT BSI: Employee tax results
BTXERES BSI: Employee/Employer tax
CIMSYN Syntax Description for Extensions
COMC_R3_FIELDS Assignment of R/3 material master fields
CRMRDTRMSG Check Results Management: Texts of Messag
DFKKARREPCONTST ARGENTINA: Legal report sales tax control
EDISYN Syntax Description for Extended Basic Typ
EDSYN IDoc syntax after 3.0
ETXDCH External tax document: header info
ETXDCI External tax document: line item info
ETXDCJ Ext. tax document: tax rates and amounts
regards -
File name substitution with Data pump
Hi,
I'm experimenting with Oracle data pump export, 10.2 on Windows 2003 Server.
On my current export scripts, I am able to create the dump file name dynamically.
This name includes the database name, date, and time such as the
following : exp_testdb_01192005_1105.dmp.
When I try to do the same thing with data pump, it doesn't work. Has anyone
had success with this. Thanks.
ed lewisHi Ed
This is an example for your issue:
[oracle@dbservertest backups]$ expdp gsmtest/gsm directory=dpdir dumpfile=exp_testdb_01192005_1105.dmp tables=ban_banco
Export: Release 10.2.0.1.0 - Production on Thursday, 19 January, 2006 12:23:55
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Starting "GSMTEST"."SYS_EXPORT_TABLE_01": gsmtest/******** directory=dpdir dumpfile=exp_testdb_01192005_1105.dmp tables=ban_banco
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type TABLE_EXPORT/TABLE/COMMENT
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "GSMTEST"."BAN_BANCO" 7.718 KB 9 rows
Master table "GSMTEST"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
Dump file set for GSMTEST.SYS_EXPORT_TABLE_01 is:
/megadata/clona/exp_testdb_01192005_1105.dmp
Job "GSMTEST"."SYS_EXPORT_TABLE_01" successfully completed at 12:24:18
This work OK.
Regards,
Wilson -
Table name ? with query name , variable name and variant .
Hi All,
Is there any single table with fields as query name , variable name and variant ?
or any table which i can build a view to get these fields.
or any other way ?? to get this fields in single table
Thanks,
AkHi,
first use the proper heading for a question.
you want the query all details means technical name, variable and variable type use RSRTQ
it will give total information of query.
Bex related tables
RSZELTDIR ----
Directory of the reporting component elements
RSZELTTXT ----
Texts of reporting component elements
RSZELTXREF ---
Directory of query element references .
Thanks,
Phani. -
Table names in generated stored procs are qualified with sa schema name
I am using OMW 9.2.0.1.2 with the 9.2.0.1.3 SQL Serevr plugin to help with a SQL Server 7 to Oracle 9.2.0.1 migration on NT.
As is common with SQL Server databases, the dbo is sa. I don't want my Oracle schema to be called sa. I have succesfully gotten around this by renaming the sa user in the Oracle model in OMW.
However, the stored procedure code that OMW generates has table names qualified with sa as the schema (the tables names in the original T/SQL procs were not qualified).
How can I stop OMW from generating table names qualified with sa?
Thanks.Hi,
this is a bug in the OMWB. As a workaround, you can generate the migration scripts (see reference guide and user guide for more information) from the OMWB Oracle Model and then edit these scripts to ensure that the 'sa' prefix does not appear in the text of the stored procedures. Then use these scripts to generate the schema in your database.
An alternative is to migrate the stored procedures, schema and data over to the Oracle database using OMWB and then open each procedure in Enterprise Manager, remove the references to the 'sa' prefix and re-compile the procedure.
I will keep you updated on the release this fix will appear in.
I hope this helps,
Tom. -
Hello,
I can't find the right syntax to do what I need, if it's possible :
Context :
I work actualy on a migration from MS Access applications to Oracle (datas only). So I copied all MS Access Tables into Oracle and created manualy all the relationnal constraints like primary and foreign keys ('cause constraints are not included in 'Copy to Oracle').
I Have often to refresh my datas, because the MS access applications are still in use. Therefore I wrote PL/SQL scripts. They do the folowing, using dynamic SQL with 'Execute Immediate' statement :
Script 1
- disable all user's constraints
- disable all user's triggers
- truncate all user's tables
(Here, I have to do a manual copy of all MS Access tables to Oracle, checking the Append check-box, because the BRIDGE statement doesn't support 'Execute Immediate', and wait...)
Script 2
- enable all user's constraints
- enable all user's triggers
Could someone let me know how Il could do the same as :
For t in (select table_name from user_tables) loop
-- Copy the datas from an Access table into the same Oracle table
execute immediate ('BRIDGE ' || t.table_name || ' AS MyAccessConnName(select * from ' || t.table_name || ') APPEND') ;
-- News flash ...
dbms_output.put_line('Table ' || t.table_name || ' filled') ;
end loop;
-------------------------------------------------------------------------------------------------------------------------- ==> 00900. 00000 - "invalid SQL statement"
If a dynamic table name substitution is applicable in the Bridge statement from a query, I take it with joice!
Thank you for helping me...
DanielHi Daniel,
The BRIDGE statement is just an extra command I implemented in the SQL Developer worksheet script runner.
It gets interpreted by SQL Developer and it dynamically creates (CREATE TABLE , INSERT INTO , SELECT ... ) statements and runs them against the connections specified.
It was developed to improve certain migration features of SQL Developer. We haven't really spent any time developing it into a customer friendly statement to be used in custom scripts.
Hence the lack of doc. But it is there and if you can make it work for yourself all the better.
When I say "One way of doing what you want". I mean I haven't thought about your particular problem exhaustively and I wouldn't want you to take my solution as gospel :)
If you are happy running a script in SQL Developer, but would rather not run 2 scripts , or cut and paste results around, you could SPOOL the results and execute them.
--call your other scripts to disable constraints during the data move
set echo off;
set feedback off;
set linesize 1000;
set pagesize 0;
set headsep off;
set termout off;
set verify off;
set heading off;
SET PAGES 0;
SET HEAD OFF;
spool c:\mydynamicscript.sql
select 'BRIDGE ' || table_name || ' AS MyAccessConnName(select * from ' || table_name||');' from user_tables ;
spool off
@c:\mydynamicscript.sql
--call another script to enable your constraints again
Regards,
Dermot.
SQL Developer Team. -
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/ -
Need to know schema and table name
Hi folks,
I need to know the schema name and the table name associated with a column. Though jdbc has the api to getTableName and getSchemaName, some database vendor like oracle does return empty upon call of mentioned methods. I found that oracle driver does not support that ��
Can any one give me the solution? It is urgent. Or do you suggest any third pary jdbc driver which can provide those?
Thanks
Angelinahi,
does not work for me.
more pls
--thanks -
Hello, are there any possibilities to use the same table names in different SAP JPA EJB? For example, the first project has entity with a name History and the table name is TMP_HISTORY. The second one has also the entity History with a table name TMP_HISTORY with other columns. In such case it's impossible to deploy the second one dictionary.
Hi Kirill,
if you use the System Data Source, it is obvious that there is the same table and you cannot deploy the 2nd application.
If you use two different data sources and set the datasource type to "native" or "vendor" in NetWeaver Administrator, it should work.
Regards
Rolf -
Hi,
say I am doing a generic program that must retreive the table/view names and the number rows they hold.
I am using the DatabaseMetaData.getTables to grab each table name, along with its schema and catalog.
Then, I would send a request "SELECT COUNT(*) FROM "+myFullyQualifiedTableName to get the number of rows.
My question is : given a table name with its schema and catalog names, whar is the value of the variable myFullyQualifiedTableName ?
is it <catalog>.<schema>.<table> ?
<schema>.<catalog>.<table> ?
something else ?
and what if there is no catalog and/or no schema name ?
thanks for your help,
cdThis is true on Oracle only, AFAIK.
anyway, on oracle, if you connect as user1, you can see the tables belonging to user2, provided you are granted for that. The User is the schema
On M$SQLServer, you can see all the tables in all the databases hosted on the server you are connected to. theDatabase is the schema.
Maybe you are looking for
-
How do i know if my lost ipod touch has been reset?
I have lost it a couple of days ago and am using FIND MY IPHONE and it says that my iPod is offline. Does this mean it has been reset or it is still out there?
-
Allow Networking Disabled when Webpage Renders in an App Hosting Webbrowser Control
Was there a change with Security for Network requests for Flash player 11.4? I have a Windows Application that hosts the Webbrowser Control. When browsing webpages with Flash files that load external requests, the Flash ActiveX control does not load
-
SSRS 2008 R2:Export to excel error
Hello, I have a report which has 28 columns, one expression for generating alternate row colors, 2 images in the page header. Users are able to render the report in report manager url with in 20 seconds but they are unable to export the report to exc
-
Prime Infrastructure v1.3 -- Boot fails, displays debug info
Prime website stopped responding so I logged onto the console (VM) and it had these debug errors on it. I rebooted and received same thing. This happened on a previous install as well. However, I can SSH to the appliance, but the website doesn't load
-
Detail of stock transport order
pls i need detail step of stock transport order