Discussion:
Stored procedure to set defaults
(too old to reply)
TA
2004-09-10 20:07:36 UTC
Permalink
I have this stored procedure that sets defaults to blank strings for all the
columns in a table. I have some date columns in this table also, how would I
identify that the column is data or integer or double or char..

PROCEDURE DefaultsALL
USE qtk EXCLUSIVE
FOR i = 1 TO FCOUNT()
fieldname = FIELD(i)
ALTER TABLE Qtk ALTER COLUMN (fieldname) set default ' '
ENDFOR
ENDPROC
Dan Freeman
2004-09-10 20:25:40 UTC
Permalink
You should look up Type() in the help file.

But you may be working a little too hard. Take a look at AFIELDS() while
you're in there. <g>

Dan
Post by TA
I have this stored procedure that sets defaults to blank strings for
all the columns in a table. I have some date columns in this table
also, how would I identify that the column is data or integer or
double or char..
PROCEDURE DefaultsALL
USE qtk EXCLUSIVE
FOR i = 1 TO FCOUNT()
fieldname = FIELD(i)
ALTER TABLE Qtk ALTER COLUMN (fieldname) set default ' '
ENDFOR
ENDPROC
TA
2004-09-10 20:34:14 UTC
Permalink
I dont know the basis of stored procedure.. maybe you can give me some
hints..
Post by Dan Freeman
You should look up Type() in the help file.
But you may be working a little too hard. Take a look at AFIELDS() while
you're in there. <g>
Dan
Post by TA
I have this stored procedure that sets defaults to blank strings for
all the columns in a table. I have some date columns in this table
also, how would I identify that the column is data or integer or
double or char..
PROCEDURE DefaultsALL
USE qtk EXCLUSIVE
FOR i = 1 TO FCOUNT()
fieldname = FIELD(i)
ALTER TABLE Qtk ALTER COLUMN (fieldname) set default ' '
ENDFOR
ENDPROC
Dan Freeman
2004-09-10 21:04:33 UTC
Permalink
I have no idea what you just asked. Sorry.

Dan
Post by TA
I dont know the basis of stored procedure.. maybe you can give me some
hints..
Post by Dan Freeman
You should look up Type() in the help file.
But you may be working a little too hard. Take a look at AFIELDS()
while you're in there. <g>
Dan
Post by TA
I have this stored procedure that sets defaults to blank strings for
all the columns in a table. I have some date columns in this table
also, how would I identify that the column is data or integer or
double or char..
PROCEDURE DefaultsALL
USE qtk EXCLUSIVE
FOR i = 1 TO FCOUNT()
fieldname = FIELD(i)
ALTER TABLE Qtk ALTER COLUMN (fieldname) set default ' '
ENDFOR
ENDPROC
Cindy Winegarden
2004-09-10 22:18:36 UTC
Permalink
Hi TA,

AFields() will give you an array of field names, types, etc. You can iterate
through the array and build a command to set your values.

Are you working against Fox data or some other kind? The default value for
character and memo types is a blank string, the default for dates is {}
(empty) and the default for numeric types is 0. In other words, if you
append a new record to a Fox table you'll probably get what you want
automatically.
--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
Post by TA
I dont know the basis of stored procedure.. maybe you can give me some
hints..
Post by Dan Freeman
You should look up Type() in the help file.
But you may be working a little too hard. Take a look at AFIELDS() while
you're in there. <g>
Dan
Post by TA
I have this stored procedure that sets defaults to blank strings for
all the columns in a table. I have some date columns in this table
also, how would I identify that the column is data or integer or
double or char..
PROCEDURE DefaultsALL
USE qtk EXCLUSIVE
FOR i = 1 TO FCOUNT()
fieldname = FIELD(i)
ALTER TABLE Qtk ALTER COLUMN (fieldname) set default ' '
ENDFOR
ENDPROC
Loading...