Re: New to informix.
Posted in 1998
josephatl@mindspring.com writes:
>
> Hello everyone. I'm new to informix & isql in general, so this is going to be
> simple for you.
>
> I need to know how to find the field names in all my tables, and then how to
> replace the value of a field in one record based on the value of another
> field. ie...:
>
> replace port_number with "5061" where switch_id = "2XO"
>
> but I don't know how to tell it which table to look in.
>
> Any help would be greatly appreciated.
Write an SQL script that generates an sql script and pipe the output
of the first script into sql again.
script 1:
output to pipe "cat" without headings
select "update ", tabname, " set port_number = '5061' where switch_id = '2XO';"
from systables a,
syscolumns b
where a.tabid = b.tabid
and b.colname = "port_number"
and a.tabid in (
select c.tabid
from systables c,
syscolumns d
where c.tabid = d.tabid
and d.colname = "switch_id"
)
Save this script to a file and run it through isql or dbaccess to confirm
it is doing what you want:
script 1 output:
update
rp_line_ocost_724
set port_number = '5061' where switch_id = '2XO';
update
rp_ln_sp_ocst_725
set port_number = '5061' where switch_id = '2XO';
Finally run: isql <dbname> script1 | isql <dbname> -
(Tells the 2nd isql to get its instructins from <stdin>.
As another poster mentioned, beware of long transactions.
--
______________________________________________________________________
| Colin McGrath cmm@trac3000.ueci.com |
| Raytheon Engineers & Constructors, Inc. (215) 422-4144 |
| Phila, PA, USA |
| Any opinions I state are my own and not necessarily of my employer |
|____________________________________________________________________|