error()

Here’s how to use error() function.

db.error()

Description:

Obtain the last error information from a database connection.

Syntax:

db.error()

Note:

The function returns the error information corresponding to the previous command related to the database. 0 indicates error free; otherwise, the error code is returned. The error message can only be called one time.

Parameters:

db

Database connection

Options:

@m

Use this option to return information in string.

Example:

 

A

 

1

=file("D://files//student.txt")

Data in the file student.txt is not correct

2

=A1.import@t()

 

3

=connect@e("demo")

Create a connection and auto-control the commit and rollback operations

4

>A3.execute@k(A2,"update STUDENTS2 set NAME=?,GENDER=?,AGE=? where ID=?",NAME,GENDER,AGE,ID)

The transaction is not committed

5

=A3.error@m()

Return the error message corresponding to sql command execution

6

>file("D:\\log.txt").write@a(A5)

Append error message to the log

 

7

>A3.close()

Close the connection

Related functions:

db.close()

connect()

db.commit()

db.rollback()