Query problems Zeos 6.6.6, Lazarus 0.9.28.2b & Firebird

Forum related to Firebird

Moderators: gto, cipto_kh, EgonHugeist

christensen
Fresh Boarder
Fresh Boarder
Posts: 12
Joined: 13.05.2010, 11:31

Query problems Zeos 6.6.6, Lazarus 0.9.28.2b & Firebird

Post by christensen »

Hi guys,
Today I’ve installed Zeos 6.6.6 component on Lazarus 0.9.28.2beta till this moment I’ve use SQLbd for Mysql but I want to learn Firebird.
I have problems with queries:

The select is working well:

Code: Select all

ZQuery1.Close;
    ZQuery1.SQL.Clear;
    ZQuery1.SQL.Add('Select NAME from test');
    ZQuery1.Open;     
The insert doesn’t work at all(I haven’t test DELETE query):

Code: Select all

ZQuery1.Close;
  ZQuery1.SQL.Clear;
  ZQuery1.SQL.Add('insert into test(ID, NAME, SURNAME, ADDRESS, PHONE) values (“3”, “D”, “E”, “F”, “458”)');
  ZQuery1.ExecSQL;
The same with UPDATE:

Code: Select all

ZQuery1.Close;
        ZQuery1.SQL.Clear;
        ZQuery1.SQL.Add('update test  set name="BlaBla” where id=1');
        ZQuery1.ExecSQL;      
The code is ok, because I’ve tested on IBExpert: insert into test(ID, NAME, SURNAME, ADDRESS, PHONE) values ('2', 'A', 'B', 'C', '123');

I don’t know what I’m doing wrong :(

Thankx
sfxcc
Senior Boarder
Senior Boarder
Posts: 95
Joined: 13.05.2010, 18:48

Post by sfxcc »

Make sure u have the zconnection Active and if is connected.
Go to firebird guardian check if there's a client connected.

It must work.. SQL is fine and zquery works .. or u have the same problem i did u dont have the correct fbclient.dll

Make sure u have at least zeos 6.6.5 if u using firebird 2.1 .

And use firebirdd-21 and not the firebird-21 Protocol.

Just try with the embeded first. Then u can change the client dll for remote connection.

Check on Internet for embedded firebird.


Hope this help a bit. :prog2:
silvioprog
Junior Boarder
Junior Boarder
Posts: 42
Joined: 10.01.2009, 00:34
Location: Brasil
Contact:

Post by silvioprog »

Double quote ("1") mark in integer field, this works? I uses ('1').

Other error: NAME. Use ANOTHER_NAME, name is primitive type in Fb. :wink:
guidoaerts
Senior Boarder
Senior Boarder
Posts: 93
Joined: 01.07.2009, 16:07

Post by guidoaerts »

I know NAMES is a reserved word in firebird, but what is a primitive type?
guido
about strings and quotes in firebird, read this :
http://www.firebirdsql.org/manual/qsg10 ... 10-strings
and then there is the extra caveat of quoted string in a string..
christensen
Fresh Boarder
Fresh Boarder
Posts: 12
Joined: 13.05.2010, 11:31

Post by christensen »

Thanks for the answer!
i've change the field name but the same problem.

other thing what i do is to change the protocol 'firebirdd-21 Protocol' but doesn't work at all, the fdclientd21.dll and fdclientd.dll are missing.

why is working the select and other no?!
silvioprog
Junior Boarder
Junior Boarder
Posts: 42
Joined: 10.01.2009, 00:34
Location: Brasil
Contact:

Post by silvioprog »

christensen,

Code: Select all

...Protocol := 'firebird-2.1'; // To Fb no embedded.
Copy fbclient.dll to your .exe dir, or system32 dir. To more samples:

http://www.silvioprog.com.br/downloads/ ... mos_en.zip (to Lazarus, here in forum has to Delphi)

guidoaerts,

I do not understand what you want (I use a translator :oops: ). Primitive that belongs to the database, not me.

P.S.: I use PostgreSQL, I could be wrong on the types of data Firebird.
sfxcc
Senior Boarder
Senior Boarder
Posts: 95
Joined: 13.05.2010, 18:48

silvio prog

Post by sfxcc »

guidoaerts,

I do not understand what you want (I use a translator ). Primitive that belongs to the database, not me.
Sivlio prog -

O ke o guido queria dizer e que a palavra "NAME" nao pode ser usada no firebird porque e um palavra reservada usa pelo sistema.

Já agora . >
Firebirdd - > para embeeded
Firebird - > para remoto

:idea:

Esta Correcto ? - penso qe é isto mas não tenho 100% certeza.

:?:
where's the code ..
silvioprog
Junior Boarder
Junior Boarder
Posts: 42
Joined: 10.01.2009, 00:34
Location: Brasil
Contact:

Post by silvioprog »

Então cara, foi justamente o que falei. Mas não sei pq ele me mostrou o link dos docs do Fb. :? Como uso tradutor e não tive certeza do que falei, coloquei a observação que uso o Pg. (Usei o Fb por mais ou menos um ano, não tenho 100% de certeza).

Acho que vai funcionar para o christensen, o problema parece ser ou fbclient.dll inexistente, ou o protocol do ZConn.

Acho que não podemos falar em português aqui no fórum, rs... :roll:
guidoaerts
Senior Boarder
Senior Boarder
Posts: 93
Joined: 01.07.2009, 16:07

Post by guidoaerts »

NAMES e um palavra reservada do firebird, não NAME
o link dos docs do fb fale de ' e '' e " e como usar
in the code examples, that christensen gave, the quotes are represented by ascii 221 or ascii 222
christensen
Fresh Boarder
Fresh Boarder
Posts: 12
Joined: 13.05.2010, 11:31

Post by christensen »

silvioprog wrote:
Copy fbclient.dll to your .exe dir, or system32 dir. To more samples:

http://www.silvioprog.com.br/downloads/ ... mos_en.zip (to Lazarus, here in forum has to Delphi)
I have this file in System32 directory and i've copy near the exe, but still the same still need fdclientd21.dll, fdclientd.dll files.
I had search for those files but unfortunately i don't find :( .

I had make a few screenshot:

Components:
Query:
Image

Image

Connection:
Image

Connection error:
Image

Insert error:
Image

Update error:
Image

Database:
Ibexpert
Image

Image

ODBC:
Image

Image

Image
guidoaerts
Senior Boarder
Senior Boarder
Posts: 93
Joined: 01.07.2009, 16:07

Post by guidoaerts »

christensen,
you should, in your sql string use two single quotes in stead of one double quote around your string values

ZQuery1.SQL.Add('update test set name="BlaBla” where id=1');
should be
ZQuery1.SQL.Add('update test set name=''BlaBla'' where id=1');

ZQuery1.SQL.Add('insert into test(ID, NAME, SURNAME, ADDRESS, PHONE)
values (“3”, “D”, “E”, “F”, “458”)');

should be

ZQuery1.SQL.Add('insert into test(ID, NAME, SURNAME, ADDRESS, PHONE) values (3,''D'',''E'', ''F'',458)');

and no quotes for integer fields (I don't know if PHONE is an integer field, if it is varchar, put it between doubled single quotes, hope you understand what I want to say.
when you use double quotes, fb thinks you quote a table.column
I advise you first return to the configuration where the SELECT statement was working well.
Last edited by guidoaerts on 19.05.2010, 17:54, edited 1 time in total.
sfxcc
Senior Boarder
Senior Boarder
Posts: 95
Joined: 13.05.2010, 18:48

Are u sure u have the Firebird installed

Post by sfxcc »

Make sure u have firebird installed - > FB 21 is best.

So it cant find the dll do :

Copy files from programs /Firebird/ fb*.dll to windows/System32/

If u dont have on programs/firebird/ the fbclient.dll or fb*.dll you have to check for some dll like gds.dll or gds32.dll (this files are on some versions by mistake) and rename it to :

- Fbclient.dll
- fbclient-21.dll - > if is fb21
- fbclientd-21.dll - > id is fb21

then copy then to system32.


Install version 21

And use Zeos components and not odbc u dont need ODBC( is to be removed from windows..)... so..


Hope this help u a bit. :idea:
where's the code ..
silvioprog
Junior Boarder
Junior Boarder
Posts: 42
Joined: 10.01.2009, 00:34
Location: Brasil
Contact:

Post by silvioprog »

christensen, you will use embedded database? If not, please uses protocol firebird-2.1.

Protocol firebirdd (with two d) is to embedded database.
christensen
Fresh Boarder
Fresh Boarder
Posts: 12
Joined: 13.05.2010, 11:31

Post by christensen »

guidoaerts, thank you very much!
That was the problem!
I use double quotes instead two single quotes!

Now all are working!
silvioprog
Junior Boarder
Junior Boarder
Posts: 42
Joined: 10.01.2009, 00:34
Location: Brasil
Contact:

Post by silvioprog »

I do not understand you, I was shown this early in the thread:
silvioprog Posted: 18.05.2010, 16:48 (No subject)
Double quote ("1") mark in integer field, this works? I uses ('1').
But no problems, serves as a lesson for me. 8)
Post Reply