The Database object provides general information about Databases in the process instance. These are:
Syntax
public class Database
Members
Schema GetSchema(string name) |
Retrieves a schema by name of the associated schema diagram. |
Syntax
public class Schema
Members
object Execute(string cmd) |
Execute an SQL-statement on the schema |
|
DBReader Select(string cmd) |
Execute an SQL-statement on the schema which returns data |
|
void Close() |
Close the schema |
Syntax
public class DBReader
Members
bool IsClosed() |
Indicates if the reader has been closed |
|
bool Read() |
Read the next row from the database |
|
void Close() |
Close the reader |
|
void Dispose() |
Disposes the reader. Its important in non-sandboxed environments to dispose the reader to avoid memory leaks |
|
object GetValue(int index) |
Get the value of the column of the current row by index |
Sample
This sample sets and updates information about a person
s = Database.GetSchema("Datastorage")
hasData = False
with s.Select("select Id, Name, Age from Person") as reader:
while reader.Read():
hasData = True
ProcessInstance.Warn("DBData:"+str(reader.GetValue(1)))
mId = reader.GetValue(0)
mAge = reader.GetValue(2)
if hasData:
s.Execute("UPDATE Person SET Age=%d WHERE ID=%d" % (mAge + 1, mId))
else:
s.Execute("INSERT INTO Person (Name,Age) VALUES ('Frank',45)")
s.Close()