Troy Loberger
Troy Loberger

Reputation: 347

Comparing 2 fields in one table and updating another accordingly

Is there any way to prefix all the columns in a table when doing a select without doing the following with 44 fields from each table?

BEGIN
    SELECT a.example, a.something, b.example as c_example, b.something as c_something
      INTO AEC_CIS_SVC_PIPE_COMP
      FROM AEC_CIS_SVC_PIPE_V V
      FULL OUTER JOIN AEC_CIS_SVC_PIPE_EXT E
                   ON V.Serv_pipe_num = E.Serv_Pipe_Num
END;

Addition: Or a suffix would work too (ie. b.example as example_c)

Thanks, Troy

Upvotes: 0

Views: 39

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270593

No, you have to list all the columns out.

One thing you can generate the list by running a query in Oracle:

select 'a.'||column_name||' as a_'||column_name||', '
from all_tab_cols
where table_name = 'whatever';

And then copy the results into your query.

Upvotes: 0

Related Questions