Add Database name to a field in your database

Build your list of AccuZIP6 commands by requesting commands and sharing commands with other users

Moderators: Chrissy, Steve, Terry, Donna, Dave, Eric, MartyH, Kristen, Geoff, Vince

Post Reply
User avatar
Eric
Moderator
Posts: 1910
Joined: Tue Sep 19, 2006 3:29 pm
Contact:

Add Database name to a field in your database

Post by Eric » Tue Oct 24, 2006 11:19 am

To create a field in your database, you can use the command:

Code: Select all

ALTER TABLE (ALIAS()) ADD COLUMN filename C(20)
Add Column filename C(20) describes the name of the field (filename) the type of field (C for Character) and the width of the field (20 characters).

Then to add the database name to that field, use this command:

Code: Select all

REPLACE ALL filename WITH SUBSTR(DBF(),RAT("\",DBF())+1)
DBF() is the complete path of your database. This takes everything from the first character right after the right-most backslash, which is the name of the database without any of the path, and puts it in to a field name called filename for every record in the list.

When you combine the two commands, you have a command that adds a field name then fills the database name into that field:

Code: Select all

ALTER TABLE (ALIAS()) ADD COLUMN filename C(20)
REPLACE ALL filename WITH SUBSTR(DBF(),RAT("\",DBF())+1)
Chat with an AccuZIP6 technician weekdays from 7-4 PST with AccuZIP6 Live Online Support

Post Reply