動態創業數據存儲函數

返回:datastore

參數:string sql

DataStore dw_new
string error_syntaxfromSQL, error_create
string new_sql, new_syntax
Integer iRetrieve

new_sql = sql
new_syntax = SQLCA.SyntaxFromSQL(new_sql, 'Style(Type=Form)', error_syntaxfromSQL)

IF Len(error_syntaxfromSQL) > 0 THEN
// Display errors
gf_message(100, "gf_exec_sql_ret_datastore create syntax error~n" + error_syntaxfromSQL)

If bLogEnabled = TRUE Then
syslog.log("GF_EXEC_SQL_RET_DATASTORE:SYNTAX ERROR", new_sql + " Error:" + error_syntaxfromSQL)
End If

Return dw_new
ELSE
// Generate new DataWindow
dw_new = CREATE datastore

dw_new.Create(new_syntax, error_create)
IF Len(error_create) > 0 THEN
gf_message(100, "gf_exec_sql_ret_datastore create datawindow error~n" + error_create)

If bLogEnabled = TRUE Then
syslog.log("GF_EXEC_SQL_RET_DATASTORE:CREATE ERROR", new_sql + " Error:" + error_create)
End If

Destroy dw_new
Return dw_new
END IF
END IF

dw_new.SetTransObject(SQLCA)

iRetrieve = dw_new.Retrieve()

If iRetrieve = -1 /*or iRetrieve = 0*/ Then
gf_message(100, "gf_exec_sql_ret_datastore retrieve error~n" + "Retrieve Error Code = -1")

If bLogEnabled = TRUE Then
syslog.log("GF_EXEC_SQL_RET_DATASTORE:RETRIEVE ERROR", new_sql)
End If
End If

If bLogEnabled = TRUE Then
syslog.log("GF_EXEC_SQL_RET_DATASTORE:SQL", new_sql)
End If

Return dw_new

你可能感兴趣的:(sql)