Computing.Net > Forums > Database > script change column 22

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

script change column 22

Reply to Message Icon

Name: showpiecerodent
Date: March 27, 2009 at 03:24:13 Pacific
OS: Solaris
Subcategory: General
Comment:

A recent change means that the sql being produced has too much text in column 22 for the target system which is limited to 30 characters. I need to know how to post process the sql file to truncate whatever is in field 22 to the 30 leftmost characters. The INSERT command is every third line. Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: March 27, 2009 at 09:34:11 Pacific
Reply:

Since your OS is Solaris, are you asking for a unix shell script to do the post processing? If so, this awk script grabs the first 30 characters of field 22, resets field 22 to these values and prints the record:

#!/bin/ksh

# untested for 22 columns
awk ' {
$22=substr($22,1,30)
print $0
} ' mysqlfile > mynewsqlfile


0

Response Number 2
Name: showpiecerodent
Date: March 27, 2009 at 10:18:40 Pacific
Reply:

Thanks nails. I'm not sure what to do about the other 2 lines. One does an insert in another database and the other is a comit command. Obviously I don't want to change these lines with the script. This requires some "if" and "where" presumably?


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Database Forum Home


Sponsored links

Ads by Google


Results for: script change column 22

MSSQL 2005 change scale in column www.computing.net/answers/dbase/mssql-2005-change-scale-in-column/388.html

Batch to fill a csv column with text www.computing.net/answers/dbase/batch-to-fill-a-csv-column-with-text/607.html

Oracle Column Data Convertion www.computing.net/answers/dbase/oracle-column-data-convertion/306.html