Difference between revisions of "SQLCODE"

From Recital Documentation Wiki
Jump to: navigation, search
(Products)
 
Line 12: Line 12:
  
 
==Description==
 
==Description==
A Pseudo Column behaves like a table column, but is not actually stored in the table. You can select from Pseudo Columns, but they cannot be updated.  Pseudo Columns provide extra information about a SELECT row set.
+
SQLCODE will return a number indicating the result of the last SQL statement.  SQLCODE return values:
 
+
The SQLCODE Pseudo Column will return a number indicating the result of the last SQL statement.  SQLCODE return values:
+
  
  
Line 32: Line 30:
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
// Display all overdue accounts with 15% commission in
+
set gateway to "rec@server1:user1/pass1-southind"
// Sorted "name" and "paid date" order with the row number.
+
SELECT * FROM example WHERE state = "MA"
EXEC SQL
+
? sqlcode
SELECT ROWNUM, name, address, balance, cost*1.15
+
        0
FROM accounts
+
WHERE paid_date < date()
+
ORDER BY name, paid_date;
+
// Check return code and number of rows returned
+
EXEC SQL
+
SELECT DISTINCT sqlcode, sqlcnt from accounts;
+
 
</code>
 
</code>
  

Latest revision as of 15:03, 5 July 2011

Purpose

Return a number indicating the result of the last SQL statement


Syntax

SQLCODE


See Also

PSEUDO COLUMNS, INSERT, SELECT, UPDATE


Description

SQLCODE will return a number indicating the result of the last SQL statement. SQLCODE return values:


SQLCODE Description
0 The SQL statement completed successfully
+100 No rows were found or the end of the set reached
<0 An error occurred


Example

set gateway to "rec@server1:user1/pass1-southind"
SELECT * FROM example WHERE state = "MA"
? sqlcode
         0


Products

Recital, Recital Server