📄 zlibibsql.pas
字号:
Tisc_dsql_describe_bind = function(status_vector: PISC_STATUS;
stmt_handle: PISC_STMT_HANDLE; dialect: Word; xsqlda: PXSQLDA): ISC_STATUS;
stdcall;
Tisc_dsql_execute = function(status_vector: PISC_STATUS;
tran_handle: PISC_TR_HANDLE; stmt_handle: PISC_STMT_HANDLE; dialect: Word;
xsqlda: PXSQLDA): ISC_STATUS; stdcall;
Tisc_dsql_execute2 = function(status_vector: PISC_STATUS;
tran_handle: PISC_TR_HANDLE; stmt_handle: PISC_STMT_HANDLE; dialect: Word;
in_xsqlda, out_xsqlda: PXSQLDA): ISC_STATUS; stdcall;
Tisc_dsql_execute_immediate = function(status_vector: PISC_STATUS;
db_handle: PISC_DB_HANDLE; tran_handle: PISC_TR_HANDLE; length: Word;
statement: PChar; dialect: Word; xsqlda: PXSQLDA): ISC_STATUS; stdcall;
Tisc_dsql_fetch = function(status_vector: PISC_STATUS;
stmt_handle: PISC_STMT_HANDLE; dialect: Word; xsqlda: PXSQLDA): ISC_STATUS;
stdcall;
Tisc_dsql_free_statement = function(status_vector: PISC_STATUS;
stmt_handle: PISC_STMT_HANDLE; options: Word): ISC_STATUS; stdcall;
Tisc_dsql_prepare = function(status_vector: PISC_STATUS;
tran_handle: PISC_TR_HANDLE; stmt_handle: PISC_STMT_HANDLE;
length: Word; statement: PChar; dialect: Word; xsqlda: PXSQLDA):
ISC_STATUS; stdcall;
Tisc_dsql_set_cursor_name = function(status_vector: PISC_STATUS;
stmt_handle: PISC_STMT_HANDLE; cursor_name: PChar; _type: Word): ISC_STATUS;
stdcall;
Tisc_dsql_sql_info = function(status_vector: PISC_STATUS;
stmt_handle: PISC_STMT_HANDLE; item_length: Short; items: PChar;
buffer_length: Short; buffer: PChar): ISC_STATUS; stdcall;
{ Blob processing routines }
Tisc_open_blob2 = function(status_vector: PISC_STATUS;
db_handle: PISC_DB_HANDLE; tran_handle: PISC_TR_HANDLE;
blob_handle: PISC_BLOB_HANDLE; blob_id: PISC_QUAD; bpb_length: Short;
bpb_buffer: PChar): ISC_STATUS; stdcall;
Tisc_create_blob2 = function(status_vector: PISC_STATUS;
db_handle: PISC_DB_HANDLE; tran_handle: PISC_TR_HANDLE;
blob_handle: PISC_BLOB_HANDLE; blob_id: PISC_QUAD; bpb_length: Short;
bpb_address: PChar): ISC_STATUS; stdcall;
Tisc_blob_info = function(status_vector: PISC_STATUS;
blob_handle: PISC_BLOB_HANDLE; item_list_buffer_length: Short;
item_list_buffer: PChar; result_buffer_length: Short; result_buffer: PChar):
ISC_STATUS; stdcall;
Tisc_close_blob = function(status_vector: PISC_STATUS;
blob_handle: PISC_BLOB_HANDLE): ISC_STATUS; stdcall;
Tisc_cancel_blob = function(status_vector: PISC_STATUS;
blob_handle: PISC_BLOB_HANDLE): ISC_STATUS; stdcall;
Tisc_get_segment = function(status_vector: PISC_STATUS;
blob_handle: PISC_BLOB_HANDLE; actual_seg_length: PWord;
seg_buffer_length: Word; seg_buffer: PChar): ISC_STATUS; stdcall;
Tisc_put_segment = function(status_vector: PISC_STATUS;
blob_handle: PISC_BLOB_HANDLE; seg_buffer_len: Word; seg_buffer: PChar):
ISC_STATUS; stdcall;
{ Event processing routines }
Tisc_event_block = function(event_buffer: PPChar; result_buffer: PPChar;
id_count: Word; event_list: array of PChar): ISC_LONG; cdecl;
Tisc_event_counts = procedure(status_vector: PISC_STATUS;
buffer_length: Short; event_buffer: PChar; result_buffer: PChar); stdcall;
Tisc_cancel_events = function(status_vector: PISC_STATUS;
db_handle: PISC_DB_HANDLE; event_id: PISC_LONG): ISC_STATUS; stdcall;
Tisc_que_events = function(status_vector: PISC_STATUS;
db_handle: PISC_DB_HANDLE; event_id: PISC_LONG; length: Short;
event_buffer: PChar; event_function: TISC_CALLBACK;
event_function_arg: PVoid): ISC_STATUS; stdcall;
{ Types convertion routines }
Tisc_decode_date = procedure(ib_date: PISC_QUAD; tm_date: PCTimeStructure);
stdcall;
Tisc_encode_date = procedure(tm_date: PCTimeStructure; ib_date: PISC_QUAD);
stdcall;
{ Interbase Version 6 routines }
Tisc_decode_sql_date = procedure(ib_date: PISC_DATE;
tm_date: PCTimeStructure); stdcall;
Tisc_decode_sql_time = procedure(ib_time: PISC_TIME;
tm_date: PCTimeStructure); stdcall;
Tisc_decode_timestamp = procedure(ib_timestamp: PISC_TIMESTAMP;
tm_date: PCTimeStructure); stdcall;
Tisc_encode_sql_date = procedure(tm_date: PCTimeStructure;
ib_date: PISC_DATE); stdcall;
Tisc_encode_sql_time = procedure(tm_date: PCTimeStructure;
ib_time: PISC_TIME); stdcall;
Tisc_encode_timestamp = procedure(tm_date: PCTimeStructure;
ib_timestamp: PISC_TIMESTAMP); stdcall;
Tisc_vax_integer = function(buffer: PChar; length: Short): ISC_LONG; stdcall;
{************* Plain API Function variables definition ************}
var
{ General database routines }
isc_attach_database: Tisc_attach_database;
isc_detach_database: Tisc_detach_database;
isc_drop_database: Tisc_drop_database;
isc_database_info: Tisc_database_info;
isc_free: Tisc_free;
isc_sqlcode: Tisc_sqlcode;
isc_sql_interprete: Tisc_sql_interprete;
isc_interprete: Tisc_interprete;
{ Transaction support routines }
isc_start_transaction: Tisc_start_transaction;
isc_start_multiple: Tisc_start_multiple;
isc_rollback_transaction: Tisc_rollback_transaction;
isc_rollback_retaining: Tisc_rollback_retaining;
isc_commit_transaction: Tisc_commit_transaction;
isc_commit_retaining: Tisc_commit_retaining;
{ Dynamic SQL routines }
isc_dsql_allocate_statement: Tisc_dsql_allocate_statement;
isc_dsql_alloc_statement2: Tisc_dsql_alloc_statement2;
isc_dsql_describe: Tisc_dsql_describe;
isc_dsql_describe_bind: Tisc_dsql_describe_bind;
isc_dsql_execute: Tisc_dsql_execute;
isc_dsql_execute2: Tisc_dsql_execute2;
isc_dsql_execute_immediate: Tisc_dsql_execute_immediate;
isc_dsql_fetch: Tisc_dsql_fetch;
isc_dsql_free_statement: Tisc_dsql_free_statement;
isc_dsql_prepare: Tisc_dsql_prepare;
isc_dsql_set_cursor_name: Tisc_dsql_set_cursor_name;
isc_dsql_sql_info: Tisc_dsql_sql_info;
{ Array processing routines }
isc_array_gen_sdl: Tisc_array_gen_sdl;
isc_array_get_slice: Tisc_array_get_slice;
isc_array_lookup_bounds: Tisc_array_lookup_bounds;
isc_array_lookup_desc: Tisc_array_lookup_desc;
isc_array_set_desc: Tisc_array_set_desc;
isc_array_put_slice: Tisc_array_put_slice;
{ Blob processing routines }
isc_open_blob2: Tisc_open_blob2;
isc_create_blob2: Tisc_create_blob2;
isc_blob_info: Tisc_blob_info;
isc_close_blob: Tisc_close_blob;
isc_cancel_blob: Tisc_cancel_blob;
isc_get_segment: Tisc_get_segment;
isc_put_segment: Tisc_put_segment;
{ Event processing routines }
isc_que_events: Tisc_que_events;
isc_event_counts: Tisc_event_counts;
isc_event_block: Tisc_event_block;
isc_cancel_events: Tisc_cancel_events;
{ Types convertion routines }
isc_encode_date: Tisc_encode_date;
isc_decode_date: Tisc_decode_date;
isc_vax_integer: Tisc_vax_integer;
isc_encode_sql_date: Tisc_encode_sql_date;
isc_decode_sql_date: Tisc_decode_sql_date;
isc_encode_sql_time: Tisc_encode_sql_time;
isc_decode_sql_time: Tisc_decode_sql_time;
isc_encode_timestamp: Tisc_encode_timestamp;
isc_decode_timestamp: Tisc_decode_timestamp;
{ Library Initialization }
function IbSqlLoadLib: Boolean;
{ XSQLDA_LENGTH is defined in C as a macro, but in Pascal we must defined it
as a function... }
function XSQLDA_LENGTH(Value: LongInt): LongInt;
function GetIbSqlClientVersion: Integer;
procedure CheckIbSqlLoaded;
const
DLL: string = DEFAULT_DLL_LOCATION;
// hDLL: THandle = 0;
// ClientVersion: Integer = 0;
var
hDLL: THandle;
ClientVersion: Integer;
LibLoaded: Boolean;
implementation
uses SysUtils, ZDBaseConst;
procedure CheckIbSqlLoaded;
begin
if hDLL <= 0{HINSTANCE_ERROR} then
IbSqlLoadLib;
if hDLL <= 0{HINSTANCE_ERROR} then
raise Exception.CreateFmt(SLibraryNotFound, [DLL]);
end;
function GetIbSqlClientVersion: Integer;
begin
CheckIbSqlLoaded;
result := ClientVersion;
end;
{***************** Stub Functions ***************}
function isc_rollback_retaining_stub(status_vector: PISC_STATUS;
tran_handle: PISC_TR_HANDLE): ISC_STATUS; stdcall;
begin
raise Exception.CreateFmt('Feature %s is allowed only in Interbase 6.0',
['isc_rollback_retaining']);
end;
procedure isc_encode_sql_date_stub(tm_date: PCTimeStructure;
ib_date: PISC_DATE); stdcall;
begin
raise Exception.CreateFmt('Feature %s is allowed only in Interbase 6.0',
['isc_encode_sql_date']);
end;
procedure isc_encode_sql_time_stub(tm_date: PCTimeStructure;
ib_time: PISC_TIME); stdcall;
begin
raise Exception.CreateFmt('Feature %s is allowed only in Interbase 6.0',
['isc_encode_sql_time']);
end;
procedure isc_encode_timestamp_stub(tm_date: PCTimeStructure;
ib_timestamp: PISC_TIMESTAMP); stdcall;
begin
raise Exception.CreateFmt('Feature %s is allowed only in Interbase 6.0',
['isc_encode_sql_timestamp']);
end;
procedure isc_decode_sql_date_stub(ib_date: PISC_DATE;
tm_date: PCTimeStructure); stdcall;
begin
raise Exception.CreateFmt('Feature %s is allowed only in Interbase 6.0',
['isc_decode_sql_date']);
end;
procedure isc_decode_sql_time_stub(ib_time: PISC_TIME;
tm_date: PCTimeStructure); stdcall;
begin
raise Exception.CreateFmt('Feature %s is allowed only in Interbase 6.0',
['isc_decode_sql_time']);
end;
procedure isc_decode_timestamp_stub(ib_timestamp: PISC_TIMESTAMP;
tm_date: PCTimeStructure); stdcall;
begin
raise Exception.CreateFmt('Feature %s is allowed only in Interbase 6.0',
['isc_decode_timestamp']);
end;
{ Initialize Interbase dynamic library }
function IbSqlLoadLib: Boolean;
begin
if hDLL = 0 then
begin
hDLL := GetModuleHandle(PChar(DLL));
LibLoaded := False;
if hDLL = 0 then
begin
hDLL := LoadLibrary(PChar(DLL));
LibLoaded := True;
end;
end;
if hDLL <> 0 then
begin
isc_sqlcode := GetProcAddress(hDLL,'isc_sqlcode');
isc_sql_interprete := GetProcAddress(hDLL,'isc_sql_interprete');
isc_interprete := GetProcAddress(hDLL,'isc_interprete');
isc_vax_integer := GetProcAddress(hDLL,'isc_vax_integer');
isc_array_gen_sdl := GetProcAddress(hDLL, 'isc_array_gen_sdl');
isc_array_get_slice := GetProcAddress(hDLL, 'isc_array_get_slice');
isc_array_lookup_bounds := GetProcAddress(hDLL, 'isc_array_lookup_bounds');
isc_array_lookup_desc := GetProcAddress(hDLL, 'isc_array_lookup_desc');
isc_array_set_desc := GetProcAddress(hDLL, 'isc_array_set_desc');
isc_array_put_slice := GetProcAddress(hDLL, 'isc_array_put_slice');
isc_blob_info := GetProcAddress(hDLL,'isc_blob_info');
isc_open_blob2 := GetProcAddress(hDLL,'isc_open_blob2');
isc_close_blob := GetProcAddress(hDLL,'isc_close_blob');
isc_cancel_blob := GetProcAddress(hDLL,'isc_cancel_blob');
isc_get_segment := GetProcAddress(hDLL,'isc_get_segment');
isc_put_segment := GetProcAddress(hDLL,'isc_put_segment');
isc_create_blob2 := GetProcAddress(hDLL,'isc_create_blob2');
isc_decode_date := GetProcAddress(hDLL,'isc_decode_date');
isc_encode_date := GetProcAddress(hDLL,'isc_encode_date');
isc_dsql_free_statement := GetProcAddress(hDLL,'isc_dsql_free_statement');
isc_dsql_execute2 := GetProcAddress(hDLL,'isc_dsql_execute2');
isc_dsql_execute := GetProcAddress(hDLL,'isc_dsql_execute');
isc_dsql_set_cursor_name := GetProcAddress(hDLL,'isc_dsql_set_cursor_name');
isc_dsql_fetch := GetProcAddress(hDLL,'isc_dsql_fetch');
isc_dsql_sql_info := GetProcAddress(hDLL,'isc_dsql_sql_info');
isc_dsql_allocate_statement := GetProcAddress(hDLL,'isc_dsql_allocate_statement');
isc_dsql_alloc_statement2 := GetProcAddress(hDLL,'isc_dsql_alloc_statement2');
isc_dsql_prepare := GetProcAddress(hDLL,'isc_dsql_prepare');
isc_dsql_describe_bind := GetProcAddress(hDLL,'isc_dsql_describe_bind');
isc_dsql_describe := GetProcAddress(hDLL,'isc_dsql_describe');
isc_dsql_execute_immediate := GetProcAddress(hDLL,'isc_dsql_execute_immediate');
isc_drop_database := GetProcAddress(hDLL,'isc_drop_database');
isc_detach_database := GetProcAddress(hDLL,'isc_detach_database');
isc_attach_database := GetProcAddress(hDLL,'isc_attach_database');
isc_database_info := GetProcAddress(hDLL,'isc_database_info');
isc_start_multiple := GetProcAddress(hDLL,'isc_start_multiple');
isc_start_transaction := GetProcAddress(hDLL,'isc_start_transaction');
isc_commit_transaction := GetProcAddress(hDLL,'isc_commit_transaction');
isc_commit_retaining := GetProcAddress(hDLL,'isc_commit_retaining');
isc_rollback_transaction := GetProcAddress(hDLL,'isc_rollback_transaction');
isc_cancel_events := GetProcAddress(hDLL,'isc_cancel_events');
isc_que_events := GetProcAddress(hDLL,'isc_que_events');
isc_event_counts := GetProcAddress(hDLL,'isc_event_counts');
isc_event_block := GetProcAddress(hDLL,'isc_event_block');
isc_free := GetProcAddress(hDLL,'isc_free');
isc_rollback_retaining := GetProcAddress(hDLL, 'isc_rollback_retaining');
if Assigned(isc_rollback_retaining) then
begin
ClientVersion := 6;
isc_decode_sql_date := GetProcAddress(hDLL, 'isc_decode_sql_date');
isc_decode_sql_time := GetProcAddress(hDLL, 'isc_decode_sql_time');
isc_decode_timestamp := GetProcAddress(hDLL, 'isc_decode_timestamp');
isc_encode_sql_date := GetProcAddress(hDLL, 'isc_encode_sql_date');
isc_encode_sql_time := GetProcAddress(hDLL, 'isc_encode_sql_time');
isc_encode_timestamp := GetProcAddress(hDLL, 'isc_encode_timestamp');
end
else
begin
ClientVersion := 5;
isc_rollback_retaining := isc_rollback_retaining_stub;
isc_decode_sql_date := isc_decode_sql_date_stub;
isc_decode_sql_time := isc_decode_sql_time_stub;
isc_decode_timestamp := isc_decode_timestamp_stub;
isc_encode_sql_date := isc_encode_sql_date_stub;
isc_encode_sql_time := isc_encode_sql_time_stub;
isc_encode_timestamp := isc_encode_timestamp_stub;
end;
Result := True;
end
else
raise Exception.Create(Format(SLibraryNotFound, [DLL]));
end;
function XSQLDA_LENGTH(Value: LongInt): LongInt;
begin
Result := SizeOf(TXSQLDA) + ((Value - 1) * SizeOf(TXSQLVAR));
end;
initialization
hDLL := 0;
ClientVersion := 0;
finalization
if (hDLL <> 0) and LibLoaded then
FreeLibrary(hDLL);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -