Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Help - What am I doing wrong with this primary key
Message
De
06/12/2000 05:18:14
 
 
À
05/12/2000 12:50:22
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00449457
Message ID:
00449843
Vues:
13
>>>>Thanks Trey
>>
>>>

Hmmm doing it this way seems to work though!!!!

sele v_ticket
*!* DBSetProp("v_ticket.p_ticket", "Field", "Default", "NextKey('P_TICKET')")
insert into v_ticket (p_ticket,ticket) values (NextKey('P_TICKET'),myvalue)
go recno()
wait window ' v_ticket '+trans(v_ticket.p_ticket)+' ticket '+trans(ticket.p_ticket)
return v_ticket.p_ticket

Thanks for the idea of populating v_ticket with the primary key before I write the record back to the underlying table.

I had been told in the past that this was a bad idea and I should insure nextkey only ever gets run from the one location.

It looks like this is one of those general rules that needs to be broken from time to time for the sake of performance.

I am pleased becuase it would have been very time consuming requerying the whole view just to get my primary key reflected back into the view.







>>>Yep. You can set it with DBSETPROP(), unlike the default for a table field. e.g.,
>>>DBSetProp("v_ticket.p_ticket", "Field", "Default", "NextKey()")
>>
>>But I can not see how it would help me since my Nextkey routine will return a different value if it is called twice.
>>
>>And since my Nextkey routine just uses a replace anyway I would expect to still be in the same boat.
>
>It won't get called twice. Since the p_ticket field in the inserted record in the view already has a value, the default of the p_ticket in the table won't fire when the view is updated.
>If you don't believe me, try it and see :)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform