📄 sdmss.pas
字号:
{**********************************************************}
{ }
{ Delphi SQLDirect Component Library }
{ MS SQLServer API (DB-LIB, 03-04-96) Interface Unit }
{ }
{ Copyright (c) 1997,2005 by Yuri Sheino }
{ }
{**********************************************************}
{$I SqlDir.inc}
unit SDMss {$IFDEF SD_CLR} platform {$ENDIF};
interface
uses
Windows, SysUtils, Classes, Db, SyncObjs,
{$IFDEF SD_VCL6}
Variants,
{$ENDIF}
{$IFDEF SD_CLR}
System.Text, System.Runtime.InteropServices,
{$ENDIF}
SDConsts, SDCommon;
{*****************************************************************************
* *
* SQLFRONT.H - DB-Library header file for the Microsoft SQL Server. *
* *
* All constant and macro definitions for DB-Library applications programming *
* are contained in this file. This file must be included before SQLDB.H and *
* one of the following #defines must be made, depending on the operating *
* system: DBMSDOS, DBMSWIN or DBNTWIN32. *
* *
*****************************************************************************}
// call convention
// #define SQLAPI cdecl
{*****************************************************************************
Datatype definitions
*****************************************************************************}
type
void = TSDPtr;
INT = Integer;
LONG = LongInt;
USHORT = Word;
BOOL = INT;
LPINT = ^INT;
LPVOID = ^void;
{$IFDEF SD_CLR}
LPBYTE = TSDCharPtr;
LPCSTR = TSDCharPtr;
LPSTR = TSDCharPtr;
{$ELSE}
LPBYTE = PChar;
{$ENDIF}
type
// DBPROCESS, LOGINREC and DBCURSOR
PDBPROCESS = TSDPtr; // pointer to the dbprocess structure
PLOGINREC = TSDPtr; // pointer to the login record
PDBCURSOR = TSDPtr; // pointer to the cursor record
PDBHANDLE = TSDPtr; // pointer to the generic handle
{#define PTR *
typedef int (SQLAPI *SQLFARPROC)();
#else
typedef long (far pascal *LGFARPROC)(); // Windows loadable driver fp
#endif}
{*****************************************************************************
DB-Library datatype definitions
*****************************************************************************}
const
DBMAXCHAR = 256; // Max length of DBVARBINARY and DBVARCHAR, etc.
type
RETCODE = INT;
STATUS = INT;
// DB-Library datatypes
DBCHAR = CHAR;
DBBINARY = UCHAR;
DBTINYINT = BYTE;
DBSMALLINT = SHORT;
DBUSMALLINT = USHORT;
DBINT = LONG;
DBFLT8 = Double;
DBBIT = BYTE;
DBBOOL = BYTE;
DBFLT4 = Single;
DBMONEY4 = LONG;
DBREAL = DBFLT4;
DBUBOOL = UINT;
DBDATETIME4 = record // 4-byte smalldatetime
numdays: USHORT; // No of days since Jan-1-1900
nummins: USHORT; // No. of minutes since midnight
end;
DBDATETIM4 = DBDATETIME4;
DBVARYCHAR = record
len: DBSMALLINT;
str: array [0..DBMAXCHAR-1] of DBCHAR;
end;
DBVARYBIN = record
len: DBSMALLINT;
arr: array[0..DBMAXCHAR-1] of BYTE;
end;
DBMONEY = record
mnyhigh: DBINT;
mnylow: ULONG;
end;
DBDATETIME = packed record // 8-byte datetime
dtdays: DBINT; // Days since Jan 1, 1900
dttime: ULONG; // 300ths of a second since midnight
end;
// DBDATEREC structure used by dbdatecrack
DBDATEREC = record
year: INT; // 1753 - 9999
quarter: INT; // 1 - 4
month: INT; // 1 - 12
dayofyear: INT; // 1 - 366
day: INT; // 1 - 31
week: INT; // 1 - 54 (for leap years)
weekday: INT; // 1 - 7 (Mon - Sun)
hour: INT; // 0 - 23
minute: INT; // 0 - 59
second: INT; // 0 - 59
millisecond:INT; // 0 - 999
end;
const
MAXNUMERICLEN = 16;
MAXNUMERICDIG = 38;
DEFAULTPRECISION = 18;
DEFAULTSCALE = 0;
type
DBNUMERIC = record
precision: BYTE;
scale: BYTE;
sign: BYTE; // 1 = Positive, 0 = Negative
val: array[0..MAXNUMERICLEN-1] of BYTE;
end;
DBDECIMAL = DBNUMERIC;
// Pack the following structures on a word boundary
{#ifdef __BORLANDC__
#pragma option -a+
#else
#ifndef DBLIB_SKIP_PRAGMA_PACK // Define this if your compiler does not support #pragma pack()
#pragma pack(2)
#endif
#endif}
const
MAXCOLNAMELEN = 30;
MAXTABLENAME = 30;
MAXSERVERNAME = 30;
MAXNETLIBNAME = 255;
MAXNETLIBCONNSTR = 255;
type
TDBPROCINFO = record
SizeOfStruct: DBINT;
ServerType: BYTE;
ServerMajor: USHORT;
ServerMinor: USHORT;
ServerRevision: USHORT;
ServerName: array[0..MAXSERVERNAME] of CHAR;
NetLibName: array[0..MAXNETLIBNAME] of CHAR;
NetLibConnStr: array[0..MAXNETLIBCONNSTR] of CHAR;
end;
LPDBPROCINFO = ^TDBPROCINFO;
TDBCURSORINFO = record
SizeOfStruct: DBINT; // Use sizeof(DBCURSORINFO)
TotCols: ULONG; // Total Columns in cursor
TotRows: ULONG; // Total Rows in cursor
CurRow: ULONG; // Current actual row in server
TotRowsFetched: ULONG; // Total rows actually fetched
CuMssSetErrHandlerrType: ULONG; // See CU_...
Status: ULONG; // See CU_...
end;
LPDBCURSORINFO = ^TDBCURSORINFO;
const
INVALID_UROWNUM = ULONG(-1);
{*****************************************************************************
Pointer Datatypes
*****************************************************************************}
type
LPCINT = LPINT;
LPCBYTE = LPBYTE;
LPUSHORT = ^USHORT;
LPCUSHORT = LPUSHORT;
LPDBINT = ^DBINT;
LPCDBINT = LPDBINT;
LPDBBINARY = ^DBBINARY;
LPCDBBINARY = LPDBBINARY;
LPDBDATEREC = ^DBDATEREC;
LPCDBDATEREC = LPDBDATEREC;
LPDBDATETIME = ^DBDATETIME;
LPCDBDATETIME = LPDBDATETIME;
{*****************************************************************************
General #defines
*****************************************************************************}
const
TIMEOUT_IGNORE = ULONG(-1);
TIMEOUT_INFINITE = ULONG(0);
TIMEOUT_MAXIMUM = ULONG(1200); // 20 minutes maximum timeout value
// Used for ServerType in dbgetprocinfo
SERVTYPE_UNKNOWN = 0;
SERVTYPE_MICROSOFT = 1;
// Used by dbcolinfo
//enum CI_TYPES { CI_REGULAR=1, CI_ALTERNATE=2, CI_CURSOR=3 };
CI_REGULAR = 1;
CI_ALTERNATE = 2;
CI_CURSOR = 3;
const
// Bulk Copy Definitions (bcp)
DB_IN = 1; // Transfer from client to server
DB_OUT = 2; // Transfer from server to client
BCPMAXERRS = 1; // bcp_control parameter
BCPFIRST = 2; // bcp_control parameter
BCPLAST = 3; // bcp_control parameter
BCPBATCH = 4; // bcp_control parameter
BCPKEEPNULLS = 5; // bcp_control parameter
BCPABORT = 6; // bcp_control parameter
// redefine predefined constants
DB_TRUE = 1;
DB_FALSE = 0;
TINYBIND = 1;
SMALLBIND = 2;
INTBIND = 3;
CHARBIND = 4;
BINARYBIND = 5;
BITBIND = 6;
DATETIMEBIND = 7;
MONEYBIND = 8;
FLT8BIND = 9;
STRINGBIND = 10;
NTBSTRINGBIND = 11;
VARYCHARBIND = 12;
VARYBINBIND = 13;
FLT4BIND = 14;
SMALLMONEYBIND = 15;
SMALLDATETIBIND = 16;
DECIMALBIND = 17;
NUMERICBIND = 18;
SRCDECIMALBIND = 19;
SRCNUMERICBIND = 20;
MAXBIND = SRCNUMERICBIND;
DBSAVE = 1;
DBNOSAVE = 0;
DBNOERR = -1;
DBFINDONE = $04; // Definately done
DBMORE = $10; // Maybe more commands waiting
DBMORE_ROWS = $20; // This command returned rows
MAXNAME = 31;
DBTXTSLEN = 8; // Timestamp length
DBTXPLEN = 16; // Text pointer length
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -