Creates a database cursor.
PSConnectionClass objects
connectionobject.CreateCursor( sql )
connectionobject.CreateCursor( sql , resultSetType, resultSetConcurrency )
Argument |
Description |
---|---|
connectionobject |
A variable that contains a reference to an instance of PSConnectionClass. |
sql |
A string that specifies the SQL statement. |
resultSetType |
An int that specifies the result set type. If the single argument syntax is used in a JSP target, TYPE_SCROLL_INSENSITIVE is passed as a default argument. |
resultSetConcurrency |
An int that specifies the result set concurrency properties. If the single argument syntax is used in a JSP target, CONCUR_UPDATABLE is passed as a default argument. |
PSCursorClass object
At runtime, CreateCursor has the following behavior:
Application server |
Runtime behavior |
---|---|
ASP |
Calls the Execute method of the Connection object |
JSP |
Creates a cursor object and executes the SQL statement |
The following example creates a cursor to retrieve rows from the products table. Once the data has been retrieved, the code in the example writes out each row in the cursor. If an error occurs, it writes out the error code and message text:
myquery = "SELECT products.prod_id, products.prod_name FROM DBA.products";
mycursor = myconnect.CreateCursor(myquery);
if ( myconnect.GetError() == null )
{
for (i=0; (!mycursor.EOF()); i++)
{
psDocument.Write(mycursor.GetValue(0) + " " + mycursor.GetValue(1));
psDocument.Write("<BR>");
mycursor.MoveNext();
}
}
else {
dberror = true;
}
if ( dberror == true )
{
errobj = myconnect.GetError();
str = errobj.GetCode() + " " + errobj.GetMessage();
psDocument.Write ( str );
}
To use the same example in a JSP target, you must declare “mycursor” as a variable of type PSCursorClass before instantiating it and calling any methods on it. You must also declare “myquery” as a variable of type String, “myconnect” as a variable of type PSConnectionClass, “dberror” as a variable of type boolean, and “errobj” as a variable of type PSErrorClass.