Adxsqlrec

This function returns the number of records processed by the last ExecSql instruction. It must be called after an ExecSql instruction that inserts, updates, or deletes records. This function returns 0 after ExecSql instructions that execute DDL statements like CREATE TABLE or DROP TABLE.

Syntax

adxsqlrec

Example

Funprog SQL_EXECUTIONLocal Char DATABASE_TYPE(1)Local Integer ILocal Char ERROR_MESSAGE(100)# Set the database typeDATABASE_TYPE="3" : # "3" is Oracle, "5" is Sql server# Handle errorsOnerrgo SQL_ERROR# No need to test adxsqlrec after executing CREATE TABLE. It will always be 0. # If CREATE TABLE fails, an error is raised and execution resumes at SQL_ERROR.MESSAGE="creating MYTABLE"Execsql From DATABASE_TYPE Sql "Create table MYTABLE( t integer )"# Let us insert records: adxsqlrec should be 1 after every inserted recordFor I=1 to 10Execsql From DATABASE_TYPE Sql "Insert into MYTABLE values ("+num$(I)+")"If adxsqlrec=0End "No record inserted with "+num$(I)+" value"EndifNext I# Now delete records having value 5 and above (5,6,7,8,9,10 ==> 6 records)Execsql From DATABASE_TYPE Sql "delete from MYTABLE where t >= 5"If adxsqlrec<>6End num$(adxsqlrec)-"records deleted, expected 6"Endif# adxsqlrec will be 0 after executing DROP TABLEMESSAGE="dropping MYTABLE"Execsql From DATABASE_TYPE Sql "drop table MYTABLE"# End of jobEnd "Job completed successfully"End# If an error occurred$SQL_ERRORErrbox "error"End "An error occurred while"-MESSAGEEnd

See also

Execsqladxuprecadxdlrec