13.4. RDBMS specific

Peculiarities of using particular RDBMS with CLIP are described below.

13.4.1. MySQL

13.4.1.1. Building an application

To be able to build an application using MySQL data base, appropriate packages must be installed. It includes MySQL development files and clip-mysql package. See Installation chapter for details.

Link your application with MySQL driver by adding -lclip-mysql to the end of clip command:

$clip -e test.prg -lclip-mysql

13.4.1.2. ConnectNew() syntax

To obtain a connect to the MySQL server use ConnectNew() with the following syntax:

ConnectNew("MS",[<cHost>],[<cPort>],[<cLogin>],[<cPassword>],[<cDB>],;
	[<cSocket>],[<cFlags>],[<cCharset>],[<cIsolation>])

where

  • "MS" - identifier of MySQL driver; see also SQLList()

  • cHost - a string containing the name of the host MySQL server is running on

  • cPort - server port number as string

  • cLogin - a string containing user login

  • cPassword - a string containing user's password

  • cDB - a string containing the name of the database to be used

  • cSocket - a string containing UNIX socket or pipe name to be used as transport

  • cFlags - flags to be used with this connection as string; see MySQL manual for details

  • cCharset - charset used by server; if not passed, SET("SQL_CHARSET") is used

  • cIsolation - a string containing the name of isolation level to be used by default (see MySQL manual for details); if not passed, SET("MS_ISOLATION_LEVEL") value is used; possible values:

    • READ UNCOMMITTED

    • READ COMMITTED

    • REPEATABLE READ

    • SERIALIZABLE

    the same values are possible for <cIsolation> parameter of TRowset:Start().

13.4.2. PostgreSQL

13.4.2.1. Building an application

To be able to build an application using PostgreSQL data base, appropriate packages must be installed. It includes PostgreSQL development files and clip-postgres package. See Installation chapter for details.

Link your application with PostgreSQL driver by adding -lclip-postgres to the end of clip command:

$clip -e test.prg -lclip-postgres

13.4.2.2. ConnectNew() syntax

To obtain a connect to the PostgreSQL server use ConnectNew() with the following syntax:

ConnectNew("PG",[<cHost>],[<cPort>],[<cLogin>],[<cPassword>],[<cDB>],;
	[<cTTY>],[<cOptions>],[<cCharset>],[<cIsolation>])

where

  • "PG" - identifier of PostgreSQL driver; see also SQLList()

  • cHost - a string containing the name of the host PostgreSQL server is running on

  • cPort - server port number as string

  • cLogin - a string containing user login

  • cPassword - a string containing user's password

  • cDB - a string containing the name of the database to be used

  • cTTY - the name of debug tty

  • cOptions - optional parameters of the connection; see PostgreSQL manual for details

  • cCharset - charset used by server; if not passed, SET("SQL_CHARSET") is used

  • cIsolation - a string containing the name of isolation level to be used by default (see PostgreSQL manual for details); if not passed, SET("PG_ISOLATION_LEVEL") value is used; possible values:

    • READ COMMITTED

    • SERIALIZABLE

    the same values are possible for <cIsolation> parameter of TRowset:Start().

13.4.3. Oracle 8i

13.4.3.1. Building an application

To be able to build an application using Oracle data base, appropriate packages must be installed. It includes Oracle development files and clip-oracle package. See Installation chapter for details.

Link your application with Oracle driver by adding -lclip-oracle to the end of clip command:

$clip -e test.prg -lclip-oracle

13.4.3.2. ConnectNew() syntax

To obtain a connect to the Oracle server use ConnectNew() with the following syntax:

ConnectNew("OR",NIL,NIL,<cLogin>,<cPassword>,[<cDB>],NIL,NIL,[<cCharset>],[<cIsolation>])

where

  • "OR" - identifier of Oracle driver; see also SQLList()

  • cLogin - a string containing user login

  • cPassword - a string containing user's password

  • cDB - a string containing the name of the database to be used (connect string)

  • cCharset - charset used by server; if not passed, SET("SQL_CHARSET") is used

  • cIsolation - a string containing the name of isolation level to be used by default (see Oracle manual for details); if not passed, SET("OR_ISOLATION_LEVEL") value is used; values containing one or more of the following strings divided by ';' are possible:

    • READ COMMITTED

    • SERIALIZABLE

    • READ ONLY

    • READ WRITE

    the same values are possible for <cIsolation> parameter of TRowset:Start().

13.4.3.4. Other peculiarities

An array with SQL parameters (used in <aParameters> parameter of TConnect:Command() and TConnect:CreateRowset() functions) must have third element (SQL data type) in each row with Oracle. Data types are defined in oracle.ch include file. For example:

#include "oracle.ch"
// ...
conn:Command("INSERT INTO mytable (fname,lname) VALUES (:fname,:lname)",;
	{{"fname","John",ORT_VARCHAR2},{"lname","Smith",ORT_VARCHAR2}})

INSERT statement passed in <cInsertSQL> parameter to TRowset constructor TConnect:CreateRowset() must have RETURNING rowid clause. For example:

INSERT INTO mytable (fname,lname) VALUES (:fname,:lname) RETURNING rowid INTO :rowid

13.4.4. Interbase/Firebird

13.4.4.1. Building an application

To be able to build an application using Interbase data base, appropriate packages must be installed. It includes Interbase development files and clip-interbase package. See Installation chapter for details.

Link your application with Interbase driver by adding -lclip-interbase to the end of clip command:

$clip -e test.prg -lclip-interbase

13.4.4.2. ConnectNew() syntax

To obtain a connect to the Interbase server use ConnectNew() with the following syntax:

ConnectNew("IB",NIL,NIL,<cLogin>,<cPassword>,<cDB>,NIL,NIL,[<cCharset>],[<cIsolation>])

where

  • "IB" - identifier of Interbase driver; see also SQLList()

  • cLogin - a string containing user login

  • cPassword - a string containing user's password

  • cDB - a string containing the name of the database to be used (the file name)

  • cCharset - charset used by server; if not passed, SET("SQL_CHARSET") is used

  • cIsolation - a string containing the name of isolation level to be used by default (see Interbase manual for details); if not passed, SET("IB_ISOLATION_LEVEL") value is used; values containing one or more of the following strings divided by ';' are possible:

    • CONCURRENCY

    • READ COMMITTED or READ_COMMITTED

    • REC VERSION or REC_VERSION

    • NO REC VERSION or NO_REC_VERSION

    • CONSISTENCY

    • WAIT

    • NOWAIT

    • READ

    • WRITE

    the same values are possible for <cIsolation> parameter of TRowset:Start().

13.4.4.4. Other peculiarities

With Interbase, TConnect:Start() may receive the second parameter <cLockTables> describing what tables and how they should be locked during transaction. The string being contained in <cLockTables> should have the following form:

<table_name>=<lock_type>[;<table_name>=<lock_type>,...]

where <table_name> - the name of the table to be locked; <lock_type> - lock type; the following types are possible:

  • SHARED_READ

  • SHARED_WRITE

  • PROTECTED_READ

  • PROTECTED_WRITE

See Interbase manual for details.

13.4.5. ODBC driver manager

13.4.5.2. ConnectNew() syntax

To obtain a connect to the database server through ODBC manager use ConnectNew() with the following syntax:

ConnectNew("ODBC",<cDSN>,[<cLogin>],[<cPassword>],NIL,NIL,NIL,NIL,[<cCharset>])

where

  • "ODBC" - identifier of ODBC driver; see also SQLList()

  • cDSN - a string containing Data Source Name (see ODBC manual and odbc.ini)

  • cLogin - a string containing user login

  • cPassword - a string containing user's password

  • cCharset - charset used by server; if not passed, SET("SQL_CHARSET") is used

13.4.6. DBTCP proxy server for ODBC connections

13.4.6.1. Building an application

To be able to build an application using DBTCP proxy, appropriate packages must be installed. It includes DBTCP development files and clip-dbtcp package. See Installation chapter for details.

Link your application with DBTCP driver by adding -lclip-dbtcp to the end of clip command:

$clip -e test.prg -lclip-dbtcp

13.4.6.2. ConnectNew() syntax

To obtain a connect to the database server through DBTCP proxy use ConnectNew() with the following syntax:

ConnectNew("DBTCP",[<cHost>],[<cPort>],[<cLogin>],[<cPassword>],<cDSN>,NIL,NIL,[<cCharset>])

where

  • "DBTCP" - identifier of DBTCP driver; see also SQLList()

  • cHost - host name DBTCP server running on

  • cPort - server port number as string

  • cLogin - a string containing user login

  • cPassword - a string containing user's password

  • cDSN - a string containing Data Source Name

  • cCharset - charset used by server; if not passed, SET("SQL_CHARSET") is used