Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL passthrough when error is a unique key violation.
Message
De
01/06/2001 03:57:41
 
 
À
31/05/2001 12:16:18
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00512889
Message ID:
00513612
Vues:
16
William,
Strange. I run some tests against the northwind database. If I understood you correctly, you're trying to do something similar to the following:
<pre>
?SQLEXEC(nSql, "EXEC customer_add 'SP001', 'Added through VFP calling a SPROC'")  <font color=green>&& works</font>
?SQLEXEC(nSql, "EXEC customer_add 'SP001', 'Added through VFP calling a SPROC'")  <font color=green>&& fails because of duplicate key</font>

<font color=blue>AERROR</font>(laError)                                               <font color=green>&& get error information</font>
lcErrorMessage = laError[2]                                   <font color=green>&& get error message</font>
lnErrorId = 0                                                 <font color=green>&& initialize return parameter</font>
<font color=green>*-- log error message to error table</font>
?SQLEXEC(nSql, "EXEC error_add ?lcErrorMessage, ?@lnErrorId") <font color=green>&& works</font>


What is the error you get when you try to add a record to the error table?

Here are the SPROCs:
CREATE PROCEDURE  customer_add 
@CustomerId CHAR(5),
@CompanyName CHAR(40)

 AS 

 BEGIN TRANSACTION 

 INSERT INTO customers(CustomerId, CompanyName)

 VALUES (@CustomerId, @CompanyName)

COMMIT TRANSACTION
CREATE PROCEDURE  error_add 
@ErrorMessage VARCHAR(250),
@newkey INTEGER OUTPUT

 AS 

 BEGIN TRANSACTION 

 INSERT INTO errors(ErrorMessage)

 VALUES (@ErrorMessage)

 SELECT @newKey = @@IDENTITY 

COMMIT TRANSACTION
>Call a stored procedure
Daniel
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform