Discussion:
about integer AutoInc fields
(too old to reply)
neoLeoX
2004-12-30 14:55:05 UTC
Permalink
Hi group


How can I know, programatically, if a table has an "integer AutoInc" field
on it?


thanks in advance
L.Ortega
Fred Taylor
2004-12-30 15:20:09 UTC
Permalink
Use the AFIELDS() function. Elements 17 & 18 for the field will tell you
about the Autoinc features.
--
Fred
Microsoft Visual FoxPro MVP
Post by neoLeoX
Hi group
How can I know, programatically, if a table has an "integer AutoInc" field
on it?
thanks in advance
L.Ortega
neoLeoX
2004-12-30 15:28:54 UTC
Permalink
Thank you very much Fred!!
I had not even an Idea...
Post by Fred Taylor
Use the AFIELDS() function. Elements 17 & 18 for the field will tell you
about the Autoinc features.
--
Fred
Microsoft Visual FoxPro MVP
Post by neoLeoX
Hi group
How can I know, programatically, if a table has an "integer AutoInc"
field on it?
thanks in advance
L.Ortega
Rick Bean
2004-12-30 15:37:46 UTC
Permalink
L.Ortega,
Use AFIELDS() to get the info about the fields, and use ASCAN() to locate the row where columns 17 and 18 are non-zero (there can only be one), then it's an autoinc field, and you can get the name of the field out of column 1.

Rick
Post by neoLeoX
Hi group
How can I know, programatically, if a table has an "integer AutoInc" field
on it?
thanks in advance
L.Ortega
neoLeoX
2004-12-30 18:08:53 UTC
Permalink
Rick

Do you have an example how to do the ASCAN to locate the row where columns
17 and 18 are non-zero?

I haven't used ASCAN yet, and reviewing the documentation the sintax is
ASCAN(ArrayName, eExpression [, nStartElement [, nElementsSearched [,
nSearchColumn [, nFlags ]]]])


AFIELDS(aF,"myAlias")

*!* Here's where the problem begins :)
lnFieldNum = ASCAN(af, ??

* eExpression = ??
* nStartElement = 1 ?
*nElementsSearched = alen(af,0) ?
*nSearchColumn = 17 && Should I run another ASCAN for Column 18?
*nFlags=8 && if I want to obtain the Field Number as a return

-----------------------------
I was using

lnFlds = AFIELDS(af,lcAliasX)
FOR i=1 TO lnFlds
IF af[i,17]#0 OR af[i,18]#0
*-- Has autoInc
lcAutoIncFieldName = af[i,1]
lnFldNo = i
EXIT
ENDIF
ENDFOR


But I would like to use the ASCAN instead



"Rick Bean" <***@unrealmelange-inc.com> wrote in message news:***@TK2MSFTNGP12.phx.gbl...
L.Ortega,
Use AFIELDS() to get the info about the fields, and use ASCAN() to locate
the row where columns 17 and 18 are non-zero (there can only be one), then
it's an autoinc field, and you can get the name of the field out of column
1.

Rick
Post by neoLeoX
Hi group
How can I know, programatically, if a table has an "integer AutoInc" field
on it?
thanks in advance
L.Ortega
Rick Bean
2004-12-30 18:31:48 UTC
Permalink
If you always use an autoinc step value of 1, then this will work:

lnFieldNum = ASCAN(aF,1,1,0,18,8)

If it isn't 1, then you'll probably need the loop you've used. (I could of sworn you could put an expression in as the 2nd parameter! <g>)

Rick
Post by neoLeoX
Rick
Do you have an example how to do the ASCAN to locate the row where columns
17 and 18 are non-zero?
I haven't used ASCAN yet, and reviewing the documentation the sintax is
ASCAN(ArrayName, eExpression [, nStartElement [, nElementsSearched [,
nSearchColumn [, nFlags ]]]])
AFIELDS(aF,"myAlias")
*!* Here's where the problem begins :)
lnFieldNum = ASCAN(af, ??
* eExpression = ??
* nStartElement = 1 ?
*nElementsSearched = alen(af,0) ?
*nSearchColumn = 17 && Should I run another ASCAN for Column 18?
*nFlags=8 && if I want to obtain the Field Number as a return
-----------------------------
I was using
lnFlds = AFIELDS(af,lcAliasX)
FOR i=1 TO lnFlds
IF af[i,17]#0 OR af[i,18]#0
*-- Has autoInc
lcAutoIncFieldName = af[i,1]
lnFldNo = i
EXIT
ENDIF
ENDFOR
But I would like to use the ASCAN instead
L.Ortega,
Use AFIELDS() to get the info about the fields, and use ASCAN() to locate
the row where columns 17 and 18 are non-zero (there can only be one), then
it's an autoinc field, and you can get the name of the field out of column
1.
Rick
Post by neoLeoX
Hi group
How can I know, programatically, if a table has an "integer AutoInc" field
on it?
thanks in advance
L.Ortega
Loading...