Re: Autoincremental field in VFP7
- From: "Anders Altberg" <anders altberg>
- Date: Mon, 12 Feb 2007 19:41:26 +0100
Sorry Ian
I made a gross mistake and pointed you to CREATE TRIGGER ON INSERT .command.
Altogether wrong. That would create a table validation rule that would check
if the insert contained some particular value. It would not provide a new
value automatically.
The correct SQL for that is
ALTER TABLE x ALTER COLUMN keyfield Integer NOT NULL PRIMARY KEY DEFAULT
NewID()
or
ALTER TABLE x ALTER COLUMN keyfield Int AUTOINC [NEXTVALUE NextValue[STEP
StepValue]]
You triugger would not fail if you used this command
INSERT INTO x (Crrefno) VALUES ( 1)
but will fail for
INSERT INTO x (Crrefno) VALUES (2)
-Anders
"Barley Man" <BarleyMan@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:7845AF4C-937F-4E69-A1C6-C23AAA62A319@xxxxxxxxxxxxxxxx
Guys......record
I fully understand that it's me that's stupid but I can't get ANY of your
suggestions to work! If I use the tastrade example (so I can see how it
works), I simply CANNOT add a new record when browing ANY of the tables as
there is vastly too much other rubbish preventing me from adding a new
no matter how I do it and thus I can't get to see HOW it works. If youdoubt
me, just try browsing any of the tables affected and try pressing ctrl y,you
will see exactly what I mean. I haven't manged to insert a single recordinto
ANY of the tables while browing!numeric
Secondly, I cannot see how I make any of the suggestions work as even the
most basic attmept fails for me. I have tried the most simple of routines
just to get a handle on this. For example, with an empty table with a
(4,0) field of Crrefno, I have tried entering crrefno=1 in the 'insert'insert
trigger' field and, if I then use ctrl y on the table, I get 'Trigger
failed'. That implies that I am making the error in the very simplest of
stuff, i.e, the inserting of the value once I have created it!
Please tell me what the correct syntax is that I should place in the
trigger' assuming that's where the 'initiation' of the function should beseparete
inserted.
Ian
"Craig Berntson" wrote:
This may help. http://www.craigberntson.com/Articles/kb006.htm
--
----
Craig Berntson
MCSD, Visual FoxPro MVP
Salt Lake City Fox User Group
"Barley Man" <BarleyMan@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A7F1F86A-4900-4FCA-A4BF-2757B7FBF1F7@xxxxxxxxxxxxxxxx
No Auto Incremental field value appears built into VFP7. It has been
suggested to me that I could build such a tool using an UDF in the
'default'
property of a table.
I assume I need the 'create table' statement and then wil need a
untilUDF
Can anyone suggest the coding and tell me EXACTLY where to put it with
what
syntax assuming the following is the 'create' command. I need to
Autoincrement the field iIrefno by one on each new record.
CREATE TABLE inv ;
( ;
iIrefno n(10,0) , ;
iCrefno i(10) , ;
nAmount n(10,2) , ;
)
I have been doing the incrementation by a much more clumsy method up
now, so , if it can be done more elegantly.......
Ian
.
- Follow-Ups:
- Re: Autoincremental field in VFP7
- From: Barley Man
- Re: Autoincremental field in VFP7
- References:
- Re: Autoincremental field in VFP7
- From: Craig Berntson
- Re: Autoincremental field in VFP7
- From: Barley Man
- Re: Autoincremental field in VFP7
- Prev by Date: Re: Autoincremental field in VFP7
- Next by Date: determine if a file fits a file mask
- Previous by thread: Re: Autoincremental field in VFP7
- Next by thread: Re: Autoincremental field in VFP7
- Index(es):
Relevant Pages
|