Home » SQL & PL/SQL » SQL & PL/SQL » JOIN WITH PROCEDURE
JOIN WITH PROCEDURE [message #197811] Thu, 12 October 2006 15:56 Go to next message
superoscarin@hotmail.com
Messages: 101
Registered: July 2006
Location: Mexico
Senior Member

Hi my friends:


I´m comparing 2 tables and i need insert information in a 3rd table...

Basicly i need the first field of the first table and all fields of the 2nd table, this 2 tables don't have any relation... but they are very similar and i want to join them with a procedure

Something like a join but with a procedure when 2 fields in each table are equals the all fields in the second table + the field in the 1st table would be joined in a third table

Example

table 1
field1 field2
1 ab
2 cd
3 ef

table 2
field1 field2
5 ab
9 cd
8 gh

table 3 or resultant
field1 field2 field3
1 5 ab
2 9 cd

Its means, when the field2 for both tables are equal the fields from de 1st and 2nd table should be inserted in 3rd table....

I´m new in PLSQL, any ideas??

Do you recommend me variables or cursors?

Thanks for your help
Alex
Re: JOIN WITH PROCEDURE [message #197814 is a reply to message #197811] Thu, 12 October 2006 16:12 Go to previous messageGo to next message
ebrian
Messages: 2794
Registered: April 2006
Senior Member
Keep it in SQL:

create table table3 as (
	select a.field1 field1, b.field1 field2, a.field2 field3
	from table1 a, table2 b
	where a.field2 = b.field2);
Re: JOIN WITH PROCEDURE [message #197820 is a reply to message #197814] Thu, 12 October 2006 16:28 Go to previous messageGo to next message
superoscarin@hotmail.com
Messages: 101
Registered: July 2006
Location: Mexico
Senior Member

in fact: i need to do more things and i need an autamoted process...

i also need to search pattern in the 1st table to insert it in the 3rd table:


table1
field1 field2
10 abcd 11
20 efgh 22

table2
field1 field2
15 abcd
25 efgh

table3
field1 field2 field3
15 10 abcd 11
25 20 efgh 22



Look patterns (or substrings) in a table and insert it in a different table..

Thanks ebrain
Alex
Re: JOIN WITH PROCEDURE [message #197829 is a reply to message #197820] Thu, 12 October 2006 19:01 Go to previous messageGo to next message
scottwmackey
Messages: 505
Registered: March 2005
Senior Member
Do yourself a favor and describe completely and exactly what you need to do. We don't need the Readers' Digest version, moreover, it's usually useless. Ebrian's response was the best answer to your original question. You have given no reason why it is insufficient. Simple SQL statements can be run as automated processes.
Re: JOIN WITH PROCEDURE [message #198016 is a reply to message #197829] Fri, 13 October 2006 16:28 Go to previous message
superoscarin@hotmail.com
Messages: 101
Registered: July 2006
Location: Mexico
Senior Member

i was trying to do it less complex but i believe that it was the opposite...

i have 2 different tables with states and i need generate a 3rd table with the relation between 2 tables... (what state for the first table apply for the second table)

for do it i need match the states descriptions (no ids)...

but when if i have incomplete name states i need to identified them by substrings??

I need a store procedure becuase the states will be increase in the future...

What do you recommend me?

Thanks for your aclaration scottwmackey
Alex

Previous Topic: Convert output value to 64-Char Hexdecimal
Next Topic: Table Type list from a schema
Goto Forum:
  


Current Time: Fri Dec 09 01:47:06 CST 2016

Total time taken to generate the page: 0.07060 seconds