Update SAME column name in two tables from ONE query
Dear All Seniors
Please tell me is it possible to update a same column name in two tables.
I have two tables in same schema
(1)table name
pem.igp_parent
column name
igp_no.
igp_type
(2)table name
pem.igp_child
column name
igp_no.
igp_type
i want to update igp_no column in one query please tell me how it would be possible.
thanks
yassen
You want to update the data from what to what? Where is the new data coming from?
If you are trying to put the same data in two different tables, that strongly implies that you have a normalization problem that needs to be addressed.
Why do you want a single query rather than updating each table in turn? Can you join the two target tables to produce a key-preserved view?
Justin
Similar Messages
-
How to pass column name as a values from one page to another
hi
i have created a report(pivot) from a table
SQL> SELECT * FROM T;
C1 C2 C3 D SEQ
A AA 2 1
A AB 3 2
A AC 2 3
B AB 5 4
B AC 6 5
SQL> SELECT C1
2 ,NVL(MAX(CASE WHEN C2='AA' THEN C3 END),'') AA
3 ,NVL(MAX(CASE WHEN C2='AB' THEN C3 END),'') AB
4 ,NVL(MAX(CASE WHEN C2='AC' THEN C3 END),'') AC
5 ,SUM(C3) FROM T GROUP BY C1;
C1 AA AB AC SUM(C3)
A 2 3 2 7
B 5 6 11
SQL>
my requirement in Apex is like this(reverse)
eg-
when i click on cell values '2' then,it should return
C1 C2 C3 D SEQ
A AA 2 1
{quote}how to pass column name as a values from one page to another
for example i have to pass 'c2' as a value to next page{quote}for report pivot you can reffer below link
Report
Amuthanks for your reply
i 'm doing what exactly you mention here .
my problem here is
i have 15 columns
i am executing a query based on the values of the column(column name) in the target page
1)here i am passing(all) the column values to the next page-but i want to pass only one column values(column name)
when i click on any cell of that column
OR
2)i can pass all column name to target page -there(in the target page) i can filter out
i think option 1 would good if you filter out the unwanted columns
Regards
Amul -
How To Create Table View With Same Column name But Different Table?
Hi All,
I have the problem to create a tableview with same column name but in different table.
The Table that i have:-
Table - PAC051MPROFORMA
Column - mrn,visitid
Table - PAC051TPROFORMA
Column - mrn,visitid
Table - PAC052MTRANSBILL
Column - mrn,visitid
Then i want to create a table view to view that table. This is my SQL
CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid)
As Select PAC051MPROFORMA.mrn,PAC051MPROFORMA.visitid,PAC051TPROFORMA.mrn,PAC051TPROFORMA.visitid,PAC052MTRANSBILL.mrn,PAC052MTRANSBILL.visitid
where
*(a.PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)*
and
*(a.PAC051TPROFORMA.mrn=PAC052TRANSBILL.mrn)*
That SQL Return this error = ORA-00957: duplicate column name
Then I modify that SQL to
CREATE VIEW pacviewproforma (mrn,visitid)
As Select PAC051MPROFORMA.mrn,PAC051MPROFORMA.visitid,PAC051TPROFORMA.mrn,PAC051TPROFORMA.visitid,PAC052MTRANSBILL.mrn,PAC052MTRANSBILL.visitid
where
*(a.PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)*
and
*(a.PAC051TPROFORMA.mrn=PAC052TRANSBILL.mrn)*
This time this error return = ORA-01730: invalid number of column names specified
What should i do?
Thanks...Hi,
SQL> CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid)
2 As Select
3 PAC051MPROFORMA.mrn,
4 PAC051MPROFORMA.visitid,
5 PAC051TPROFORMA.mrn,
6 PAC051TPROFORMA.visitid,
7 PAC052MTRANSBILL.mrn,
8 PAC052MTRANSBILL.visitid
9 from PAC051MPROFORMA,PAC051TPROFORMA,PAC052MTRANSBILL
10 where
11 (PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)
12 and
13 (PAC051TPROFORMA.mrn=PAC052MTRANSBILL.mrn);
CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid)
ERROR at line 1:
ORA-00957: duplicate column namePlease give different names to each column.
Something like this..
SQL> CREATE OR REPLACE VIEW pacviewproforma (MPROFORMA_mrn,MPROFORMA_visitid,TPROFORMA_mrn,TPROFORMA
_visitid,MTRANSBILL_mrn,MTRANSBILL_visitid)
2 As Select
3 PAC051MPROFORMA.mrn,
4 PAC051MPROFORMA.visitid,
5 PAC051TPROFORMA.mrn,
6 PAC051TPROFORMA.visitid,
7 PAC052MTRANSBILL.mrn,
8 PAC052MTRANSBILL.visitid
9 from PAC051MPROFORMA,PAC051TPROFORMA,PAC052MTRANSBILL
10 where
11 (PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)
12 and
13 (PAC051TPROFORMA.mrn=PAC052MTRANSBILL.mrn);
View created.
SQL> DESC pacviewproforma;
Name Null? Type
MPROFORMA_MRN NUMBER
MPROFORMA_VISITID NUMBER
TPROFORMA_MRN NUMBER
TPROFORMA_VISITID NUMBER
MTRANSBILL_MRN NUMBER
MTRANSBILL_VISITID NUMBER
ORA-01730: invalid number of column names specifiedThe list of column nmae you specified during the CREATE VIEW should match with the SELECT list of the view.
Twinkle -
How to read the column name of a table from sap system using C#?
Hi!!
I am using SAP .NET connector and creating a windows application.
Now I wanna read the column name when a table name is given....
Connection is done, but I don't know the code to read the column names alone...
Can anyone help me with the code??fine!!
So if i give the table name, which the RFC_READ_TABLE function module have, will it run properly? or i wanna change all the codes in order to support RFC_READ_TABLE function module?
Because from the beginning I was using BAPI_CUSTOMER_GETLIST function, but my client requirement is to use ERP function module RFC_READ_TABLE, he didn't give any table name also..
This is my code: What I have to change in this???
ECCDestinationConfig ECCDestination = new ECCDestinationConfig();
RfcDestinationManager.RegisterDestinationConfiguration(ECCDestination);
RfcDestination rfcDest = null;
rfcDest = RfcDestinationManager.GetDestination(a);
RfcRepository repo = rfcDest.Repository;
IRfcFunction customerList = repo.CreateFunction("BAPI_CUSTOMER_GETLIST");
IRfcTable addressData = customerList.GetTable("AddressTable"));
int j = addressData.Metadata.LineType.FieldCount;
for (int i = 0; i < j; i++)
RfcElementMetadata metadata = addressData.GetElementMetadata(i);
listallcolumn.Items.Add(metadata.Name);
Message was edited by: Jeswin Rebil -
How to make two tables from one single taable
Hi,
i have one table with 100 records and i want to create two tables each with 50 records and with no duplicates. if i will do on bases on empno then i have to check the min and max emp no and then divide them in two tables, is there any automate way of performing this task.
Regards,
AbidaHi,
A rather quick and dirty solution, but definitely works.
I used the HR sample schema (employees table) for this.
hsaprd@706447>create table tab1 as select * from employees where rownum <51;
Table created.
hsaprd@706447>select count(*) from tab1;
COUNT(*)
50
hsaprd@706447>create table tab2 as select * from employees where employee_id nnot in (select employee_id from tab1);
Table created.
hsaprd@706447>select count(*) from tab2;
COUNT(*)
56
hsaprd@706447>
Hope this helps!
-Anand -
Count number rows in multiple tables from one query
Hi
I was wondering if its possible to have a single query return the number of lines in multiple tables, for example i have the tables
foo1
pk_foo1
and
foo2
pk_foo2
They are not joined together by any contraints. So the pseudo code for the query would be something like
SELECT numrows(pk_foo1), numrows(pk_foo2) FROM foo1, foo2
Thanks!without a join you get a cartesian product for the query:
SQL> select count(d.deptno),count(e.deptno)
2 from dept d,emp e
3 /
COUNT(D.DEPTNO) COUNT(E.DEPTNO)
105 105so you need to do a bit of trickery
1 select a.cnt,b.cnt
2 from
3 ( select count(d.deptno) cnt from dept d ) a,
4* ( select count(e.deptno) cnt from emp e) b
SQL> /
CNT CNT
7 15
SQL> select count(*) from dept;
COUNT(*)
7
SQL> select count(*) from emp;
COUNT(*)
15 -
Deleting from multiple tables where few tables have same column name
Hi,
I am new to PL/SQL and need some help. I need to delete data older then X years from some 35 odd tables in my schema and out of those tables 25 tables have same column name on which i can have my "where" clause and rest 10 table have different table names. I am doing something like this :
declare
table_list UTL_FILE.FILE_TYPE;
string_line VARCHAR2(1000);
tables_count number:=0;
table_name VARCHAR2(400);
column_name VARCHAR2(400);
BEGIN
table_list := UTL_FILE.FOPEN('ORALOAD','test7.txt','R');
DBMS_OUTPUT.PUT_LINE(table_list);
LOOP
UTL_FILE.GET_LINE(table_list,string_line);
table_name := substr(string_line,1, instr(string_line,'|')-1);
column_name := substr(string_line, instr(string_line,'|')+1);
DBMS_OUTPUT.PUT_LINE(table_name);
DBMS_OUTPUT.PUT_LINE(column_name);
IF column_name = 'SUBMISSION_TIME' THEN
delete from :table_name where to_date(:column_name)<(sysdate-(365*7));
ELSE
delete from || table_name || where ( || to_date(column_name) || ) <(sysdate-(365*7));
END IF;
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND THEN
UTL_FILE.FCLOSE(table_list);
DBMS_OUTPUT.PUT_LINE('Number of Tables processed is : ' || tables_count);
UTL_FILE.FCLOSE(table_list);
END;
WHERE the text file "text7.txt" contains list of table name and column names separated by a pipe line. But when I execute the above proc it gives error "invalid table name".
Can something like this be done or is there any other way to execute this task of deletion from 35 tables.
Thanks.Thanks for replies. I don't know what I am doing wrong but still not getting this damn thing work...This is the proc i am running now :
declare
table_list UTL_FILE.FILE_TYPE;
string_line VARCHAR2(1000);
tables_count number:=0;
table_name VARCHAR2(4000);
column_name VARCHAR2(4000);
code_text VARCHAR2(2000);
BEGIN
table_list := UTL_FILE.FOPEN('ORALOAD','test7.txt','R');
LOOP
UTL_FILE.GET_LINE(table_list,string_line);
table_name := substr(string_line,1, instr(string_line,'|')-1);
column_name := substr(string_line, instr(string_line,'|')+1);
IF column_name = 'SUBMISSION_TIME' THEN
DBMS_OUTPUT.PUT_LINE('do nothing');
ELSE
code_text:= 'begin delete from'|| (table_name) ||'where to_date' || (column_name) || '<(sysdate-(365*7))';
Execute Immediate code_text;
END IF;
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND THEN
UTL_FILE.FCLOSE(table_list);
DBMS_OUTPUT.PUT_LINE('Number of Tables processed is : ' || tables_count);
UTL_FILE.FCLOSE(table_list);
END;
But it gives following error :
" ORA-06550: line 1, column 51:
PL/SQL: ORA-00933: SQL command not properly ended
ORA-06550: line 1, column 7:
PL/SQL: SQL Statement ignored
ORA-06550: line 1, column 68:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
ORA-06512: at line 22 " -
How to rename a column name while copying it from another table
Hi All,
I am copying rows between two table TableA to TableB
but I wanted to insert data in he column name (username) in tableA to a column named (NewUser) in tableB
How do I go about that?
insert into TableB
select Username
from TableA
ThanksIf you want to only move username, then just specify the column name for TableB, that is
insert into TableB(NewUser)
select Username
from TableA
If you want to move all (or some) of the columns while putting Username in a column named NewUser, just list the columns in both the insert into part and the select part, for example
insert into TableB(NewUser, ColA, ColB, ColC)
select Username, ColA, ColB, ColC
from TableA
Tom -
How to Select data using same column name from 3 remote database
Hi,
Can anyone help me on how to get data with same column names from 3 remote database and a single alias.
Ex.
SELECT *
a.name, b.status, SUM(b.qty) qantity, MAX(b.date) date_as_of
FROM
*((table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3)a,*
*(table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3)b)*
WHERE b.dept = 'finance'
AND a.position = 'admin'
AND a.latest = 'Y' AND (b.status <> 'TRM') AND b.qty > 0;
GROUP BY a.name, b.status ;
NOTE: the bold statements is just an example of what I want to do but I always gets an error beacause of ambiguous columns.
Thanks in advnce. :)
Edited by: user12994685 on Jan 4, 2011 9:42 PMuser12994685 wrote:
Can anyone help me on how to get data with same column names from 3 remote database and a single alias.Invalid. This does not make sense and breaks all scope resolution rules. And whether this is in a single database, or uses tables across databases, is irrelevant.
Each object must be uniquely identified. So you cannot do this:
select * from (table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3) a3 objects cannot share the same alias. Example:
SQL> select * from (dual, dual) d;
select * from (dual, dual) d
ERROR at line 1:
ORA-00907: missing right parenthesisYou need to combine the objects - using a join or union or similar. So it will need to be done as follows:
SQL> select * from (select * from dual d1, dual d2) d;
select * from (select * from dual d1, dual d2) d
ERROR at line 1:
ORA-00918: column ambiguously definedHowever, we need to have unique column names in a SQL projection - so the join of the tables need to project a unique set of columns. Thus:
SQL> select * from (select d1.dummy as dummy1, d2.dummy as dummy2 from dual d1, dual d2) d;
DUM DUM
X X
SQL> I suggest that you look closely at what scope is and how it applies in the SQL language - and ignore whether the objects referenced are local or remote as it has no impact to fundamentals of scope resolution. -
View the tables with same column name
Hi all
I have 10-20 tables and they have some same column names
How can I know it?
I mean, I want to know the tables which have the common column names
Thanks...SQL> break on column_name
SQL> set linesize 1000
SQL> set pagesize 10000
SQL> select column_name, owner, table_name
2 from (select owner, table_name, column_name, count(*) over (partition by column_name) ct
3 from dba_tab_columns)
4 where ct>1
SQL> /
COLUMN_NAME OWNER TABLE_NAME
AADSAS_ID_NBR H89UCBAC PS_SAD_ADA_CD
H89UCBAC PS_SAD_ADA_SUS
H89UCBAC PS_SAD_ADA_TMP
AA_CODE H89UCBAC PS_RQ_CONDIN_SLVW
H89UCBAC PS_RQ_CONDIN_SRCH
H89UCBAC PS_DUMMYDESCR_LANG
H89UCBAC PS_DUMMY_DESCR
H89UCBAC PS_RQ_NOTINCOND_LV
H89UCBAC PS_RQ_NOTINCOND_SR
[...]Nicolas. -
I am looking for the best way (or any way) to interact between two different frames in the same indesign template as well as from one template to another. It's for a DPS app which needs to carry some button initiated data from one page to another and then present it in a table.
There is no simple way to do it, as itunes wont let you use it on another computer without wiping the contents first.
However if you really want to transfer songs to another computer then you could try this;
* make sure that your ipod is accessible as a disk drive (ipod options)
* when you plug your ipod into the computer you want to transfer to make sure you select "no" or "cancel" when it asks to wipe the contents. Leave the ipod connected and quit from itunes.
* go to "my computer" and access the ipod directly. You probably have to select "view hidden files" from windows. You will see a lot of folders with odd names like ZX838aff with similar named files inside.
* copy these files to a folder on your computers hardrive. Now remove the ipod and start itunes.
* import the files from the folder you made in the last step.
* Now your music is on itunes, but with unrecogisable names.
This is the only way I have found to do it, but there may be another way, say with an application to do the hard work for you.
Generic homebuild PC Windows XP
Generic homebuild PC Windows XP -
What is the use of Position Column Name in USER_CONS_COLUMNS Table
Please let me know the purpose of POSITION Column Name in USER_CONS_COLUMNS Table.
Example :
Created this below Table having two constraints 1.Primary Key 2.Check Constraint
CREATE TABLE A(ID NUMBER PRIMARY KEY,NAME VARCHAR2(30),SAL NUMBER CHECK (SAL > 0))
When i execute the below query
SELECT POSITION,CONSTRAINT_NAME FROM USER_CONS_COLUMNS WHERE TABLE_NAME = 'A'
it displays the data :
POSITION CONSTRAINT_NAME
1 SYS_C005488
SYS_C005487
Only for the first record it displays the POSITION but not for the second row.
Kindly help me on this.SQL> CREATE TABLE A(
2 ID1 NUMBER
3 , ID2 NUMBER
4 , NAME VARCHAR2(30)
5 , SAL NUMBER CONSTRAINT A_SAL_POSITIVE CHECK (SAL > 0)
6 , CONSTRAINT A_PRIMARY_KEY PRIMARY KEY (ID1, ID2)
7 )
8 /
Table created.
SQL> SELECT CONSTRAINT_NAME, POSITION, COLUMN_NAME
2 FROM USER_CONS_COLUMNS
3 WHERE TABLE_NAME = 'A'
4 ORDER BY CONSTRAINT_NAME, POSITION
5 /
CONSTRAINT_NAME POSITION COLUMN_NAME
A_PRIMARY_KEY 1 ID1
A_PRIMARY_KEY 2 ID2
A_SAL_POSITIVE SALA primary key constraint can have multiple columns - the position shows the order the columns are in the primary key definition (and thus also in the pk supporting index.)
A check constraint does not have any such ordering of the columns involved, so therefore position is null. -
How do you join two tables from different Oracle schemas using a subquery
I am trying to join two tables from different Oracle schemas using a subquery. I can extract data from each of the tables without a problem. However, when I combine the select statements using a subquery I get the Oracle error *'ORA-00936: missing expression'*. Since each SELECT statement executes on its own without error I don't understand what is missing. The result set I am trying to get is to match up the LINE_ID from PDTABLE_12_1 in schema DD_12809 with the MAT_DESCRIPTION from table PDTABLE_201 in schema RA_12809.
The query is as follows:
sql = "SELECT [DD_12809].[PDTABLE_12_1].LINE_ID FROM [DD_12809].[PDTABLE_12_1] JOIN " _
+ "(SELECT [RA_12809].[PDTABLE_201].MAT_DESCRIPTION " _
+ "FROM [RA_12809].[PDTABLE_201]) AS FAB " _
+ "ON [DD_12809].[PDTABLE_12_1].PIPING_MATER_CLASS = FAB.PIPING_MATER_CLASS"
The format of the query is copied from a SQL programming manual.
I also tried executing the query using a straight JOIN on the two tables but got the same results. Any insight would be helpful. Thanks!
Edited by: user11338343 on Oct 19, 2009 6:55 AMI believe you are receiving the error because you are trying to JOIN on a column that doesn't exist. For example you are trying to join on FAB.PIPING_MATER_CLASS but that column does not exist in the subquery.
If you want to do a straight join without a subquery you could do the following
SELECT DD_12809.PDTABLE_12_1.LINE_ID
, FAB.MAT_DESCRIPTION
FROM DD_12809.PDTABLE_12_1
JOIN RA_12809.PDTABLE_201 AS FAB ON DD_12809.PDTABLE_12_1.PIPING_MATER_CLASS = FAB.PIPING_MATER_CLASS HTH! -
How to get the column names of the table into the Dashboard prompt
how to get the column names of the table into the Dashboard prompt
Thanks & Regards
Kishore PHey john,
My requirement is as follows
I have created a Rank for Total sales by Region wise i.e RANK(SUM(Dollars By Region)) in a pivot table.
My pivot table looks like this
COLUMN SELECTOR: TOTAL US , REGION , DISTRICT , MARKET
---------------------------------------------------- JAN 2009 FEB 2009 MAR 2009
RANK REGION DOLLARS DOLLARS DOLLARS DOLLARS
1 CENTRAL 10 20 30 40
2 SOUTHERN 10 30 30 70
3 EASTERN 20 20 20 60
4 WESTERN 10 20 30 40
When i select the District in column selector
Report has to display rank based on Total Sales by District. i.e
------------------------------------------------- JAN 2009 FEB 2009 MAR 2009
RANK DISTRICT DOLLARS DOLLARS DOLLARS DOLLARS
for this i need to change the fx of rank i.e RANK(SUM(Dollars By Region)) to RANK(SUM(Dollars By District)) and fx of Region i.e Markets.Region to Markets.District dynamically.
so , i need to capture column name of the value selected from the column selector and dynamically i need to update the fx 0f RANK & fx of region.
do you have any solution for this?
http://rapidshare.com/files/402337112/Presentation1.jpg.html
Thanks & Regards
Edited by: Kishore P on Jun 24, 2010 7:24 PM
Edited by: Kishore P on Jun 24, 2010 7:28 PM -
Delete from two tables in one statement
Hi,
Is there a way to delete from two tables in one statement?
Actually I have two tables:
1. Base table (id, name, age)
2. Person table (id, city, street)
The id in both tables is identical.
I would like to delete using something like a join:
Delete from base, person where id=2;
Thanks
dyahavHi,
If you want to delete records both at a time them your table must use ON DELETE CASCADE. See the below example.
CREATE TABLE supplier
( supplier_id numeric(10) not null,
supplier_name varchar2(50) not null,
contact_name varchar2(50),
CONSTRAINT supplier_pk PRIMARY KEY (supplier_id)
CREATE TABLE products
( product_id numeric(10) not null,
supplier_id numeric(10) not null,
CONSTRAINT fk_supplier
FOREIGN KEY (supplier_id)
REFERENCES supplier(supplier_id)
ON DELETE CASCADE
In this example, we've created a primary key on the supplier table called supplier_pk. It consists of only one field - the supplier_id field. Then we've created a foreign key called fk_supplier on the products table that references the supplier table based on the supplier_id field.
Because of the cascade delete, when a record in the supplier table is deleted, all records in the products table will also be deleted that have the same supplier_id value.
Thank you.
Maybe you are looking for
-
IPhone 4s won't sync to iMac, isn't recognized as a device in iTunes or iPhoto.
my iPhone 4s is not recognized as a device in iTunes or on my iMac. Doesn't show up in Wifi cloud sync as a device either. It's charging now via my iMac so the USB cord is good. I am on iTunes v.11.1.1 and Mac OS X v. 10.8.5. All other SW updates com
-
Restore previous session button available on my Firefox homepage is great, but what I really want is the Save and Quit feature. I have always felt that its one of the best features of Firefox, second only to search address bar directly leading me to
-
Display many fields of a lookup table in the main table
Hello Experts, In MDM, I have a "Suppliers" table which is a lookup table. This table has 4 fields : - Supplier Name (Display Field) - Supplier Code - Email - Phone number In the main table, a field "Supplier" uses the "Suppliers" lookup table. This
-
I consider myself a fairly savvy Mac user. I update regularly, NEVER drop my computer or have it near food, have good firewall protection, and I even preordered Mac OS Leopard. I recently installed Microsoft Office on my Mac, and, out of sheer lazine
-
Sending a SOAP response immediately upon receipt - synchronous interface
Hi, We have an outbound synchronous SOAP interface on XI which is called by a sender system. Although the process is asynchronous, the sender system can only handle synchronous web service calls (apparently some limitation of that system). What I wou