Hi, I Have a large database, with several tables, and obviously, many columns . Due to an update on my system I need to change all entries where I have 'H:\' to '\server\folder\'. But I dont know the tables neider columns where this string happen. There is any way to select all fields in each table where I have this string, this way I can, at least, create some script to update the tables and solve my problem ? Hope I was clear ?? Thanks a lot. Paulo Braga IT Manager not DBA... |
Hi, You should rebuild the database. Database rebuilds http://dcx.sap.com/index.html#sqla170/en/html/8184a0196ce210148e44c2c2c08aa7b0.html Unload utility (dbunload) http://dcx.sap.com/index.html#sqla170/en/html/813e16456ce21014b96dc39365129dc6.html When the database unload, the data are output to a file. You can search & update data with this file. And you reload the data to a new database. Thanks, 2
This is an excellent starting point... and it may indeed be a complete solution (brute force is sometimes the best way). If the unloaded data files are extremely large (e.g., gigabytes) it may be time consuming to edit them to replace a short substring H:\ with a longer one \server\folder... it may be necessary to shop around for a text editor that can handle the task. However, at the very least you may be able to discover which columns in which tables contain H:\ and use an UPDATE to actually change them. One alternative may be a FOR SELECT SYSTABCOL loop containing an EXECUTE IMMEDIATE... bonus points for the first such answer that works :)
(24 May '17, 03:10)
Breck Carter
Try this: select string ('select ''', suser_name (t.creator), '.', t.table_name, ''', ''', c.column_name, ''', "', c.column_name, You may have to adjust the string ('update "', suser_name (t.creator), '"."', t.table_name, '" set "', c.column_name, and use a different filename. You may apply a white list of table and column names where at least one match had been found in the first run. HTH Volker
(24 May '17, 16:37)
Volker DB-TecKy
|
Dear Fellows, Thanks for your time and knowledge, i used some parts of the first idea to solve my issue, I made a script with unload of all tables, creating txt files for each into a folder, then use grep to find the string i needed. The Volker alternative, unfortunately was not so clear, it created a sql file and then read it but no result was shown.. I thik I solve it, thank you so much. Which dbisql version do you use (17 or older)? If "older", did you check the "show results from all statements" option? Default is "show only result from last statement". HTH Volker
(24 May '17, 17:22)
Volker DB-TecKy
|
I think the following block could help you if you can modify the line 6, so that you can retrict the columnscursor to retrive only the columns whose datatype is (varchar). I personally couldn't find a proper way for restricting the select statement, so that it worked partially but I had error messages whenever it reaches a column with a numeric datatype. begindeclare currenttablename varchar(128); --maximum length for table namesdeclare currenttableid int;declare currentcolumn varchar(128); --maximum length for column namesdeclare tablescursor dynamic scroll cursor for select table_name, table_id from systable where creator >100;declare columnscursor dynamic scroll cursor for select column_name from syscolumn where table_id = currenttableid and pkey = 'N';declare NoDataAvailable exception for sqlstate value '02000';open tablescursor with hold;fetch first tablescursor into currenttablename, currenttableid;tablesloop:while sqlstate<>NoDataAvailable loopopen columnscursor with hold;fetch first columnscursor into currentcolumn;columnsloop:while sqlstate<>NoDataAvailable loopmessage (currenttablename);message (currenttableid);execute immediate string('update ' + currenttablename + ' set ' + currentcolumn + '=''new_path'' where ' + currentcolumn + '=''old_path''');fetch next columnscursor into currentcolumn;end loop columnsloop;close columnscursor;fetch next tablescursor into currenttablename, currenttableid;end loop tablesloop;close tablescursor;end; |