Hi Does the script work without moving the query into custom functions? Can you confirm your exact query executes in another program and ensure any parameters are passed correctly. In general passing sql is not a problem, this is my working example: function FExecuteQuery(Query : sql) var i : number; begin OdbcAlloc(SQL_HANDLE_ENV, hEnv); OdbcAlloc(SQL_HANDLE_DBC, hDbc, hEnv); OdbcConnect(hDbc, sConnectString); OdbcOpen(cCursor, hDbc); OdbcPrepare(cCursor, HoursSinceLastUpdate); // define datatype of returned fields - change depending on number of fields being returned OdbcDefine(cCursor, "1", SQL_C_CHAR); OdbcDefine(cCursor, "2", SQL_C_CHAR); OdbcExecute(cCursor); OdbcDisconnect(hDbc); OdbcFree(hDbc); OdbcFree(hEnv); end FExecuteQuery; dclsql HoursSinceLastUpdate: SELECT Code, Company_Name ,Name, Severity, DATEDIFF(hh, Last_Updated, GetDate()) AS 'HoursSinceLastUpdate' FROM Support_Incident;
↧