home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue47 / IntBase / frs_Ibase.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-04-28  |  25.3 KB  |  845 lines

  1. unit frs_Ibase;
  2.  
  3. {*************************************************************************
  4.                                                                           
  5.   UNIT:           Ibase.pas                                               
  6.   DESCRIPTION:      OSRI entrypoints and definitions for use with Delphi    
  7.                                                                           
  8.   AUTHOR:         Paul Reeves                                             
  9.                   Fleet River Software                                    
  10.                                                                           
  11.   Acknowledgements to InterBase Software Corporation                      
  12.                                                                           
  13. **************************************************************************}
  14.  
  15. interface
  16.  
  17. uses 
  18.     Windows
  19.   , SysUtils
  20.   ;
  21.  
  22.  
  23. const
  24.  
  25.     ISC_TRUE = 1;
  26.     ISC_FALSE = 0;
  27.  
  28.     DSQL_close = 1;
  29.     DSQL_drop = 2;
  30.  
  31.   IBASE_DLL = 'GDS32.DLL';
  32.  
  33. //  Ibase.h has lots of constant definitions. They cause a lot of clutter
  34. //  when it comes to reading the function definitions, so lets keep them separate.
  35.  
  36. {$include frs_Ibase_Const.inc}
  37.  
  38.  
  39. type
  40.  
  41. {*********************}
  42. {* Fundamental types *}
  43. {*********************}
  44.  
  45.   ISC_LONG = Longint;
  46.     PISC_LONG = ^ISC_LONG;
  47.  
  48.   PByte     = ^Byte;
  49.   PWord     = ^Word;
  50.   PSmallint = ^Smallint;
  51.   PInteger  = ^Integer;
  52.  
  53.   //short     = Smallint;     //defined in Windows.pas, usually.
  54.   PShort    = ^Short;
  55.   
  56.   PLong     = ^LongInt;
  57.   PFloat    = ^Single;
  58.   PSingle   = ^Single;
  59.   PDouble   = ^Double;
  60.  
  61.   ISC_QUAD = record
  62.     isc_quad_high: ISC_LONG;
  63.     isc_quad_low: Cardinal;
  64.   end;
  65.   PISC_QUAD = ^ISC_QUAD;
  66.  
  67.   TISC_QUAD = ISC_QUAD;
  68.  
  69. {*********************}
  70. {* InterBase handles *}
  71. {*********************}
  72.  
  73.   Tisc_att_handle = Pointer;        pisc_att_handle = ^Tisc_att_handle;
  74.     Tisc_blob_handle = Pointer;       pisc_blob_handle = ^Tisc_blob_handle;
  75.   Tisc_db_handle = Pointer;         pisc_db_handle = ^Tisc_db_handle;
  76.   Tisc_req_handle = Pointer;        pisc_req_handle = ^Tisc_req_handle;
  77.   Tisc_stmt_handle = Pointer;       pisc_stmt_handle = ^Tisc_stmt_handle;
  78.     Tisc_svc_handle = Pointer;        pisc_svc_handle = ^Tisc_svc_handle;
  79.   Tisc_tr_handle = Pointer;         pisc_tr_handle = ^Tisc_tr_handle;
  80.  
  81.   Tisc_callback = procedure( ptr: Pointer; length: Word; updated: PChar);
  82.  
  83. //*******************/
  84. //* Exception Class */
  85. //*******************/
  86.  
  87. EIBError = class(Exception);
  88.  
  89. {*****************}
  90. {* Status vector *}
  91. {*****************}
  92.  
  93.   ISC_STATUS = ISC_LONG;                PISC_STATUS = ^ISC_STATUS;
  94.   
  95.   ISC_STATUS_VECTOR = array[0..19] of ISC_STATUS;
  96.   
  97.   PSTATUS_VECTOR = ^ISC_STATUS_VECTOR;  PPSTATUS_VECTOR = ^PSTATUS_VECTOR;
  98.  
  99. {********************}
  100. {* Array structures *}
  101. {********************}
  102.  
  103.   ISC_ARRAY_BOUND = record
  104.     array_bound_lower: Word;
  105.     array_bound_upper: Word;
  106.   end;
  107.  
  108.   ISC_ARRAY_DESC = record
  109.     array_desc_dtype: Byte;
  110.       array_desc_scale: smallint;
  111.     array_desc_length: Byte;
  112.         array_desc_field_name: array [0..31] of Char;
  113.     array_desc_relation_name: array [0..31] of Char;
  114.     array_desc_dimensions: Word;
  115.     array_desc_flags: Word;
  116.     array_desc_bounds: array [0..15] of ISC_ARRAY_BOUND;
  117.   end;
  118.   PISC_ARRAY_DESC = ^ISC_ARRAY_DESC;
  119.  
  120. {*******************}
  121. {* BLOb structures *}
  122. {*******************}
  123.  
  124.     ISC_BLOB_DESC = record
  125.     SubType: Smallint;
  126.     Charset: Smallint;
  127.     SegmentSize: Smallint;
  128.     ColumnName: array [0..31] of Char;
  129.     TableName: array [0..31] of Char;
  130.   end;
  131.  
  132.   PISC_BLOB_DESC = ^ISC_BLOB_DESC;
  133.  
  134.   BSTREAM = record
  135.     bstr_blob: Pointer;         {* BLOb handle *}
  136.       bstr_buffer: PChar;         {* Address of buffer *}
  137.     bstr_ptr: PChar;            {* Next character *}
  138.         bstr_length: Smallint;      {* Length of buffer *}
  139.     bstr_cnt: Smallint;         {* Characters in buffer *}
  140.     bstr_mode: Char;            {* OUTPUT or INPUT *}
  141.   end;
  142.  
  143.   ISC_BLOB_CTL = record
  144.     ctl_source: PISC_STATUS;          {* Source filter *}
  145.     ctl_source_handle: Pointer;       {* Argument to pass to source *}
  146.     ctl_to_sub_type: Smallint;        {* Target type *}
  147.     ctl_from_sub_type: Smallint;      {* Source type *}
  148.       ctl_buffer_length: Byte;          {* Length of buffer *}
  149.     ctl_segment_length: Byte;         {* Length of current segment *}
  150.     ctl_bpb_length: Byte;             {* Length of BLOb Parameter Buffer *}
  151.     ctl_bpb: PChar;                   {* Address of BLOb Parameter Buffer *}
  152.     ctl_buffer: PByte;                {* Address of segment buffer *}
  153.     ctl_max_segment: ISC_LONG;        {* Length of longest segment *}
  154.     ctl_number_segments: ISC_LONG;    {* Total number of segments *}
  155.     ctl_total_length: ISC_LONG;       {* Total length of BLOb *}
  156.     ctl_status: PSTATUS_VECTOR;       {* Address of status vector *}
  157.     ctl_data: array [0..7] of Longint;{* Application specific data *}
  158.   end;
  159.   PISC_BLOB_CTL = ^ISC_BLOB_CTL;
  160.  
  161. {**************************}
  162. {* Dynamic SQL structures *}
  163. {**************************}
  164.  
  165.   SQLVAR = record
  166.     sqltype: Smallint;
  167.     sqllen: Smallint;
  168.     sqldata: Pointer;
  169.     sqlind: ^Smallint;
  170.     sqlname_len: Smallint;
  171.     sqlname: array [0..29] of Char;
  172.   end;
  173.     PSQLVAR = ^SQLVAR;
  174.  
  175.   SQLDA = record
  176.     sqldaid: array [0..7] of Char;
  177.     sqldabc: ISC_LONG;
  178.     sqln: Smallint;
  179.     sqld: Smallint;
  180.     sqlvar: array [0..0] of SQLVAR;
  181.   end;
  182.   PSQLDA = ^SQLDA;
  183.  
  184.  
  185.   XSQLVAR = record
  186.     sqltype: Smallint;                  {* datatype of field *}
  187.     sqlscale: Smallint;                 {* scale factor *}
  188.     sqlsubtype: Smallint;               {* datatype subtype - BLObs & Text types only *}
  189.     sqllen: Smallint;                   {* length of data area *}
  190.     sqldata: Pointer;                   {* address of data *}
  191.     sqlind: ^Smallint;                  {* address of indicator variable *}
  192.     sqlname_length: Smallint;           {* length of sqlname field *}
  193.     sqlname: array [0..31] of Char;     {* name of field, name length + space for NULL *}
  194.         relname_length: Smallint;           {* length of relation name *}
  195.     relname: array [0..31] of Char;     {* field's relation name + space for NULL *}
  196.     ownname_length: Smallint;           {* length of owner name *}
  197.     ownname: array [0..31] of Char;     {* relation's owner name + space for NULL *}
  198.     aliasname_length: Smallint;         {* length of alias name *}
  199.     aliasname: array [0..31] of Char;   {* relation's alias name + space for NULL *}
  200.   end;
  201.   PXSQLVAR = ^XSQLVAR;
  202.  
  203.     XSQLDA = record
  204.     version        : Smallint;                          {* version of this XSQLDA *}
  205.     sqldaid        : array [0..7] of Char;              {* XSQLDA name field *}
  206.     sqldabc        : isc_long;                          {* length in bytes of SQLDA *}
  207.     sqln            : Smallint;                     {* number of fields allocated *}
  208.     sqld            : Smallint;                     {* actual number of fields *}
  209.     sqlvar        : array [0..0] of XSQLVAR;        {* first field address *}
  210.   end;
  211.   PXSQLDA = ^XSQLDA;
  212.  
  213. {********************************
  214. * Transaction Existence Buffer *
  215. ********************************}
  216.  
  217.     ISC_TEB = record
  218.       db_ptr: pisc_db_handle;
  219.       tpb_len: Longint;
  220.       tpb_ptr: PChar;
  221.     end;
  222.     PISC_TEB = ^ISC_TEB;
  223.  
  224. {****************************}
  225. {* Date and Time structures *}
  226. {****************************}
  227.  
  228.   TM = record
  229.       sec     : Integer; { seconds (0-59) }
  230.     min     : Integer; { minutes (0-59) }
  231.     hour    : Integer; { hour (0-23) }
  232.     mday    : Integer; { day of month (1-31) }
  233.     mon     : Integer; { month of year (0-11) }
  234.     year    : Integer; { year (year - 1900 ) }
  235.     wday    : Integer; { day of week (0-6  Sunday=0)}
  236.         yday    : Integer; { day of year (0-364) }
  237.         isdst   : Integer; { daylight savings in effect (1 = True) }
  238.   end;
  239.     PTM = ^TM;
  240.   
  241.  
  242.  
  243.     DATETIME = record
  244.       IbDateTime: ISC_QUAD;
  245.       TimeDate: PTM;
  246.   end;
  247.  
  248. const
  249.   // C Consts
  250.   cYearOffset     = 1900;
  251.  
  252. {***************************}
  253. {* OSRI Database functions *}
  254. {***************************}
  255.     function isc_array_get_slice(
  256.         status_vector: PSTATUS_VECTOR;
  257.         db_handle: pisc_db_handle;
  258.         trans_handle: pisc_tr_handle;
  259.         array_id: PISC_QUAD;
  260.         desc: PISC_ARRAY_DESC;
  261.         dest_array: Pointer;
  262.         slice_length: PISC_LONG
  263.     ): ISC_STATUS; stdcall;
  264.  
  265.     function isc_array_lookup_bounds(
  266.         status_vector: PSTATUS_VECTOR;
  267.         db_handle: pisc_db_handle;
  268.         trans_handle: pisc_tr_handle;
  269.         table_name: PChar;
  270.         column_name: PChar;
  271.         desc: PISC_ARRAY_DESC
  272.     ): ISC_STATUS; stdcall;
  273.  
  274.     function isc_array_lookup_desc(
  275.         status_vector: PSTATUS_VECTOR;
  276.         db_handle: pisc_db_handle;
  277.         trans_handle: pisc_tr_handle;
  278.         table_name: PChar;
  279.         column_name: PChar;
  280.         desc: PISC_ARRAY_DESC
  281.     ): ISC_STATUS; stdcall;
  282.  
  283.     function isc_array_put_slice(
  284.         status_vector: PSTATUS_VECTOR;
  285.         db_handle: pisc_db_handle;
  286.         trans_handle: pisc_tr_handle;
  287.         array_id: PISC_QUAD;
  288.         desc: PISC_ARRAY_DESC;
  289.         source_array: Pointer;
  290.         slice_length: PISC_LONG
  291.     ): ISC_STATUS; stdcall;
  292.  
  293.     function isc_array_set_desc(
  294.         status_vector: PSTATUS_VECTOR;
  295.         table_name: PChar;
  296.         column_name: PChar;
  297.         sql_dtype: PSmallint;
  298.         sql_length: PSmallint;
  299.         dimensions: PSmallint;
  300.         desc: PISC_ARRAY_DESC
  301.     ): ISC_STATUS; stdcall;
  302.  
  303.     function isc_attach_database(
  304.         status_vector: PSTATUS_VECTOR;
  305.         db_name_length: Short;
  306.         db_name: PChar;
  307.         db_handle: pisc_db_handle;
  308.         parm_buffer_length: Short;
  309.         parm_buffer: PChar
  310.     ): ISC_STATUS; stdcall;
  311.  
  312.     procedure isc_blob_default_desc(
  313.         desc: ISC_BLOB_DESC;
  314.         table_name: PChar;
  315.         column_name: PChar
  316.     ); stdcall;
  317.  
  318.     function isc_blob_gen_bpb(
  319.         status_vector: PSTATUS_VECTOR;
  320.         to_desc: PISC_BLOB_DESC;
  321.         from_desc: PISC_BLOB_DESC;
  322.         bpb_buffer_length: Byte;
  323.         bpb_buffer: Pointer;
  324.         bpb_length: PByte
  325.     ): ISC_STATUS; stdcall;
  326.  
  327.     function isc_blob_info(
  328.         status_vector: PSTATUS_VECTOR;
  329.         blob_handle: pisc_blob_handle;
  330.         item_list_buffer_length: Smallint;
  331.         item_list_buffer: Pointer;
  332.         result_buffer_length: Smallint;
  333.         result_buffer: Pointer
  334.     ): ISC_STATUS; stdcall;
  335.  
  336.     function isc_blob_lookup_desc(
  337.         status_vector: PSTATUS_VECTOR;
  338.         db_handle: pisc_db_handle;
  339.         trans_handle: pisc_tr_handle;
  340.         tablename: PChar;
  341.         colname: PChar;
  342.         blobdesc: ISC_BLOB_DESC;
  343.         global: PChar
  344.     ): ISC_STATUS; stdcall;
  345.  
  346.     function isc_blob_set_desc(
  347.         status_vector: PSTATUS_VECTOR;
  348.         table_name: PChar;
  349.         column_name: PChar;
  350.         subtype: Smallint;
  351.         charset: Smallint;
  352.         segment_size: Smallint;
  353.         desc: PISC_BLOB_DESC
  354.     ): ISC_STATUS; stdcall;
  355.  
  356.     function isc_cancel_blob(
  357.         status_vector: PSTATUS_VECTOR;
  358.         blob_handle: pisc_blob_handle
  359.     ): ISC_STATUS; stdcall;
  360.  
  361.     function isc_cancel_events(
  362.         status_vector: PSTATUS_VECTOR;
  363.         db_handle: pisc_db_handle;
  364.         event_id: pisc_long
  365.     ): ISC_STATUS; stdcall;
  366.  
  367.     function isc_close_blob(
  368.         status_vector: PSTATUS_VECTOR;
  369.         blob_handle: pisc_blob_handle
  370.     ): ISC_STATUS; stdcall;
  371.  
  372.     function isc_commit_retaining(
  373.         status_vector: PSTATUS_VECTOR;
  374.         trans_handle: pisc_tr_handle
  375.     ): ISC_STATUS; stdcall;
  376.  
  377.     function isc_commit_transaction(
  378.         status_vector: PSTATUS_VECTOR;
  379.         trans_handle: pisc_tr_handle
  380.     ): ISC_STATUS; stdcall;
  381.  
  382.     function isc_create_blob(
  383.         status_vector: PSTATUS_VECTOR;
  384.         db_handle: pisc_db_handle;
  385.         trans_handle: pisc_tr_handle;
  386.         blob_handle: pisc_blob_handle;
  387.         pblob_id : PISC_QUAD
  388.     ): ISC_STATUS; stdcall;
  389.  
  390.     function isc_create_blob2(
  391.         status_vector: PSTATUS_VECTOR;
  392.         db_handle: pisc_db_handle;
  393.         trans_handle: pisc_tr_handle;
  394.         blob_handle: pisc_blob_handle;
  395.         pblob_id: PISC_QUAD;
  396.         bpb_length: Smallint;
  397.         bpb_address: PChar
  398.     ): ISC_STATUS; stdcall;
  399.  
  400.     function isc_database_info(
  401.         status_vector: PSTATUS_VECTOR;
  402.         db_handle: pisc_db_handle;
  403.         item_list_buffer_length: Smallint;
  404.         item_list_buffer: Pointer;
  405.         result_buffer_length: Smallint;
  406.         result_buffer: Pointer
  407.     ): ISC_STATUS; stdcall;
  408.  
  409.     procedure isc_decode_date(
  410.         ib_date: PISC_QUAD;
  411.         tm_date: PTM
  412.     ); stdcall;
  413.  
  414.     function isc_detach_database(
  415.         status_vector: PSTATUS_VECTOR;
  416.         db_handle: pisc_db_handle
  417.     ): ISC_STATUS; stdcall;
  418.  
  419.     function isc_drop_database(
  420.         status_vector: PSTATUS_VECTOR;
  421.         db_handle: pisc_db_handle
  422.     ): ISC_STATUS; stdcall;
  423.  
  424.     function isc_dsql_allocate_statement(
  425.         status_vector: PSTATUS_VECTOR;
  426.         db_handle: pisc_db_handle;
  427.         stmt_handle: pisc_stmt_handle
  428.     ): ISC_STATUS; stdcall;
  429.  
  430.     function isc_dsql_allocate_statement2(
  431.         status_vector: PSTATUS_VECTOR;
  432.         db_handle: pisc_db_handle;
  433.         stmt_handle: pisc_stmt_handle
  434.     ): ISC_STATUS; stdcall;
  435.  
  436.     function isc_dsql_describe(
  437.         status_vector: PSTATUS_VECTOR;
  438.         stmt_handle: pisc_stmt_handle;
  439.         dialect: Word;
  440.         xsqlda: PXSQLDA
  441.     ): ISC_STATUS; stdcall;
  442.  
  443.     function isc_dsql_describe_bind(
  444.         status_vector: PSTATUS_VECTOR;
  445.         stmt_handle: pisc_stmt_handle;
  446.         dialect: Word;
  447.         xsqlda: PXSQLDA
  448.     ): ISC_STATUS; stdcall;
  449.  
  450.     function isc_dsql_execute(
  451.         status_vector: PSTATUS_VECTOR;
  452.         trans_handle: pisc_tr_handle;
  453.         stmt_handle: pisc_stmt_handle;
  454.         dialect: Word;
  455.         xsqlda: PXSQLDA
  456.     ): ISC_STATUS; stdcall;
  457.  
  458.     function isc_dsql_execute2(
  459.         status_vector: PSTATUS_VECTOR;
  460.         trans_handle: pisc_tr_handle;
  461.         stmt_handle: pisc_stmt_handle;
  462.         dialect: Word;
  463.         in_xsqlda: PXSQLDA;
  464.         out_xsqlda: PXSQLDA
  465.     ): ISC_STATUS; stdcall;
  466.  
  467.     function isc_dsql_execute_immediate(
  468.         status_vector: PSTATUS_VECTOR;
  469.         db_handle: pisc_db_handle;
  470.         trans_handle: pisc_tr_handle;
  471.         length: Word;
  472.         statement: PChar;
  473.         dialect: Word;
  474.         xsqlda: PXSQLDA
  475.     ): ISC_STATUS; stdcall;
  476.  
  477.     function isc_dsql_exec_immed2(
  478.         status_vector: PSTATUS_VECTOR;
  479.         db_handle: pisc_db_handle;
  480.         trans_handle: pisc_tr_handle;
  481.         length: Word;
  482.         statement: PChar;
  483.         dialect: Word;
  484.         in_xsqlda: PXSQLDA;
  485.         out_xsqlda: PXSQLDA
  486.     ): ISC_STATUS; stdcall;
  487.  
  488.     function isc_dsql_fetch(
  489.         status_vector: PSTATUS_VECTOR;
  490.         stmt_handle: pisc_stmt_handle;
  491.         dialect: Word;
  492.         xsqlda: PXSQLDA
  493.     ): ISC_STATUS; stdcall;
  494.  
  495.     function isc_finish(
  496.         db_handle: pisc_db_handle
  497.     ): ISC_STATUS; stdcall;
  498.  
  499.     function isc_dsql_free_statement(
  500.         status_vector: PSTATUS_VECTOR;
  501.         stmt_handle: pisc_stmt_handle;
  502.         option: Word
  503.     ): ISC_STATUS; stdcall;
  504.  
  505.     function isc_dsql_prepare(
  506.         status_vector: PSTATUS_VECTOR;
  507.         trans_handle: pisc_tr_handle;
  508.         stmt_handle: pisc_stmt_handle;
  509.         length: Word;
  510.         statement: PChar;
  511.         dialect: Word;
  512.         xsqlda: PXSQLDA
  513.     ): ISC_STATUS; stdcall;
  514.  
  515.     function isc_dsql_set_cursor_name(
  516.         status_vector: PSTATUS_VECTOR;
  517.         stmt_handle: pisc_stmt_handle;
  518.         cursor_name: PChar;
  519.         cursor_type: Word
  520.     ): ISC_STATUS; stdcall;
  521.  
  522.     function isc_dsql_sql_info(
  523.         status_vector: PSTATUS_VECTOR;
  524.         stmt_handle: pisc_stmt_handle;
  525.         item_length: Word;
  526.         items: PChar;
  527.         buffer_length: Word;
  528.         buffer: PChar
  529.     ): ISC_STATUS; stdcall;
  530.  
  531.     procedure isc_encode_date(
  532.         tm_date: PTM;
  533.         ib_date: PISC_QUAD
  534.     ); stdcall;
  535.  
  536.     function isc_event_block(
  537.         event_buffer: Pointer;
  538.         result_buffer: Pointer;
  539.         count: Short;
  540.         name1: PChar
  541.     ): Longint; cdecl;
  542.  
  543.     function isc_event_block_asm: longint; stdcall;
  544.  
  545.     procedure isc_event_counts(
  546.         status_vector: PSTATUS_VECTOR;
  547.         buffer_length: Word;
  548.         event_buffer: PChar;
  549.         result_buffer: PChar
  550.     ); stdcall;
  551.  
  552.     function isc_free(
  553.         buffer: PChar
  554.     ): isc_long; stdcall;
  555.  
  556.     function isc_get_segment(
  557.         status_vector: PSTATUS_VECTOR;
  558.         blob_handle: pisc_blob_handle;
  559.         actual_seg_length : PWord;
  560.         seg_buffer_length : Word;
  561.         seg_buffer : Pointer
  562.     ): ISC_STATUS; stdcall;
  563.  
  564.     function isc_interprete(
  565.         buffer: PChar;
  566.         status_vector_ptr: PPSTATUS_VECTOR
  567.     ): ISC_STATUS; stdcall;
  568.  
  569.     function isc_open_blob2(
  570.         status_vector: PSTATUS_VECTOR;
  571.         db_handle: pisc_db_handle;
  572.         trans_handle: pisc_tr_handle;
  573.         blob_handle: pisc_blob_handle;
  574.         blob_id : PISC_QUAD;
  575.         bpb_length : Word;
  576.         bpb_address : Pointer
  577.     ): ISC_STATUS; stdcall;
  578.  
  579.     function isc_prepare_transaction(
  580.         status_vector: PSTATUS_VECTOR;
  581.         trans_handle: pisc_tr_handle
  582.     ): ISC_STATUS; stdcall;
  583.  
  584.     function isc_prepare_transaction2(
  585.         status_vector: PSTATUS_VECTOR;
  586.         trans_handle: pisc_tr_handle;
  587.         msg_length: Word;
  588.         msg: PChar
  589.     ): ISC_STATUS; stdcall;
  590.  
  591.     procedure isc_print_status(
  592.         status_vector_ptr: PSTATUS_VECTOR
  593.     );
  594.  
  595.     procedure isc_print_sqlerror(
  596.         SQLCODE: ISC_LONG;
  597.         status_vector_ptr: PSTATUS_VECTOR
  598.     );
  599.  
  600.     function isc_put_segment(
  601.         status_vector: PSTATUS_VECTOR;
  602.         blob_handle: pisc_blob_handle;
  603.         seg_buffer_length : Word;
  604.         seg_buffer_address : Pointer
  605.     ): ISC_STATUS; stdcall;
  606.  
  607.     function isc_que_events(
  608.         status_vector: PSTATUS_VECTOR;
  609.         db_handle: pisc_db_handle;
  610.         event_id: PISC_LONG;
  611.         length: Word;
  612.         event_buffer: PChar;
  613.         event_function: Tisc_callback;
  614.         event_function_arg: Pointer
  615.     ): ISC_STATUS; stdcall;
  616.  
  617.     function isc_rollback_transaction(
  618.         status_vector: PSTATUS_VECTOR;
  619.         trans_handle: pisc_tr_handle
  620.     ): ISC_STATUS; stdcall;
  621.  
  622.     function isc_sqlcode(
  623.         status_vector: PSTATUS_VECTOR
  624.     ): ISC_LONG; stdcall;
  625.  
  626.     procedure isc_sql_interprete(
  627.         sqlcode: ISC_LONG;
  628.         buffer: PChar;
  629.         buffer_length: Short
  630.     ); stdcall;
  631.  
  632.     function isc_start_multiple(
  633.         status_vector: PSTATUS_VECTOR;
  634.         trans_handle: pisc_tr_handle;
  635.         db_handle_count: Short;
  636.         teb_vector_address: PISC_TEB
  637.     ): ISC_STATUS; stdcall;
  638.  
  639.     function isc_start_transaction(
  640.         status_vector: PSTATUS_VECTOR;
  641.         trans_handle: pisc_tr_handle;
  642.         db_handle_count: Short;
  643.         db_handle: pisc_db_handle;
  644.         tpb_length: Word;
  645.         tpb_addr: PChar
  646.     ): ISC_STATUS; stdcall;
  647.  
  648.     function isc_transaction_info(
  649.         status_vector: PSTATUS_VECTOR;
  650.         trans_handle: pisc_tr_handle;
  651.         item_list_buffer_length: Smallint;
  652.         item_list_buffer: Pointer;
  653.         result_buffer_length: Smallint;
  654.         result_buffer: Pointer
  655.     ): ISC_STATUS; stdcall;
  656.  
  657.     function isc_version(
  658.         db_handle: pisc_db_handle;
  659.         function_name: Tisc_callback;
  660.         user_arg: Pointer
  661.     ): Integer; stdcall;
  662.  
  663.     function isc_wait_for_event(
  664.         status_vector: PSTATUS_VECTOR;
  665.         db_handle: pisc_db_handle;
  666.         length: Short;
  667.         event_buffer: PChar;
  668.         result_buffer: PChar
  669.     ): ISC_STATUS; stdcall;
  670.  
  671.  
  672.     function SQLDA_LENGTH(n: Word): Longint;
  673.  
  674.     function XSQLDA_LENGTH(n: Word): Longint;
  675.  
  676. implementation
  677.  
  678. function SQLDA_LENGTH(n: Word): Longint;
  679. begin
  680.     SQLDA_LENGTH := (SizeOf(SQLDA) + (n - 1) * SizeOf(SQLVAR));
  681. end;
  682.  
  683. function XSQLDA_LENGTH(n: Word): Longint;
  684. begin
  685.     XSQLDA_LENGTH := (SizeOf(XSQLDA) + (n - 1) * SizeOf(XSQLVAR));
  686. end;
  687.  
  688. procedure isc_print_status(status_vector_ptr: PSTATUS_VECTOR);
  689. var
  690.   msgBuffer: array[0..511] of Char;
  691.   errMsg: String;
  692.   lastMsg: String;
  693.   errCode: ISC_STATUS;
  694. begin
  695.   errMsg := 'InterBase error:' + #13#10;
  696.   repeat
  697.      errCode := isc_interprete(@msgBuffer, @status_vector_ptr);
  698.      if lastMsg <> StrPas(msgBuffer) then
  699.      begin
  700.         lastMsg := StrPas(msgBuffer);
  701.         if Length(errMsg) <> 0 then
  702.            errMsg := errMsg + #13#10;
  703.         errMsg := errMsg + lastMsg;
  704.      end;
  705.   until errCode = 0;
  706.   raise EIBError.Create(errMsg);
  707. end;
  708.  
  709. procedure isc_print_sqlerror(SQLCODE: ISC_LONG; status_vector_ptr: PSTATUS_VECTOR);
  710. var
  711.   msgBuffer: array[0..511] of Char;
  712.   errMsg: String;
  713.   lastMsg: String;
  714. begin
  715.   errMsg := 'InterBase SQL error (' + IntToStr(SQLCODE) + '):' + #13#10;
  716.   isc_sql_interprete(SQLCODE, @msgBuffer, SizeOf(msgBuffer));
  717.   if lastMsg <> StrPas(msgBuffer) then
  718.   begin
  719.     lastMsg := StrPas(msgBuffer);
  720.     if Length(errMsg) <> 0 then
  721.       errMsg := errMsg + #13#10;
  722.     errMsg := errMsg + lastMsg;
  723.   end;
  724.   raise EIBError.Create(errMsg);
  725. end;
  726.  
  727. function isc_array_get_slice; external IBASE_DLL name 'isc_array_get_slice';
  728.  
  729. function isc_array_lookup_bounds;  external IBASE_DLL name 'isc_array_lookup_bounds';
  730.  
  731. function isc_array_lookup_desc; external IBASE_DLL name 'isc_array_lookup_desc';
  732.  
  733. function isc_array_put_slice; external IBASE_DLL name 'isc_array_put_slice';
  734.  
  735. function isc_array_set_desc; external IBASE_DLL name 'isc_array_set_desc';
  736.  
  737. function isc_attach_database; external IBASE_DLL name 'isc_attach_database';
  738.  
  739. procedure isc_blob_default_desc; external IBASE_DLL name 'isc_blob_default_desc';
  740.  
  741. function isc_blob_gen_bpb; external IBASE_DLL name 'isc_blob_gen_bpb';
  742.  
  743. function isc_blob_info;  external IBASE_DLL name 'isc_blob_info';
  744.  
  745. function isc_blob_lookup_desc; external IBASE_DLL name 'isc_blob_lookup_desc';
  746.  
  747. function isc_blob_set_desc; external IBASE_DLL name 'isc_blob_set_desc';
  748.  
  749. function isc_cancel_events; external IBASE_DLL name 'isc_cancel_events';
  750.  
  751. function isc_close_blob; external IBASE_DLL name 'isc_close_blob';
  752.  
  753. function isc_cancel_blob; external IBASE_DLL name 'isc_cancel_blob';
  754.  
  755. function isc_commit_retaining; external IBASE_DLL name 'isc_commit_retaining';
  756.  
  757. function isc_commit_transaction; external IBASE_DLL name 'isc_commit_transaction';
  758.  
  759. function isc_create_blob; external IBASE_DLL name 'isc_create_blob';
  760.  
  761. function isc_create_blob2; external IBASE_DLL name 'isc_create_blob2';
  762.  
  763. function isc_database_info; external IBASE_DLL name 'isc_database_info';
  764.  
  765. function isc_detach_database; external IBASE_DLL name 'isc_detach_database';
  766.  
  767. procedure isc_decode_date; external IBASE_DLL name 'isc_decode_date';
  768.  
  769. function isc_dsql_execute_immediate; external IBASE_DLL name 'isc_dsql_execute_immediate';
  770.  
  771. function isc_drop_database; external IBASE_DLL name 'isc_drop_database';
  772.  
  773. function isc_sqlcode; external IBASE_DLL name 'isc_sqlcode';
  774.  
  775. function isc_dsql_allocate_statement; external IBASE_DLL name 'isc_dsql_allocate_statement';
  776.  
  777. function isc_dsql_allocate_statement2; external IBASE_DLL name 'isc_dsql_allocate_statement2';
  778.  
  779. function isc_dsql_describe; external IBASE_DLL name 'isc_dsql_describe';
  780.  
  781. function isc_dsql_describe_bind; external IBASE_DLL name 'isc_dsql_describe_bind';
  782.  
  783. function isc_dsql_exec_immed2; external IBASE_DLL name 'isc_dsql_exec_immed2';
  784.  
  785. function isc_dsql_execute; external IBASE_DLL name 'isc_dsql_execute';
  786.  
  787. function isc_dsql_execute2; external IBASE_DLL name 'isc_dsql_execute2';
  788.  
  789. function isc_dsql_fetch; external IBASE_DLL name 'isc_dsql_fetch';
  790.  
  791. function isc_dsql_free_statement; external IBASE_DLL name 'isc_dsql_free_statement';
  792.  
  793. function isc_dsql_prepare; external IBASE_DLL name 'isc_dsql_prepare';
  794.  
  795. function isc_dsql_set_cursor_name; external IBASE_DLL name 'isc_dsql_set_cursor_name';
  796.  
  797. function isc_dsql_sql_info; external IBASE_DLL name 'isc_dsql_sql_info';
  798.  
  799. procedure isc_encode_date; external IBASE_DLL name 'isc_encode_date';
  800.  
  801. function isc_event_block; external IBASE_DLL name 'isc_event_block';
  802.  
  803. function isc_event_block_asm; external IBASE_DLL name 'isc_event_block_asm';
  804.  
  805. procedure isc_event_counts; external IBASE_DLL name 'isc_event_counts';
  806.  
  807. function isc_finish; external IBASE_DLL name 'isc_finish';
  808.  
  809. function isc_free; external IBASE_DLL name 'isc_free';
  810.  
  811. function isc_get_segment; external IBASE_DLL name 'isc_get_segment';
  812.  
  813. function isc_interprete; external IBASE_DLL name 'isc_interprete';
  814.  
  815. function isc_que_events; external IBASE_DLL name 'isc_event_block_asm';
  816.  
  817. function isc_open_blob2; external IBASE_DLL name 'isc_open_blob2';
  818.  
  819. function isc_prepare_transaction; external IBASE_DLL name 'isc_prepare_transaction';
  820.  
  821. function isc_prepare_transaction2; external IBASE_DLL name 'isc_prepare_transaction2';
  822.  
  823. function isc_put_segment; external IBASE_DLL name 'isc_put_segment';
  824.  
  825. function isc_rollback_transaction; external IBASE_DLL name 'isc_rollback_transaction';
  826.  
  827. procedure isc_sql_interprete; external IBASE_DLL name 'isc_sql_interprete';
  828.  
  829. function isc_start_multiple; external IBASE_DLL name 'isc_start_multiple';
  830.  
  831. function isc_start_transaction; external IBASE_DLL name 'isc_start_transaction';
  832.  
  833. function isc_transaction_info; external IBASE_DLL name 'isc_transaction_info';
  834.  
  835. function isc_version; external IBASE_DLL name 'isc_version';
  836.  
  837. function isc_wait_for_event; external IBASE_DLL name 'isc_wait_for_event';
  838.  
  839.  
  840. end.
  841.  
  842.  
  843.  
  844.  
  845.