f_connectdb_id.srf 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. $PBExportHeader$f_connectdb_id.srf
  2. global type f_connectdb_id from function_object
  3. end type
  4. forward prototypes
  5. global function integer f_connectdb_id (ref string arg_msg)
  6. end prototypes
  7. global function integer f_connectdb_id (ref string arg_msg);Int rslt = 1
  8. //id
  9. id_sqlca = CREATE Transaction
  10. id_sqlca.DBMS = "SNC SQL Native Client(OLE DB)"
  11. id_sqlca.Database = sqlca.database
  12. id_sqlca.UserID = sqlca.userid
  13. id_sqlca.DBPass = sqlca.dbpass
  14. id_sqlca.LogID = sqlca.logid
  15. id_sqlca.LogPass = sqlca.logpass
  16. id_sqlca.ServerName = sqlca.servername
  17. id_sqlca.DBParm = sqlca.dbparm
  18. id_sqlca.Lock = "RC"
  19. id_sqlca.AutoCommit = false
  20. CONNECT USING id_sqlca;
  21. IF id_sqlca.SQLCode < 0 THEN
  22. arg_msg = "取ID模块数据连接失败!" + id_sqlca.SQLErrText
  23. rslt = 0
  24. GOTO ext
  25. END IF
  26. EXECUTE IMMEDIATE "set transaction isolation level READ UNCOMMITTED" USING id_sqlca;
  27. execute immediate 'SET DEADLOCK_PRIORITY low' USING id_sqlca;
  28. IF id_sqlca.SQLCode <> 0 THEN
  29. HALT;
  30. END IF
  31. ext:
  32. RETURN rslt
  33. end function