tags:

views:

31

answers:

1

I have a table called excel that has 3 columns, name, id, and full_name. The name part is the only one I have and I need to fill id and full_name. The other table that contains the data is called tim_pismena and has 2 columns that I need, id and pismeno_name (the actual names are not important, but i'm writing them just for clarity). In pseudooracle code :) the select that gets me the values from the second table would be done something like this:

SELECT tp.id, tp.pismeno_name
FROM tim_pismena tp
WHERE  upper(tp.pismeno_name) LIKE IN upper('%(SELECT name FROM excel)%')

and when used with an insert, the end result should be something like

name        id    full_name
Happy Joe   55    Very fun place Happy Joe, isn't it?
+2  A: 

Use merge statement

  1  MERGE
  2     INTO  excel  tgt
  3     USING tim_pismenae src
  4     ON  ( upper(src.naziv_pismena) LIKE '%'||upper(tgt.ime)||'%')
  5  WHEN MATCHED
  6  THEN
  7     UPDATE
  8     SET   tgt.id = src.id
  9     ,     tgt.full_name = src.naziv_pismena
 10  WHEN NOT MATCHED
 11  THEN
 12     INSERT ( tgt.name
 13            , tgt.id
 14            , tgt.full_name )
 15     VALUES ( src.naziv_pismena
 16            , src.id
 17            , src.naziv_pismena )
 18     WHERE (1 <> 1);
Bharat
I think you're on the right track, but that the LIKE part isn't valid (even when I remove the bracket :) )
Andrija
Check the edited query
Bharat
That's it! :) Thank you.
Andrija