Home » SQL & PL/SQL » SQL & PL/SQL » compare columns between tables (Oracle 9i, PL/SQL Developer)
compare columns between tables [message #320186] Wed, 14 May 2008 04:46 Go to next message
Hero_2007
Messages: 2
Registered: May 2008
Location: London
Junior Member
I am new here and to Oracle, so please be gentle.

I am trying to compare columns in two existing tables 'T_CLASSNAME' and 'T_ATTRIBUTES'

Both tables have the columns called 'CLASS' that contains class name such as 'SWITCH' and 'ATTRIBUTES' that contains attributes associated with the class such as 'HEAT' or 'SIZE'. The 'ATTRIBUTES' in 'T_ATTRIBUTES' is updated regularly.

The aim is to write a procedure that will allow 'T_CLASSNAME' to check with 'T_ATTRIBUTES' to see if any new attributes has been added for a particular CLASS, if so add the new attributes into the 'T_CLASSNAME' table.

I hope this make sense, any help would be appreciated, many thanks.
Re: compare columns between tables [message #320195 is a reply to message #320186] Wed, 14 May 2008 05:06 Go to previous messageGo to next message
S.Rajaram
Messages: 1027
Registered: October 2006
Location: United Kingdom
Senior Member
Welcome to the forum.

How about posting some sample data and what you have tried so far. Since you are new to oracle start reading the oracle reference manual.

http://tahiti.oracle.com

Regards

Raj
Re: compare columns between tables [message #320202 is a reply to message #320186] Wed, 14 May 2008 05:21 Go to previous messageGo to next message
Hero_2007
Messages: 2
Registered: May 2008
Location: London
Junior Member
Many thanks for the reply,

How do I post sample data here?
Re: compare columns between tables [message #320216 is a reply to message #320202] Wed, 14 May 2008 05:48 Go to previous messageGo to next message
S.Rajaram
Messages: 1027
Registered: October 2006
Location: United Kingdom
Senior Member
Browse this forum and you will understand what I mean by posting the sample data and how they have done it and following the same. Most important is read the forum guidelines on how to format your post before posting it.

Regards

Raj
Re: compare columns between tables [message #320236 is a reply to message #320216] Wed, 14 May 2008 07:11 Go to previous messageGo to next message
pablolee
Messages: 2834
Registered: May 2007
Location: Scotland
Senior Member
@Raj I would not consider it spoon feeding to tell a newbie poster exactly how to post sample data. Wink


@OP post create table statements and insert statements like so:

CREATE TABLE table1 (colA Number, Colb VARCHAR2(20));

CREATE TABLE table2 (col2A Number, col2b number, col3 date, col4 varchar2(10));

INSERT INTO table1 VALUES (1, 'Spike');
INSERT INTO table1 VALUES (2, 'Tom');
INSERT INTO table1 VALUES (3, 'Jerry');
INSERT INTO table2 VALUES (1, 2, SYSDATE, 'X');
INSERT INTO table2 VALUES (2, 2, SYSDATE, 'Y');
INSERT INTO table2 VALUES (3, 1, SYSDATE, 'AB');

That way, people can get a better idea of your data and can play about with it more easily to help you out.
Also remember to post what you would expect the result to be from your query.
But before you go any further, have a look at the forum guidelines here
Re: compare columns between tables [message #320240 is a reply to message #320236] Wed, 14 May 2008 07:17 Go to previous messageGo to next message
S.Rajaram
Messages: 1027
Registered: October 2006
Location: United Kingdom
Senior Member
To be honest I was so lazy to type it and show how to do it. Hence I opted for the lazy approach asking the OP to browse the forum Smile

Regards

Raj
Re: compare columns between tables [message #320242 is a reply to message #320240] Wed, 14 May 2008 07:19 Go to previous message
pablolee
Messages: 2834
Registered: May 2007
Location: Scotland
Senior Member
Laughing fair play Raj, I know that feeling Smile
Previous Topic: Critical question
Next Topic: Materialized views - create and refresh times
Goto Forum:
  


Current Time: Tue Dec 06 06:38:00 CST 2016

Total time taken to generate the page: 0.12860 seconds