Example needed

325 views
Skip to first unread message

doleynikov

unread,
Sep 23, 2010, 9:59:12 AM9/23/10
to Harbour Users
Dear friends,
can you share some examples how to use "firebird" in harbour on linux?
that would be very good If there will be complete source of .prg file
and list of libraries needed.
the short example will be ok. just show how to connect to database and
loop trough it to print value of one field.

Thanks

Maurizio Faccio adinet

unread,
Sep 23, 2010, 10:08:21 AM9/23/10
to harbou...@googlegroups.com
I do not use firebird.

Do you read

/harbour/contrib/hbfbird/readme.txt
/harbour/contrib/hbfbird/tests

or via rdd please read /harbour/contrib/RDDSQL, specially SDDFB


El 23/09/2010 10:59 a.m., doleynikov escribi�:

Dmitry Oleynikov

unread,
Sep 24, 2010, 4:19:35 AM9/24/10
to harbou...@googlegroups.com
Thank you,

Probably we (me and my English experience) are not smart enough.
RDDSQL looks right like what I need, but for the beginning I need
working example: just connect to database and read something.
I have Firebird installed, but I can't make examples from
/harbour/contrib/hbfbird/tests to work. If i try to connect to
existing database - it works somehow, but I can't create database!
Maybe someone could help me from the beginning: what packages should
be installed in UBUNTU? simple .prg with connection to database and
accessing to one field of current record. how to compile (what
libraries to link etc)

I need your assistance! Please, guide me for the few first steps.

2010/9/23 Maurizio Faccio adinet <mau...@adinet.com.uy>:

--
C уважением,

Дмитрий Олейников

Maurizio Faccio adinet

unread,
Sep 24, 2010, 6:51:14 AM9/24/10
to harbou...@googlegroups.com
I can only point you to the test that use mysql with RDD, i think it
will be the same with firebird. I do not know about how to compile, but
searching the harbour/INSTALL file with firebird word maybe helps you to
know how to compile harbour with firebird support. This maybe will help
you to make hbfbird samples work

harbour/contrib/RDDSQL/sddmy/tests
Please view Createtables function.

You can use RDD to manage a database query, then you manage it like a
DBF, but if you need to CREATE, INSERT, UPTADE, etc in the table within
the engine you should call

RDDINFO(RDDI_EXECUTE, to call SQL statements.

Hope it helps.

STATIC PROC CreateTable()
? RDDINFO(RDDI_EXECUTE, "DROP TABLE country")
? RDDINFO(RDDI_EXECUTE, "CREATE TABLE country (CODE char(3), NAME
char(50), RESIDENTS int(11))")
? RDDINFO(RDDI_EXECUTE, "INSERT INTO country values ('LTU',
'Lithuania', 3369600), ('USA', 'United States of America', 305397000),
('POR', 'Portugal', 10617600), ('POL', 'Poland', 38115967), ('AUS',
'Australia', 21446187), ('FRA', 'France', 64473140), ('RUS', 'Russia',
141900000)")
RETURN

Dmitry Oleynikov

unread,
Sep 24, 2010, 7:30:38 AM9/24/10
to harbou...@googlegroups.com
Many thanks!
I will continue to study this

2010/9/24 Maurizio Faccio adinet <mau...@adinet.com.uy>:

--
C уважением,

Дмитрий Олейников

Maurizio Faccio adinet

unread,
Sep 25, 2010, 6:48:11 AM9/25/10
to harbou...@googlegroups.com
Please If you can make your sample works, post it to the list so you
can help others like you.

Dmitry Oleynikov

unread,
Oct 10, 2010, 7:45:22 AM10/10/10
to harbou...@googlegroups.com
I do not have time to work with examples each day :-(
Finally I make it work somehow.
I reinstalled local firebird and everything what could be used from
this example. then created directory for databases, created come gdb
files from isql-fb utility, so now I am sure firebird is working.

then I changed few first lines of harbour/contrib/hbfbird/tests/simple.prg:

Function main()
Local oServer, oQuery, oRow, i, x, aTables, aStruct, aKey

Local cServer
Local cUser := "sysdba"
Local cPass := "masterkey"
Local nDialect := 3
Local cQuery
local DBpath
ALTD()
DBpath = ("/home/dimao/data/simple.gdb" ) // to be sure that I use
same database everywhere

cServer := "127.0.0.1:" + DBpath

IF hb_FileExists( DBpath )
FErase( DBpath )
ENDIF

? FBCreateDB( DBpath , cuser, cpass, 2048, "ASCII" , nDialect ) //
this line return no errors

? "Connecting..."

oServer := TFBServer():New( cServer, cUser, cPass, nDialect ) //no errors too

IF oServer:NetErr()
? oServer:Error()
QUIT
ENDIF
.......

Probably in linux it's impossible to have 1024 as pagesize.

Finally the program has created a database. there were one error in
other place of code, but the main goal is achieved!
next time I will play with RDD.

2010/9/25 Maurizio Faccio adinet <mau...@adinet.com.uy>:

> --
> You received this message because you are subscribed to the Google
> Groups "Harbour Users" group.
> Unsubscribe: harbour-user...@googlegroups.com
> Web: http://groups.google.com/group/harbour-users

Dmitry Oleynikov

unread,
Oct 10, 2010, 8:19:52 AM10/10/10
to harbou...@googlegroups.com
Now I am trying to play with SDDFB. I have compiled library in RDDSQL,
SDDFB folders. I do not know if I should install (copy) them somewhere
- so I left them "as is". Then copied test from SDDMY, and changed
MYSQL to FIREBIRD inside. It has been compiled without
warnings/errors. After I start executable, I only see the following:

SQLBASE
SQLMIX
DBF
DELIM
SDF
DBFFPT
DBFNTX
DBFNSX
DBFCDX
SIXCDX
DBFBLOB
Unable connect to the server

What to do next? Please help me!


2010/10/10 Dmitry Oleynikov <doley...@gmail.com>:

Massimo Belgrano

unread,
Oct 10, 2010, 8:51:03 AM10/10/10
to harbou...@googlegroups.com
Please post your last sample if you want good help

i can immagine that you receive "Unable connect to the server" becayse you have made incomplete translation
RDDINFO( RDDI_CONNECT, { "MYSQL", "localhost","root","mysql","test" } )
RDDINFO( RDDI_CONNECT, { "FIREBIRD",, "SYSDBA", "masterkey", "192.168.0.1:d:\data\test.fdb" } 

with rddsql you can't convert from mysql to firebird a sample without know the differences from this database and their sql implementation


2010/10/10 Dmitry Oleynikov <doley...@gmail.com>


--
Massimo Belgrano


Dmitry Oleynikov

unread,
Oct 11, 2010, 1:33:55 AM10/11/10
to harbou...@googlegroups.com
Thanks, Massimo!
it works. I thought the syntax is the same for every database.

2010/10/10 Massimo Belgrano <mbel...@deltain.it>:

Dmitry Oleynikov

unread,
Oct 11, 2010, 6:41:24 AM10/11/10
to harbou...@googlegroups.com
Well, now I see no errors due to connecting to database.
it shows .T. for all database operations. But then? when I want to
browse() the usearea - program failed!

SQLBASE
SQLMIX
DBF
DELIM
SDF
DBFFPT
DBFNTX
DBFNSX
DBFCDX
SIXCDX
DBFBLOB

.T.
.T.
.T.
.T.
Let's browse table (press any key)
Error SDDFB/1903 Prepare statement failed: SELECT * FROM country (DOS
Error -204)
Called from DBUSEAREA(0)
Called from MAIN(31)

THen I created table manually and just try to browse it -

SQLBASE
SQLMIX
DBF
DELIM
SDF
DBFFPT
DBFNTX
DBFNSX
DBFCDX
SIXCDX
DBFBLOB

Let's browse table (press any key)
Error SDDFB/1903 Prepare statement failed: SELECT * FROM country (DOS
Error -804)
Called from DBUSEAREA(0)
Called from MAIN(31)

Where is mistake?


11 октября 2010 г. 9:33 пользователь Dmitry Oleynikov
<doley...@gmail.com> написал:

Massimo Belgrano

unread,
Oct 11, 2010, 6:51:08 AM10/11/10
to harbou...@googlegroups.com
Mistake is due by  differences from this database and their sql implementation
you do a select from country but country table is not created
because use different create schema



2010/10/11 Dmitry Oleynikov <doley...@gmail.com>



--
Massimo Belgrano

Dmitry Oleynikov

unread,
Oct 11, 2010, 7:12:40 AM10/11/10
to harbou...@googlegroups.com
As I said: I have created table manually. I check this fact in GUI
tool (flamerobin). I added two records to the table.
But when I try to browse - error appears. I do not think MYSQL and
FIREBIRD have different SELECT.

dimao@dimao-desktop:~/sources/harbour/contrib/sddfb/tests$ cat test1.prg
/*
* $Id: test1.prg 14222 2010-03-24 09:33:58Z vszakats $
*/

#include "dbinfo.ch"
#include "error.ch"

#include "hbrddsql.ch"

REQUEST SDDFB, SQLMIX

ANNOUNCE RDDSYS

FIELD RESIDENTS

PROCEDURE main()
Local DBpath,DBserver
DBpath='/home/dimao/data/simple.gdb'
DBserver='localhost:' //I tried
127.0.0.1, localhost and just filename for local connection.

ALTD()
RDDSETDEFAULT("SQLMIX")

AEVAL(RDDLIST(), {|X| QOUT(X)})
if hb_FileExists(DBpath)
? "file OK!" // this line shows OK!
ENDIF

IF RDDINFO(RDDI_CONNECT, {"FIREBIRD",, "SYSDBA", "masterkey",
DBserver+DBpath }) == 0
? "Unable connect to the server"
RETURN
ENDIF

CreateTable()

? "Let's browse table (press any key)"
INKEY(0)
? DBUSEAREA( .T.,, "SELECT * FROM country", "country" )
Browse()

? "Let's browse table ordered by resident count (press any key)"
INKEY(0)
INDEX ON RESIDENTS TAG residents TO country
Browse()

DBCLOSEALL()
RETURN

STATIC PROC CreateTable() // DONE MANUALLY
// ? RDDINFO(RDDI_EXECUTE, "DROP TABLE country")
// ? RDDINFO(RDDI_EXECUTE, "CREATE TABLE country (CODE Varchar(5),
NAME Varchar(50), RESIDENTS numeric(10,1))")
// ? RDDINFO(RDDI_EXECUTE, "INSERT INTO country values ('LTU',


'Lithuania', 3369600), ('USA', 'United States of America', 305397000),
('POR', 'Portugal', 10617600), ('POL', 'Poland', 38115967), ('AUS',
'Australia', 21446187), ('FRA', 'France', 64473140), ('RUS', 'Russia',
141900000)")

// ? RDDINFO(RDDI_EXECUTE, "COMMIT")

RETURN


11 октября 2010 г. 14:51 пользователь Massimo Belgrano
<mbel...@deltain.it> написал:

Dmitry Oleynikov

unread,
Oct 12, 2010, 6:05:51 AM10/12/10
to harbou...@googlegroups.com
Who had luck, working with FIREBIRD trough SDDFB? I did not see any
success stories, searching "SDDFB" in google, only problem reports.
Maybe this feature not ready to use yet?

11 октября 2010 г. 15:12 пользователь Dmitry Oleynikov

Dmitry Oleynikov

unread,
Oct 14, 2010, 3:58:59 AM10/14/10
to harbou...@googlegroups.com
I wrote some article about my FIREBIRD exercises. It's in Russian,
because I am afraid my English is not so good and it will disallow me
to express all I need to explain.
I hope goodle-translator will help to translate.

12 октября 2010 г. 14:05 пользователь Dmitry Oleynikov

Dmitry Oleynikov

unread,
Oct 14, 2010, 1:01:34 PM10/14/10
to harbou...@googlegroups.com
now my blog ( http://dimao.blogspot.com/ ) contains feature to
translte it using Google transtation tool. It contains some
information about harbour amd sql, which I was able to gather from
internet and my own experience.
Your comments and corrections are welcome.

14 октября 2010 г. 11:58 пользователь Dmitry Oleynikov

Reply all
Reply to author
Forward
0 new messages