Re: Autoincremental field in VFP7



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......

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
record
no matter how I do it and thus I can't get to see HOW it works. If you
doubt
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 record
into
ANY of the tables while browing!

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
numeric
(4,0) field of Crrefno, I have tried entering crrefno=1 in the '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
'insert
trigger' assuming that's where the 'initiation' of the function should be
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
separete
UDF

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
until
now, so , if it can be done more elegantly.......

Ian







.



Relevant Pages

  • Re: Autoincremental field in VFP7
    ... table held within the Keys table (or else it create new entries in the ... I made a gross mistake and pointed you to CREATE TRIGGER ON INSERT ... ALTER TABLE x ALTER COLUMN keyfield Integer NOT NULL PRIMARY KEY DEFAULT ... You triugger would not fail if you used this command ...
    (microsoft.public.fox.helpwanted)
  • Re: Autoincremental field in VFP7
    ... If the NewId() is returning a string and you need a numeric ... ALTER TABLE x ALTER COLUMN keyfield Int AUTOINC [NEXTVALUE NextValue[STEP ... You triugger would not fail if you used this command ...
    (microsoft.public.fox.helpwanted)
  • Re: troubleshooting tools - IIS Crash/Hang agent
    ... Will is leave IIS running in the case of a hang situation? ... It doesn't> include any built-in functionality such as: sending email to> administrator when the server crashes. ... it supports a command> line trigger to run any commands when the server is crashed. ...
    (microsoft.public.inetserver.iis)
  • Re: Autoincremental field in VFP7
    ... table held within the Keys table (or else it create new entries in the ... I made a gross mistake and pointed you to CREATE TRIGGER ON INSERT ... ALTER TABLE x ALTER COLUMN keyfield Integer NOT NULL PRIMARY KEY DEFAULT ... MCSD, Visual FoxPro MVP ...
    (microsoft.public.fox.helpwanted)
  • Re: newsyslog command in an script
    ... > feedback from the newsyslog command in the form of an script ... exposition of csh programming is considered harmful, ... If so what would the csh script command look like to perform ... enough to trigger newsyslog. ...
    (freebsd-questions)