📄 sdcsb.pas
字号:
SqlSss: function(Cur: SQLTCUR; size: SQLTDAL): SqlTAPI; stdcall;
SqlSta: function(Cur: SQLTCUR; var srv: SQLTSTC; svw: SQLTSTC;
var spr: SQLTSTC; var spw: SQLTSTC): SqlTAPI; stdcall;
SqlStm: function(shandle: SQLTSVH): SqlTAPI; stdcall;
SqlSto: function(Cur: SQLTCUR; cnp: SQLTDAP; cnl: SQLTDAL;
ctp: SQLTDAP; ctl: SQLTDAL): SqlTAPI; stdcall;
SqlStr: function(Cur: SQLTCUR): SqlTAPI; stdcall;
SqlSxt: function(srvno: SQLTSVN; password: SQLTDAP): SqlTAPI; stdcall;
SqlTec: function(rcd: SQLTRCD; np: SQLTRCDPTR): SqlTAPI; stdcall;
SqlTem: function(Cur: SQLTCUR; xer: SQLTXERPTR; msgtyp: SQLTPTY;
bfp: SQLTDAP; bfl: SQLTDAL; txtlen: SQLTDALPTR): SqlTAPI; stdcall;
SqlTio: function(Cur: SQLTCUR; timeout: SQLTTIV): SqlTAPI; stdcall;
SqlUnl: function(Cur: SQLTCUR; cmdp: SQLTDAP; cmdl: SQLTDAL): SqlTAPI; stdcall;
SqlUrs: function(Cur: SQLTCUR): SqlTAPI; stdcall;
SqlWdc: function(Cur: SQLTCUR; bufp: SQLTDAP; bufl: SQLTDAL): SqlTAPI; stdcall;
SqlWlo: function(Cur: SQLTCUR; bufp: SQLTDAP; bufl: SQLTDAL): SqlTAPI; stdcall;
SqlXad: function(op: SQLTNMP; np1: SQLTNMP; nl1: SQLTNML; np2: SQLTNMP; nl2: SQLTNML): SqlTAPI; stdcall;
SqlXcn: function(op: SQLTNMP; ip: SQLTDAP; il: SQLTDAL): SqlTAPI; stdcall;
SqlXda: function(op: SQLTNMP; dp: SQLTNMP; dl: SQLTNML; days: SQLTDAY): SqlTAPI; stdcall;
SqlXdp: function(op: SQLTDAP; ol: SQLTDAL; ip: SQLTNMP; il: SQLTNML;
pp: SQLTDAP; pl: SQLTDAL): SqlTAPI; stdcall;
SqlXdv: function(op: SQLTNMP; np1: SQLTNMP; nl1: SQLTNML; np2: SQLTNMP; nl2: SQLTNML): SqlTAPI; stdcall;
SqlXer: function(Cur: SQLTCUR; ErrNo: SQLTXERPTR; ErrBuf: SQLTDAP; BufLen: SQLTDALPTR): SqlTAPI; stdcall;
SqlXml: function(op: SQLTNMP; np1: SQLTNMP; nl1: SQLTNML; np2: SQLTNMP; nl2: SQLTNML): SqlTAPI; stdcall;
SqlXnp: function(Outp: SQLTDAP; OutL: SQLTDAL; isnp: SQLTNMP; isnl: SQLTNML;
PicP: SQLTDAP; PicL: SQLTDAL): SqlTAPI; stdcall;
SqlXpd: function(op: SQLTNMP; var ol: SQLTNML; ip: SQLTDAP; pp: SQLTDAP; pl: SQLTDAL): SqlTAPI; stdcall;
SqlXsb: function(op: SQLTNMP; np1: SQLTNMP; nl1: SQLTNML; np2: SQLTNMP; nl2: SQLTNML): SqlTAPI; stdcall;
// SQLBase 7.0
SqlCch: function(var hCon: SQLTCON; dbnamp: SQLTDAP; dbnaml: SQLTDAL; fType: SQLTMOD): SqlTAPI; stdcall;
SqlDch: function(hCon: SQLTCON): SqlTAPI; stdcall;
SqlOpc: function(var Cur: SQLTCUR; hCon: SQLTCON; fType: SQLTMOD): SqlTAPI; stdcall;
{$ENDIF}
type
TCSBLogon = SQLTCON; // SQLBase7 connection handle
TCSBCursor = SqlTCur; // SQLBase Cursor type
TCSBSrvCursor = SQLTSVH;
ESDCSBError = class(ESDEngineError);
{ TICsbDatabase }
TICsbConnInfo = packed record
ServerType: Byte;
hLogon: TCSBLogon; // cursor(SQLBase6) or connection(SQLBase7)
hCursor: TCSBCursor; // cursor handle
ConnectStr: string; // store connect string
end;
TICsbDatabase = class(TISqlDatabase)
private
FHandle: TSDPtr;
FIsTransLogging: Boolean;
procedure Check(Status: TSDEResult);
procedure AllocHandle;
procedure FreeHandle;
procedure ChangePreservedProps;
function GetConnectStr: string;
function GetCurHandle: TCSBCursor;
function GetLogHandle: TCSBLogon;
procedure SetNullIndicatorError(Value: Boolean);
procedure SetDefaultOptions;
protected
function GetHandle: TSDPtr; override;
procedure DoConnect(const sRemoteDatabase, sUserName, sPassword: string); override;
procedure DoDisconnect(Force: Boolean); override;
procedure DoCommit; override;
procedure DoRollback; override;
procedure DoStartTransaction; override;
procedure SetAutoCommitOption(Value: Boolean); override;
procedure SetHandle(AHandle: TSDPtr); override;
public
constructor Create(ADbParams: TStrings); override;
destructor Destroy; override;
function CreateSqlCommand: TISqlCommand; override;
function GetClientVersion: LongInt; override;
function GetServerVersion: LongInt; override;
function GetVersionString: string; override;
function GetSchemaInfo(ASchemaType: TSDSchemaType; AObjectName: string): TISqlCommand; override;
function ParamValue(Value: TSDDatabaseParam): Integer; override;
procedure SetTransIsolation(Value: TISqlTransIsolation); override;
function SPDescriptionsAvailable: Boolean; override;
function TestConnected: Boolean; override;
function UseConnHandle: Boolean;
property ConnectStr: string read GetConnectStr;
property CurHandle: TCSBCursor read GetCurHandle;
property LogHandle: TCSBLogon read GetLogHandle;
property IsTransLogging: Boolean read FIsTransLogging;
end;
{ TICsbCommand }
TICsbCommand = class(TISqlCommand)
private
FHandle: PSDCursor;
FRowFetched: Boolean; // if FetchNextRow was called (it's used for get parameter's values)
FBlobPieceSize: Integer; // to minimize call SqlDatabase.
function GetSqlDatabase: TICsbDatabase;
function GetCurHandle: TCsbCursor;
procedure Connect;
procedure ClearBindParams;
function CnvtDBDateTime2DateTimeRec(ADataType: TFieldType; Buffer: TSDPtr; BufSize: Integer): TDateTimeRec;
function DBDateTimeFormat(ADataType: TFieldType): string;
function DBDateTimeStrLen(ADataType: TFieldType): Integer;
procedure SetDefaultParams;
procedure SetPreservation(Value: Boolean);
procedure QBindParamsBuffer;
procedure SpBindParamsBuffer;
procedure SpGetOutputParams;
protected
procedure Check(Status: TSDEResult);
procedure CheckPrepared;
procedure BindParamsBuffer; override;
function CnvtDateTime2DBDateTime(ADataType: TFieldType; Value: TDateTime; Buffer: TSDValueBuffer; BufSize: Integer): Integer; override;
procedure InitParamList; override;
function FieldDataType(ExtDataType: Integer): TFieldType; override;
procedure FreeParamsBuffer; override;
procedure DoExecute; override;
procedure DoExecDirect(Value: string); override;
procedure DoPrepare(Value: string); override;
function GetHandle: PSDCursor; override;
procedure GetFieldDescs(Descs: TSDFieldDescList); override;
function NativeDataSize(FieldType: TFieldType): Word; override;
function NativeDataType(FieldType: TFieldType): Integer; override;
function RequiredCnvtFieldType(FieldType: TFieldType): Boolean; override;
procedure SetFieldsBuffer; override;
public
constructor Create(ASqlDatabase: TISqlDatabase); override;
destructor Destroy; override;
// command interface
procedure CloseResultSet; override;
procedure Disconnect(Force: Boolean); override;
function GetRowsAffected: Integer; override;
// cursor interface
function FetchNextRow: Boolean; override;
function GetCnvtFieldData(AFieldDesc: TSDFieldDesc; Buffer: TSDPtr; BufSize: Integer): Boolean; override;
procedure GetOutputParams; override;
function ResultSetExists: Boolean; override;
function ReadBlob(AFieldDesc: TSDFieldDesc; var BlobData: TSDBlobData): Longint; override;
function WriteBlob(FieldNo: Integer; const Buffer: TSDValueBuffer; Count: Longint): Longint; override;
function WriteBlobByName(Name: string; const Buffer: TSDValueBuffer; Count: Longint): Longint; override;
property CurHandle: TCSBCursor read GetCurHandle;
property SqlDatabase: TICsbDatabase read GetSqlDatabase;
end;
const
DefSqlApiDLL = 'SQLWNTM.DLL';
var
SqlApiDLL: string;
{$IFDEF SD_CLR}
type
[StructLayout(LayoutKind.Sequential)]
TGdiDefx = record
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 31)]
gdifl1: string; // filler reserved for future use */
gdifl2: ubyte1; // filler reserved for future use
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 31)]
gdilbb: string; // label buffer
gdilbl: SQLTLBL; // label info length
gdicol: SQLTSLC; // select column number
gdiddt: SQLTDDT; // database data type
gdiddl: SQLTDEDL; // database extended data length
gdiedt: SQLTDDT; // external data type
gdiedl: SQLTDEDL; // external extended data length
gdipre: SQLTPRE; // decimal precision
gdisca: SQLTSCA; // decimal scale
gdinul: byte2; // null indicator
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 47)]
gdichb: string; // column heading buffer
gdichl: SQLTCHL; // column heading length
gdifil: array[0..1] of byte1; // for future use
end;
TGdiDef = TGdiDefx;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlbld')]
function SqlBld(Cur: SQLTCUR; bnp: SQLTBNP; bnl: SQLTBNL): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlbln')]
function SqlBln(Cur: SQLTCUR; bnn: SQLTBNN): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlbna')]
function SqlBna(Cur: SQLTCUR; bnp: SQLTBNP; bnl: SQLTBNL; dap: SQLTDAP; dal: SQLTDAL;
sca: SQLTSCA; pdt: SQLTPDT; nli: SQLTNUL): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlbnd')]
function SqlBnd(Cur: SQLTCUR; bnp: SQLTBNP; bnl: SQLTBNL; dap: SQLTDAP; dal: SQLTDAL;
sca: SQLTSCA; pdt: SQLTPDT): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlbnu')]
function SqlBnu(Cur: SQLTCUR; bnn: SQLTBNN; dap: SQLTDAP; dal: SQLTDAL;
sca: SQLTSCA; pdt: SQLTPDT; nli: SQLTNUL): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlbss')]
function SqlBss(shandle: SQLTSVH; dbname: SQLTDAP; dbnamel: SQLTDAL;
bkpdir: SQLTFNP; bkpdirl: SQLTFNL; local: SQLTBOO; over: SQLTBOO): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlcbv')]
function SqlCbv(Cur: SqlTCUR): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlcdr')]
function SqlCdr(sHandle: SQLTSVH; Cur: SqlTCUR): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlcex')]
function SqlCex(Cur: SqlTCUR; pData: SqlTDAP; lData: SqlTDAL): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlcmt')]
function SqlCmt(Cur: SqlTCur): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlcnc')]
function SqlCnc(var Cur: SqlTCur{Cur: SqlTCurPtr}; pDbName: SqlTDAP; lDbName: SqlTDAL): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlcnr')]
function SqlCnr(var Cur: SqlTCUR; pDbname: SqlTDAP; lDbName: SqlTDAL): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlcom')]
function SqlCom(Cur: SqlTCUR; pCmd: SqlTDAP; lCmd: SqlTDAL): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlcon')]
function SqlCon(var Cur: SqlTCUR; pDbName: SqlTDAP; lDbname: SqlTDAL;
CurSiz: SqlTWSI; Pages: SqlTNPG; Recovr: SqlTRCF;
OutSize: SqlTDAL; InSize: SqlTDAL): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlcpy')]
function SqlCpy(fcur: SQLTCUR; selp: SQLTDAP; sell: SQLTDAL;
tcur: SQLTCUR; isrtp: SQLTDAP; isrtl: SQLTDAL): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlcre')]
function SqlCre(shandle: SQLTSVH; dbnamp: SQLTDAP; dbnaml: SQLTDAL): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlcsv')]
function SqlCsv(var shandlep: SQLTSVH; serverid: SQLTDAP; password: SQLTDAP): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlcty')]
function SqlCty(cur: SQLTCUR; var cty: SQLTCTY): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqldbn')]
function SqlDbn(serverid: SQLTDAP; buffer: SQLTDAP; length: SQLTDAL): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlded')]
function SqlDed(shandle: SQLTSVH; dbnamp: SQLTDAP; dbnaml: SQLTDAL): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqldel')]
function SqlDel(shandle: SQLTSVH; dbnamp: SQLTDAP; dbnaml: SQLTDAL): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqldis')]
function SqlDis(cur: SQLTCUR): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqldon')]
function SqlDon: SqlTApi; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqldsc')]
function SqlDsc(Cur: SQLTCUR; slc: SQLTSLC; var edt: SQLTDDT; var edl: SQLTDDL;
chp: SQLTCHP; var chlp: SQLTCHL;
var prep: SQLTPRE; var scap: SQLTSCA): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqldst')]
function SqlDst(cur: SQLTCUR; cnp: SQLTDAP; cnl: SQLTDAL): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqldsv')]
function SqlDsv(shandle: SQLTSVH): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlelo')]
function SqlElo(Cur: SQLTCUR): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlepo')]
function SqlEpo(Cur: SQLTCUR; var epo: SQLTEPO): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlexe')]
function SqlExe(Cur: SQLTCUR): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlfer')]
function SqlFer(error: SQLTRCD; msg: SQLTDAP): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlfet')]
function SqlFet(Cur: SQLTCUR): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlgdi')]
function SqlGdi(Cur: SQLTCUR; var gdi: TGdiDef): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlget')]
function SqlGet(Cur: SQLTCUR; parm: SQLTPTY; p: SQLTDAP; var l: SQLTDAL): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlgls')]
function SqlGls(Cur: SQLTCUR; slc: SQLTSLC; var size: SqlTLsi): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlind')]
function SqlInd(sHandle: SQLTSVH; pDbName: SQLTDAP; lDbName: SQLTDAL): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlini')]
function SqlIni(CallBack: SQLTPFP): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqllsk')]
function SqlLsk(Cur: SQLTCUR; slc: SQLTSLC; pos: SQLTLSI): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlnbv')]
function SqlNbv(Cur: SQLTCUR; var nbv: SQLTNBV): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlnrr')]
function SqlNrr(Cur: SQLTCUR; var rcountp: SQLTROW): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlnsi')]
function SqlNsi(Cur: SQLTCUR; var nsi: SQLTNSI): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlrbk')]
function SqlRbk(Cur: SQLTCUR): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlret')]
function SqlRet(Cur: SQLTCUR; cnp: SQLTDAP; cnl: SQLTDAL): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlrlf')]
function SqlRlf(shandle: SQLTSVH; dbname: SQLTDAP; dbnamel: SQLTDAL;
bkpdir: SQLTFNP; bkpdirl: SQLTFNL;
local: SQLTBOO; over: SQLTBOO): SqlTAPI; external;
[DllImport(DefSqlApiDLL, CharSet = CharSet.Ansi, SetLastError = True, EntryPoint = 'sqlrlo')]
function SqlRlo(Cur: SQLTCUR; slc: SQLTSLC;
bufp: SQLTDAP; bufl: SQLTDAL; var readl: SQLTDAL): SqlTAPI; external;
[
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -