⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fastdbcli.pas

📁 俄国人写的内存数据库的delphi封装
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    0, // cli_pasciiz,
    0, // cli_cstring,
    0, // cli_array_of_oid,
    0, // cli_array_of_bool,
    0, // cli_array_of_int1,
    0, // cli_array_of_int2,
    0, // cli_array_of_int4,
    0, // cli_array_of_int8,
    0, // cli_array_of_real4,
    0, // cli_array_of_real8,
    0, // cli_array_of_decimal,
    0, // cli_array_of_string,
    0, // cli_any,
    sizeof(cli_real8_t), // cli_datetime,
    4, // cli_autoincrement,
    0, // cli_rectangle,
    0, // cli_unknown
    0  // ctSubst
  );

const
  cli_view_only  = 0;
  cli_for_update = 1;


type
  TCliQueryType = (qtViewOnly, qtForUpdate);

{********************************************************************
  cli_open
  Establish connection with the server
  Parameters:
  server_url - zero terminated string with server address and port,
               for example "localhost:5101", "195.239.208.240:6100",...
  max_connect_attempts - number of attempts to establish connection
  reconnect_timeout_sec - timeput in seconds between connection attempts

  Gigabase users:
  ===============
  user_name - user name for login
  password  - password for login  pooled_connection - if not 0, then connection will be allocated from the connection pool
  Returns:
    >= 0 - connectiondescriptor to be used in all other cli calls
    < 0 - error code as described in cli_result_code enum
}
function cli_open(const ServerURL: string;
                  const MaxConnectAttempts: Integer;
                  const ReconnectTimeoutSec: Integer
                  {$IFDEF GIGABASE}
				  ; UserName, Password: string;
                  PooledConnection: Boolean                  {$ENDIF}
                 ): Integer;
type
  TCliOpenAttribute  = (oaReadWrite, oaReadOnly, oaTruncate, oaOpenConcurrent);
  TCliOpenAttributes = set of TCliOpenAttribute;

var
  cli_open_attributes: array[TCliOpenAttribute] of Integer=(
    $0, //cli_open_default
    $1, //cli_open_readonly
    $2, //cli_open_truncate
    $4  //cli_open_concurrent
  );

{********************************************************************
  cli_create
  Create conecntion to the local database
  Parameters:
  databaseName - name of the database
  fileName - path to the database file
  transactionCommitDelay - trasnaction commit delay (specify 0 to disable)
  openAttr - mask of cli_open_attributes
  initDatabaseSize - initial size of the database
  extensionQuantum - database extension quantum
  initIndexSize - initial size of object index
  fileSizeLimit - limit for file size (0 - unlimited)

  Gigabase:
  ========
  poolSize - size of page pool (in pages), specify 0 to let GigaBASE automaticaly detect pool size

  Returns:
    >= 0 - connection descriptor to be used in all other cli calls
    < 0 - error code as described in cli_result_code enum
--------------------------------------------------------------------}
{$IFDEF GIGABASE}
function cli_create(const DatabasePath: string;
                    const TransactionCommitDelay: Word=0;
                    const OpenAttr: TCliOpenAttributes = [oaReadWrite];
                    const PoolSize: Integer=0
                    ): Integer;
{$ELSE}
function cli_create(const DatabaseName: string;
                    const FilePath: string;
                    const InitDatabaseSize: Integer=FastDbDefaultInitDatabaseSize;
                    const TransactionCommitDelay: Word=0;
                    const OpenAttr: TCliOpenAttributes = [oaReadWrite];
                    const InitIndexSize: Integer=FastDbDefaultInitIndexSize;
                    const ExtensionQuantum: Integer=FastDbDefaultExtensionQuantum;
                    const FileSizeLimit: Integer=0
                    ): Integer;
{$ENDIF}

{$IFDEF GIGABASE}
{*********************************************************************
  cli_clear_connection_pool      Close all released connections in the connection pool--------------------------------------------------------------------}var
  cli_clear_connection_pool: function: Integer cdecl;
{$ENDIF}


{********************************************************************
  cli_create_replication_node
  Create conecntion to the local database
  Parameters:
  databaseName - name of the database
  fileName - path to the database file
  transactionCommitDelay - trasnaction commit delay (specify 0 to disable)
  openAttr - mask of cli_open_attributes
  initDatabaseSize - initial size of the database
  extensionQuantum - database extension quantum
  initIndexSize - initial size of object index
  fileSizeLimit - limit for file size (0 - unlimited)
  Returns:
    >= 0 - connection descriptor to be used in all other cli calls
    < 0 - error code as described in cli_result_code enum
--------------------------------------------------------------------}
function cli_create_replication_node(const NodeID: Integer;
                                     const ServerCount: Integer;
                                     const NodeNames: TStrArray;
                                     const DatabaseName: string;
                                     const FilePath: string;
                                     const InitDatabaseSize: Integer=FastDbDefaultInitDatabaseSize;
                                     //const TransactionCommitDelay: Word=0;
                                     const OpenAttr: TCliOpenAttributes = [oaReadWrite];
                                     const InitIndexSize: Integer=FastDbDefaultInitIndexSize;
                                     const ExtensionQuantum: Integer=FastDbDefaultExtensionQuantum;
                                     const FileSizeLimit: Integer=0
                                    ): Integer;

{********************************************************************
  cli_close
  Close session
  Parameters:
  session - session descriptor returned by cli_open
  Returns:
  result code as described in cli_result_code enum
--------------------------------------------------------------------}
var
  cli_close: function(session: Integer): Integer cdecl;

{********************************************************************
  cli_statement
  Specify SunSQL statement to be executed at server
  Binding to the parameters and columns can be established
  Parameters:
  session - session descriptor returned by cli_open
  stmt - zero terminated string with SubSQL statement
  Returns:
  >= 0 - statement descriptor
  < 0 - error code as described in cli_result_code enum
--------------------------------------------------------------------}
  cli_statement: function(session: Integer;
                          const stmt: PChar): Integer cdecl;

{********************************************************************
  cli_parameter
  Bind parameter to the statement
  Parameters:
  statement - statememt descriptor returned by cli_statement
  param_name - zero terminated string with parameter name
  Paramter name should start with '%'
  var_type - type of variable as described in TCliVarType enum.
  Only scalar and zero terminated string types are supported.
  var_ptr - pointer to the variable
  Returns:
  result code as described in cli_result_code enum
--------------------------------------------------------------------}
  cli_parameter: function(statement: Integer;
                          const param_name: PChar;
                          var_type: Integer;
                          var_ptr: Pointer): Integer cdecl;

{********************************************************************
  cli_column
  Bind extracted column of select or insert statement
  Parameters:
  statement - statememt descriptor returned by cli_statement
  column_name - zero terminated string with column name
  var_type - type of variable as described in TCliVarType enum
  var_len - pointer to the variable to hold length of array variable.
  This variable should be assigned the maximal length
  of the array/string buffer, pointed by var_ptr.
  After the execution of the statement it is assigned the
  real length of the fetched array/string. If it is large
  than length of the buffer, then only part of the array
  will be placed in the buffer, but var_len still will
  contain the actual array length.
  var_ptr - pointer to the variable
  Returns:
  result code as described in cli_result_code enum
--------------------------------------------------------------------}
  cli_column: function(statement: Integer;
                       const column_name: PChar;
                       var_type: Integer;
                       var_len: PInteger;
                       var_ptr: Pointer): Integer cdecl;


type
  //TCliColumnSet   = function(var_type: Integer; var_ptr: Pointer; len: Integer): Pointer; cdecl;
  //TCliColumnGet   = function(var_type: Integer; var_ptr: Pointer; var len: Integer): Pointer; cdecl;
  TCliColumnSetEx = function(const ColumnType: Integer;
                             varPtr: Pointer;
                             Len: Integer;
                             const ColumnName: PChar;
                             const Statement: Integer;
                             const SourcePtr: Pointer;
                             const UserData: Pointer): Pointer; cdecl;
  TCliColumnGetEx = function(const ColumnType: Integer;
                             varPtr: Pointer;
                             var Len: Integer;
                             const ColumnName: PChar;
                             const Statement: Integer;
                             const UserData: Pointer): Pointer; cdecl;

{********************************************************************
  cli_array_column
    Specify get/set functions for the array column
  Parameters:
    statement - statememt descriptor returned by cli_statement
    column_name - zero terminated string with column name
    var_type - type of variable as described in TCliVarType enum
    var_ptr - pointer to the variable
    set - function which will be called to construct fetched
          field. It receives pointer to the variable,
          length of the fetched array and returns pointer to th
          array's elements
    get - function which will be called to update the field in the
          database. Given pointer to the variable, it should return
          pointer to the array elements and store length of the
          array to the variable pointer by len parameter
    user_data   - pointer to user specific data passed to get and set functions
  Returns:
    result code as described in cli_result_code enum
--------------------------------------------------------------------}
{var
  cli_array_column: function(statement: Integer;
                             const column_name: PChar;
                             var_type: Integer;
                             var_ptr: Pointer;
                             setCol: TCliColumnSet;
                             getCol: TCliColumnGet): Integer cdecl;
}
var
  cli_array_column_ex: function(statement: Integer;
                                const column_name: PChar;
                                varType: Integer;
                                varPtr: Pointer;
                                setCol: TCliColumnSetEx;
                                getCol: TCliColumnGetEx;
                                user_data: Pointer): Integer cdecl;


{********************************************************************
  cli_fetch
    Execute select statement.
  Parameters:
    statement - statememt descriptor returned by cli_statement
    for_update - not zero if fetched rows will be updated
          cli_view_only  = 0
          cli_for_update = 1

  Returns:
    >= 0 - success, for select statements number of fetched rows is returned
    < 0 - error code as described in cli_result_code enum
--------------------------------------------------------------------}
  cli_fetch: function(statement: Integer;
                      for_update: Integer): Integer cdecl;

{********************************************************************
  cli_insert
    Execute insert statement.
  Parameters:
    statement - statememt descriptor returned by cli_statement
    oid - object identifier of created record.
  Returns:
    status code as described in cli_result_code enum
--------------------------------------------------------------------}
  cli_insert: function(statement: Integer;
                       oid: PCliOid): Integer cdecl;

{********************************************************************
  cli_get_first
    Get first row of the selection.
  Parameters:
    statement - statememt descriptor returned by cli_statement
  Returns:
    result code as described in cli_result_code enum
--------------------------------------------------------------------}
  cli_get_first: function(statement: Integer): Integer cdecl;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -