Re: Column name mod causing problem

From: Mike Rife <rife_at_aarlo.moffitt.usf.edu>
Date: 1995/10/19
Message-ID: <465gtq$p0u_at_mother.usf.edu>#1/1


In article <462rea$dki_at_earth.vais.net>, dci_at_sun.vais.net (Dynamic Computing) says:
>
>I am writing a Pro*c program to fetch some data from an existing table,
>but the table has a column name - mod. When I use EXEC SQL SELECT mod,
>field2 from MYTABLE, the precompiler is confused and thinks the field
>name - mod is the oracle function mod and gives a syntax error. Can
>anyone give me some ideas how I can get around this without altering the
>column name in the table. Thanks a lot in advance.
>
>Janie
>dci_at_vais.net
>

MOD is a reserved word. One way to get around this is to create a view of the table which changes the name of the MOD column. Then reference the view in your Pro*C code SELECT statement. I have ran into this with columns named TYPE.

     create view MYTABLE_VIEW as
     select mod mod_new_name, field2
     from MYTABLE;

Then in Pro*C:

     EXEC SQL SELECT mod_new_name, field2 from MYTABLE_VIEW;

Hope that helps. Received on Thu Oct 19 1995 - 00:00:00 CET

Original text of this message