Sample
local SQL_Handle_type EnvironmentHandle
local SQL_Handle_type ConnectionHandle
local SQL_Handle_type StatementHandle
local stream CharAttr
local stream CharAttr2
local counter StringLen
local counter StringLen2
local counter NumAttr
local counter NumCols
local counter RetCode
set RetCode to SQLAllocEnv(EnvironmentHandle)
output "Allocating environment handle - "
do when RetCode != SQL_SUCCESS
output "failed%n"
halt with 1
else
output "passed%n"
done
set RetCode to SQLAllocHandle
( SQL_HANDLE_DBC, EnvironmentHandle, ConnectionHandle )
output "Allocating connection handle - "
do when RetCode != SQL_SUCCESS
output "failed%n"
halt with 1
else
output "passed%n"
done
set RetCode to SQLConnect( ConnectionHandle, "omodbc", 20, "", 0, "", 0 )
output "Connecting to database - "
do when RetCode != SQL_SUCCESS
output "failed%n"
halt with 1
else
output "passed%n"
done
set RetCode to SQLAllocStmt(ConnectionHandle, StatementHandle)
output "Allocating statement handle - "
do when RetCode != SQL_SUCCESS
output "failed%n"
halt with 1
else
output "passed%n"
done
set RetCode to SQLExecDirect
( StatementHandle,
"Select EmpName, EmpID, Salary from Employee order by 2",
SQL_NTS
)
output "Combined preparation and execution of a statement - "
do when RetCode != SQL_SUCCESS
output "failed%n"
halt with 1
else
output "passed%n"
done
set RetCode to SQLNumResultCols( StatementHandle, NumCols )
output "Counting number of result columns - "
do when RetCode != SQL_SUCCESS
output "failed%n"
halt with 1
else
output "passed%n"
output "- %d(NumCols)%n"
done
set RetCode to SQLColAttributes
( StatementHandle,
1,
SQL_COLUMN_LABEL,
CharAttr,
1024,
StringLen,
NumAttr
)
set RetCode to SQLColAttribute
( StatementHandle,
1,
SQL_DESC_DISPLAY_SIZE,
CharAttr2,
1024,
StringLen2,
NumAttr
) when RetCode = SQL_SUCCESS
output "Retrieving column attributes - "
do when RetCode != SQL_SUCCESS
output "failed%n"
halt with 1
else
output "passed%n"
output "- %g(CharAttr) (%d(StringLen))%n"
output "- %d(NumAttr)%n"
done
set RetCode to SQLFreeHandle(SQL_HANDLE_STMT, StatementHandle)
output "Freeing statement handle resources - "
do when RetCode != SQL_SUCCESS
output "failed%n"
halt with 1
else
output "passed%n"
done
set RetCode to SQLDisconnect( ConnectionHandle )
output "Disconnecting from database - "
do when RetCode != SQL_SUCCESS
output "failed%n"
halt with 1
else
output "passed%n"
done
set RetCode to SQLFreeHandle(SQL_HANDLE_DBC, ConnectionHandle)
output "Freeing connection handle resources - "
do when RetCode != SQL_SUCCESS
output "failed%n"
halt with 1
else
output "passed%n"
done
set RetCode to SQLFreeHandle(SQL_HANDLE_ENV, EnvironmentHandle)
output "Freeing environment handle resources - "
do when RetCode != SQL_SUCCESS
output "failed%n"
halt with 1
else
output "passed%n"
done
Generated: April 21, 1999 at 2:01:43 pm
If you have any comments about this section of the documentation, send email to [email protected]
Copyright © OmniMark Technologies Corporation, 1988-1999.