if err <> SQL.SUCCESS then
status = SQLFreeConnect(conn1)
status = SQLFreeEnv(env1)
Call DSLogFatal("Erro na conexão com ":OraHost, fcname)
return(-1)
end
err = SQLAllocStmt(conn1, stmt1)
if err <> SQL.SUCCESS then
status = SQLDisconnect(conn1)
status = SQLFreeConnect(conn1)
status = SQLFreeEnv(env1)
Call DSLogFatal("Erro na alocação do comando '":SQL:"' em ":OraHost, fcname)
return(-1)
end
err = SQLExecDirect(stmt1, SQL)
status = SQLError(env1, conn1, stmt1, sqlstate, dbmscode, errmsg)
info = "SQL State: ":sqlstateFM:"DBMS Code: ":dbmscodeFM:errmsg
if err <> SQL.SUCCESS then
status = SQLFreeStmt(stmt1, SQL.DROP)
status = SQLDisconnect(conn1)
status = SQLFreeConnect(conn1)
status = SQLFreeEnv(env1)
Call DSLogFatal("Erro na execução do comando [":SQL:"] em ":OraHost:":"FM:info, fcname)
return(-1)
end
err = SQLNumResultCols(stmt1, numcols)
if err <> SQL.SUCCESS then
status = SQLFreeStmt(stmt1, SQL.DROP)
status = SQLDisconnect(conn1)
status = SQLFreeConnect(conn1)
status = SQLFreeEnv(env1)
Call DSLogFatal("Erro na execução do comando [":SQL:"] em ":OraHost:", comando SQLNumResultCols", fcname)
return(-1)
end
err = SQLRowCount(stmt1, rowcount)
if err <> SQL.SUCCESS then
status = SQLFreeStmt(stmt1, SQL.DROP)
status = SQLDisconnect(conn1)
status = SQLFreeConnect(conn1)
status = SQLFreeEnv(env1)
Call DSLogFatal("Erro na execução do comando [":SQL:"] em ":OraHost:", comando SQLRowCount", fcname)
return(-1)
end
if rowcount < 0 then rowcount = 0
if numcols = 0 then
status = SQLFreeStmt(stmt1, SQL.DROP)
status = SQLDisconnect(conn1)
status = SQLFreeConnect(conn1)
status = SQLFreeEnv(env1)
return(SQL.SUCCESS)
end
dimension line(numcols)
for i = 1 to numcols
status = SQLBindCol(stmt1, i, SQL.B.DEFAULT, line(i))
next
rownum = 0
loop while @True
err = SQLFetch(stmt1)
if err = 100 then exit
if err <> SQL.SUCCESS then
err = SQLError(env1, conn1, stmt1, sqlstate, dbmscode, errmsg)
status = SQLFreeStmt(stmt1, SQL.DROP)
status = SQLDisconnect(conn1)
status = SQLFreeConnect(conn1)
status = SQLFreeEnv(env1)
Call DSLogFatal("Erro na execução do comando [":SQL:"] em ":OraHost:", comando SQLFetch:"FM:"SQL State: ":sqlstateFM:"DBMS Code: ":dbmscodeFM:errmsg, fcname)
return(-1)
end
if result <> "" then result = resultFM
for i = 1 to numcols
result = result:line(i)
if i < numcols then result = result:","
next
rownum += 1
if rownum > rowlimit and rowlimit > 0 then exit
repeat
Ans = SQL.SUCCESS
status = SQLFreeStmt(stmt1, SQL.DROP)
status = SQLDisconnect(conn1)
status = SQLFreeConnect(conn1)
status = SQLFreeEnv(env1)
**********************************************************
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.