Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL passthrough when error is a unique key violation.
Message
From
01/06/2001 03:57:41
 
 
To
31/05/2001 12:16:18
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00512889
Message ID:
00513612
Views:
15
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform