Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How To Get The Name Of An Auto Increment Field
Message
From
24/01/2008 19:23:04
Al Doman (Online)
M3 Enterprises Inc.
North Vancouver, British Columbia, Canada
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01285380
Message ID:
01285391
Views:
20
>Ok, here's the problem with this.
>
>I'm working on a legacy app. I'm writing a process that automatically inserts records into
>a DBF.
>
>There is a default value for the PK field:
>
>
new_pk("custpoc","poc_pk")
>
>which calls a stored proc that returns the row's PK value.
>
>My process forms an INSERT statement, which is throwing an error "Uniqueness of index POC_PK is violated."
>
>Not all tables are calling this stored proc, so this presents a problem.
>
>I'm trying to make my process generic so that I can use it in any app. I need a way to
>exclude the PK column from the insert statement when this rule is in place.

I'd first look at the existing legacy source to see how INSERTs are handled elsewhere. If the pkey column has a default value then it's not an autoincrement field so you can't filter it out that way.

Can you just use the function call as the value you're INSERTing? i.e.
INSERT INTO CustPOC ;
  ( POC_PK ;
  , ... ) ;
  VALUES ;
    ( New_PK( "CustPOC", "POC_PK" ) ;
    , ... )
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Reply
Map
View

Click here to load this message in the networking platform