[ library(dbi) | Reference Manual | Alphabetic Index ]

session_sql(++Session, ++SQL, -RowProcessedCount)

Executes a SQL statement on the database server.
A session handle
A SQL statement (string)
Number of rows affected by this statement


Executes a SQL statement (without parameters) on the database server. The SQL statement should not have a terminating semicolon (;). If supported by the DBMS, SQL can consist of multiple statements separated by semicolons. RowProcessedCount will be unified with the number of rows affected by this statement.

In the case of data definition language statements the RowProcessedCount parameter is undefined and should be passed as a free variable.

In the case of data manipulation language statements, the RowProcessedCount is the number of rows, deleted, modified or inserted by the SQL statement.

The SQL statement must be valid for the DBMS to execute. It can contain NULL characters, i.e. it can contain binary data.

Any results generated by the statement is discarded.


(5) type error
Session is not a valid session handle or SQL not a string
database returned an error when executing SQL.


make_accounts(Session) :-
        "create table accounts \
         (id           decimal(4)      not null,\
          balance      decimal(9,2)    default 0.0 not null, \
          overdraft    decimal(9,2)    default 0.0 not null \
         )" ,_),
        "insert into accounts (id,balance) values (1001,1200.0)",1),
        "insert into accounts (id,balance) values (1002,4300.0)",1).