* removed

git-svn-id: trunk@9940 -
This commit is contained in:
marco 2008-01-26 16:47:05 +00:00
parent 9e8a372a48
commit c13acc44df
12 changed files with 0 additions and 4101 deletions

10
.gitattributes vendored
View File

@ -888,16 +888,6 @@ packages/base/mysql/ver323/mysqls.pp svneol=native#text/plain
packages/base/mysql/ver40/mysql.pp svneol=native#text/plain
packages/base/mysql/ver40/mysql_com.pp svneol=native#text/plain
packages/base/mysql/ver40/mysql_version.pp svneol=native#text/plain
packages/base/odbc/Makefile svneol=native#text/plain
packages/base/odbc/Makefile.fpc svneol=native#text/plain
packages/base/odbc/README -text
packages/base/odbc/fpmake.inc svneol=native#text/plain
packages/base/odbc/fpmake.pp svneol=native#text/plain
packages/base/odbc/odbcsql.inc svneol=native#text/plain
packages/base/odbc/odbcsql.pas svneol=native#text/plain
packages/base/odbc/odbcsqldyn.pas svneol=native#text/plain
packages/base/odbc/testodbc.mdb -text
packages/base/odbc/testodbc.pp svneol=native#text/plain
packages/base/oracle/Makefile svneol=native#text/plain
packages/base/oracle/example/Makefile svneol=native#text/plain
packages/base/oracle/fpmake.inc svneol=native#text/plain

7
.gitignore vendored
View File

@ -249,13 +249,6 @@ packages/base/mysql/ver40/*.ppu
packages/base/mysql/ver40/*.s
packages/base/mysql/ver40/fpcmade.*
packages/base/mysql/ver40/units
packages/base/odbc/*.bak
packages/base/odbc/*.exe
packages/base/odbc/*.o
packages/base/odbc/*.ppu
packages/base/odbc/*.s
packages/base/odbc/fpcmade.*
packages/base/odbc/units
packages/base/oracle/*.bak
packages/base/oracle/*.exe
packages/base/oracle/*.o

File diff suppressed because it is too large Load Diff

View File

@ -1,26 +0,0 @@
#
# Makefile.fpc for odbc bindings
#
[package]
name=odbc
version=2.0.0
[target]
units=odbcsql odbcsqldyn
examples=testodbc
[require]
libc=n
[install]
fpcpackage=y
[default]
fpcdir=../../..
[shared]
build=n
[rules]
.NOTPARALLEL:

View File

@ -1,40 +0,0 @@
Testing raw ODBC access:
For windows:
============
1. Compile testodbc. No options should be needed.
2. In the ODBC manager in the Windows Control Panel, create a new system or
file DSN called 'FPC' with the 'Microsoft Access (*.mdb)' driver
(At least MS-Access 97 or higher)
Do not enter any username or password.
The DSN should point to the testodbc.mdb database file provided with the
testodbc.pp program.
3. Run the program.
For Linux:
==========
1. Change testodbc.pp and set the UserName and Password constants if needed.
2. Compile testodbc. No options should be needed.
3. Create a MySQL database and table with the mkdb script in the mysql
directory. make sure the password and username as set in step 1 have
access to this databse.
4. Install a DSN called FPC for the newly created database.
(I used the unixODBC ODBCConfig program for this)
5. Run the program.
Enjoy !
Michael.

View File

@ -1,10 +0,0 @@
StartPackage('odbc');
{$IF defined(ALLPACKAGES)}
Directory:='base/odbc';
{$ELSEIF defined(BASEPACKAGES)}
Directory:='odbc';
{$ENDIF}
OS:=[linux,win32,netbsd,openbsd,freebsd,darwin];
T:=Targets.AddUnit('odbcsql');
T:=Targets.AddExampleunit('testodbc');
EndPackage;

View File

@ -1,17 +0,0 @@
{$mode objfpc}{$H+}
program fpmake;
uses fpmkunit;
Var
T : TTarget;
begin
With Installer do
begin
{ Base packages }
{$i fpmake.inc}
Run;
end;
end.

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +0,0 @@
unit odbcsql;
{$UNDEF DYNLOADINGODBC}
{$i odbcsql.inc}
end.

View File

@ -1,7 +0,0 @@
unit odbcsqldyn;
{$DEFINE DYNLOADINGODBC}
{$i odbcsql.inc}
end.

Binary file not shown.

View File

@ -1,121 +0,0 @@
Program TestODBC;
uses odbcsql;
Const
DBDSn : Pchar = 'FPC';
Empty : pchar = '';
Query : pchar = 'SELECT Id,Username,InstEmail from FPdev Order by UserName';
// Adapt to needs...
{$ifdef linux}
UserName : pchar = 'michael'; // for mysql test.
Password : pchar = 'geen';
{$else}
UserName : pchar = ''; // for MS-Acces test.
Password : pchar = '';
{$endif}
Function ODBCSuccess (Res : Integer) : Boolean;
begin
ODBCSuccess:= (res=SQL_SUCCESS) or (res=SQL_SUCCESS_WITH_INFO);
end;
Var
EnvHandle : SQLHandle;
DBHandle : SQLHandle;
StmtHandle : SQLHSTMT;
ResID : Longint;
ResName : Array[0..255] of char; // Matches length of field+1
ResEmail : Array[0..255] of char;
Procedure FreeHandles;
begin
If assigned(StmtHAndle) then
SQLFreeHandle(SQL_HANDLE_STMT,StmtHandle);
If assigned(dbhandle) then
SQLFreeHandle(SQL_HANDLE_DBC,DBHandle);
If assigned(EnvHandle) then
SQLFreeHandle(SQL_HANDLE_ENV,EnvHandle);
end;
Procedure DoError (Msg : String;ErrCode : Integer);
begin
FreeHandles;
Writeln(Msg,' Code : ',ErrCode);
Halt(1);
end;
Procedure StartSession;
Var
Res : Integer;
begin
EnvHandle:=nil;
DBHandle:=nil;
StmtHandle:=nil;
Res:=SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, EnvHandle);
if Res <> SQL_SUCCESS then
DoError('Could allocate ODBC handle',Res);
Res:=SQLSetEnvAttr(EnvHandle,SQL_ATTR_ODBC_VERSION, SQLPOINTER(SQL_OV_ODBC3), 0);
If Not ODBCSuccess(res) then
DoError('Could not set environment',Res);
Res:=SQLAllocHandle(SQL_HANDLE_DBC, envHandle, DBHandle);
If res<>SQL_SUCCESS then
DoError('Could not create database handle',res);
Res:=SQLConnect(DBHandle,PSQLCHAR(DBDSN),SQL_NTS,
PSQLChar(UserName),SQL_NTS,
PSQLCHAR(Password),SQL_NTS);
If Not OdbcSuccess(res) then
DoError('Could not connect to datasource.',Res);
end;
Procedure ExecuteStatement;
Var
Res,ErrCode : LongInt;
begin
Res:=SQLAllocHandle(SQL_HANDLE_STMT,DBHandle,stmtHandle);
If not ODBCSuccess(res) then
DoError('Could not allocate statement handle.',Res);
{ Bind result buffers.
Note that for many queries, the result is not known on beforehand,
And must be queried with SQLPrepare, SQLNumResulCols and SQLDescribeCol
before the statement is executed.}
SQLBindCol(stmtHandle,1,SQL_INTEGER,SQLPointer(@ResID),4,@ErrCode);
SQLBindCol(stmtHandle,2,SQL_CHAR,SQLPointer(@ResName),256,@ErrCode);
SQLBindCol(stmtHandle,3,SQL_CHAR,SQLPointer(@ResEmail),256,@ErrCode);
// Now actually do it.
Res:=SQLExecDirect(StmtHandle,Query,SQL_NTS);
if not ODBCSuccess(res) then
DoError('Execute of statement failed.',Res);
end;
Procedure ShowResult;
Var
Count,Res : Longint;
begin
Res:=SQLFetch(StmtHandle);
Count:=0;
While Res<>SQL_NO_DATA do
begin
Inc(Count);
Write('Record: ',Count,' : ');
Writeln(ResId,' ',PChar(@ResName[0]),' ',Pchar(@ResEmail[0]));
Res:=SQLFetch(StmtHandle);
end;
end;
begin
StartSession;
ExecuteStatement;
ShowResult;
FreeHandles;
end.