Defines an output variable for a specified select-list item in a SQL query. In a BDL script, it is necessary to call this function for each select-list item of a SQL query. After the OraExec (and OraFetch) function has been called, the following functions can be used to retrieve the value of the program variable that is defined for the specified select-list item:
Ora.bdh
OraDefine( in cCursor : cursor, in nPosition : number, in nDatatype : number optional, in nSize : number optional, in nMaxColSize : number optional, in nDefineType : number optional, in nPieces : number optional): boolean;
true if successful
false otherwise. In this case, you can use the OraOciError function to retrieve the Oracle OCI error code
Parameter | Description |
---|---|
cCursor | Cursor associated with a database connection |
nPosition | Index of the select-list item in the SQL query. Position indices start at 1 for the first (leftmost) select-list item |
nDatatype |
Oracle external data type of the select-list item (optional). See Oracle data types for a list of Oracle data types. The default value is SQLT_STR (null-terminated string) |
nSize |
Length of the select-list item in bytes (optional). This parameter should be omitted or set to 0 for data types of fixed length (SQLT_NUM, SQLT_INT, SQLT_FLT, SQLT_VNU, SQLT_RID, SQLT_DAT, SQLT_UIN, SQLT_CUR) |
nMaxColSize | Maximum possible size of the select-list item in bytes (optional). This parameter has to be specified whenever the select-list item is retrieved in multiple pieces |
nDefineType |
Special select-list option (optional). Possible options are:
|
nPieces | Number of pieces (optional). Whenever nDefineType is set to ORA_FETCHLONG, this parameter can be used to specify the number of pieces |
var hConnection : number; cCursor : cursor; dcltrans transaction TMain var sName : string; nFetched, nAge, i : number; begin OraLogon(hConnection, "user", "password", "orclnet2"); OraOpen(cCursor, hConnection); OraParse(cCursor, sqlSelect); OraDefine(cCursor, 1, SQLT_CHR, 32); OraDefine(cCursor, 2, SQLT_INT); OraExec(cCursor, 1, 50, 0, 0, nFetched); for i := 1 to nFetched do sName := OraGetString(cCursor, "1", i); nAge := OraGetInt(cCursor, "2", i); write(sName, 32); write(nAge, 5); writeln; end; OraClose(cCursor); OraLogoff(hConnection); end TMain; dclsql sqlSelect: SELECT * FROM persons;
Howard 33Michael 44Bobby 61Sara 38
OraArrayFetch.bdf, OraSample.bdf