Unix Technical Forum

Re: dummy update

This is a discussion on Re: dummy update within the Informix forums, part of the Database Server Software category; --> On 15 Nov 2005 12:52:31 -0800, tomcaml@yahoo.com wrote > hello! > > anyone have a script or trick to ...


Go Back   Unix Technical Forum > Database Server Software > Informix

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-20-2008, 10:35 AM
Carsten Haese
 
Posts: n/a
Default Re: dummy update


On 15 Nov 2005 12:52:31 -0800, tomcaml@yahoo.com wrote
> hello!
>
> anyone have a script or trick to spit put dummy updates needed for
> all tables in all DB's?
>
> as in, update carriertbl set add_user = add_user where 1=1;
>
> thanks!
>
> tom


Execute the following script in dbaccess against a database of your choice:

unload to "executeme.sql"
select "update "||x1.tabname||" set "||x2.colname||"="||x2.colname
||" where 1=1;--"
from systables x1, syscolumns x2
where x1.tabid = x2.tabid and x1.tabid>=100
and x2.colno = 1;

Then run the resulting script against the same database. Then lather, rinse,
repeat as needed for other databases.

Hope this helps,

Carsten.
sending to informix-list
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-20-2008, 10:35 AM
vasilis
 
Posts: n/a
Default Re: dummy update


> unload to "executeme.sql"
> select "update "||x1.tabname||" set "||x2.colname||"="||x2.colname
> ||" where 1=1;--"
> from systables x1, syscolumns x2
> where x1.tabid = x2.tabid and x1.tabid>=100
> and x2.colno = 1;


Good script, but 1-st column is serial type often and you will find
message
" 232: A SERIAL column (....) may not be updated"
I modified this sql a few
------------
unload to "_execute_me.sql"
select "update "||x1.tabname||" set "||x2.colname||"="||x2.colname||"
where
1=1;--"
from systables x1, syscolumns x2
where x1.tabid = x2.tabid
and x1.tabid>=100
-- A SERIAL column may not be updated
and (x2.colno = 1 and mod(x2.coltype, 256) not in (6,18))
union
select "update "||x1.tabname||" set "||x2.colname||"="||x2.colname||"
where
1=1;--"
from systables x1, syscolumns x2
where x1.tabid = x2.tabid
and x2.tabid>=100
-- A SERIAL column may not be updated
and x2.colno = 2 and mod(x2.coltype, 256) not in (6,18)
and x2.tabid in (select x4.tabid from syscolumns x4
where x4.colno = 1 and mod(x4.coltype,
256) in
(6,18)
);
-----------------
--
Best regards
Vasyl

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:15 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com