Return Values and Statement Failure

Table of Return Values and Statement Failure

The following table displays return values for each SQL statement and delineates when each statement fails.


Command

Return Values

Failure When…

DECLARE

1 (success)

never

OPEN

number of records

0 upon failure

too many open cursors (>100), including recursive opens

no selected records

CLOSE

1 upon success

0 upon failure

cursor is not open

FETCH

1 if fetched

0 if end of cursor

cursor is not open

no more records in cursor

SELECT

number of selected records

0 upon failure

no record met WHERE condition

SELECT … INTO

1 upon success

0 upon failure

no record met WHERE condition

INSERT … SELECT

number of inserted records

–1 if no record meets WHERE condition

no record met WHERE condition

there were selected records, but none was inserted (generally due to unique key constraint or insufficient privileges)

INSERT_VALUES

1 upon success

0 upon failure

failed to insert

UPDATE … WHERE CURRENT OF cursor_name

1 upon success

0 upon failure

cursor is not open

no more records in cursor

there is a record, but it was not updated

UPDATE

number of updated records

0 upon failure to update

–1 if no record meets WHERE condition

no record met WHERE condition

there were selected records, but none was updated (generally due to unique key constraint or insufficient privileges)

DELETE … WHERE CURRENT OF cursor_name

1 upon success

0 upon failure

cursor is not open

no more records in cursor

there is a record, but it was not deleted

DELETE

number of deleted records

0 upon failure to delete

–1 if no record meets WHERE condition

no record met WHERE condition

there were selected records, but none was deleted (generally due to unique key constraint or insufficient privileges)

RUN

returns what the query returns


ENV

1 upon success

0 upon failure


EXECUTE

PID of the child process


LINK

2 if new file has been created

1 if link to existing file

0 upon failure to link

–1 if more than one link to same table name


UNLINK

1 upon success

0 upon failure


GOTO


no such label found forwards

LOOP


no such label found backwards

LABEL


never

END


never

Further Reading