Recent

Author Topic: [SOLVED] Lazarus + Firebird how to delete from table!?  (Read 10344 times)

nicke85

  • Jr. Member
  • **
  • Posts: 92
  • #13#10
[SOLVED] Lazarus + Firebird how to delete from table!?
« on: September 21, 2010, 06:07:23 pm »
I'm new with firebird database and don't know how to delete  from table..
I want one or two Edit1.Text components on form to use like criterium for delete from table..
What I need to do..!?
If write
    
Code: [Select]
SQLQuery1.SQL.Text:='delete from (table) where xxx=:' + Edit1.Text;
it doesnt work..
does somebody can write me steps and components without SQLQuery1.DeleteSQL component.. :)
« Last Edit: September 26, 2010, 02:42:44 pm by nicke85 »
ArchLinux X64 (XFCE) & Windows 7 SP1 Ultimate X64
FPC 2.7.1 / Lazarus 1.1 / ZeosDBO / fortes4lazarus -- all svn

mirce.vladimirov

  • Sr. Member
  • ****
  • Posts: 256
Re: Lazarus + Firebird how to delete from table!?
« Reply #1 on: September 21, 2010, 10:44:53 pm »
I dont know about the FirebirdSQL, I have never used it, but I think that you need to enclose the edit1.text in single qutoes, because it is a string. Strings must be quoted with single quotes. And number two, I believe that the equation sign is typed incorectly, it should not be
xxx:='some text'
like in pascal/delphi/lazarus, the SQL correct gramar is just '='
xxx='some text'

Code: [Select]

SQLQuery1.SQL.Text:='delete from table where xxx=' + #39 + Edit1.Text + #39;

The character #39 is a single quote. This line of code would be same like if you typed to the SQL prompt the following:

Code: [Select]
delete from table where xxx='this is the text contained in the edit1';

Lacak2

  • Guest
Re: Lazarus + Firebird how to delete from table!?
« Reply #2 on: September 22, 2010, 06:12:31 am »
Yes, and you can also use syntax with parameter:

Code: [Select]
SQLQuery1.SQL.Text:='delete from table where xxx=:xxx';
SQLQuery1.Params.ParamByName('xxx').AsString:='some text';
SQLQuery1.ExecSQL;

nicke85

  • Jr. Member
  • **
  • Posts: 92
  • #13#10
Re: Lazarus + Firebird how to delete from table!?
« Reply #3 on: September 23, 2010, 07:26:19 pm »
Thanks for reply mirce.vladimirov and Lacak2...
For Firebird conection I need IBConnection1,SQLTransaction and SQLQuery..i know how to insert,update make functions but don't know how to delete..
What is with SQLTransaction when i need to delete from table!?
I got every time that data from table is errased but there is no change into table for really...
ArchLinux X64 (XFCE) & Windows 7 SP1 Ultimate X64
FPC 2.7.1 / Lazarus 1.1 / ZeosDBO / fortes4lazarus -- all svn

Lacak2

  • Guest
Re: Lazarus + Firebird how to delete from table!?
« Reply #4 on: September 24, 2010, 06:05:53 am »
May be, that you must also Commit changes using:
Code: [Select]
SQLTransaction1.Commit; or SQLTransaction1.CommitRetaining

jagorath

  • New Member
  • *
  • Posts: 34
Re: Lazarus + Firebird how to delete from table!?
« Reply #5 on: September 24, 2010, 06:54:03 am »
As an aside, you can use QuotedStr from SysUtils as an alternative to #39 or a quote character, e.g.

Code: [Select]
SQLQuery1.SQL.Text:= 'delete from table where xxx=' + QuotedStr(Edit1.Text);

nicke85

  • Jr. Member
  • **
  • Posts: 92
  • #13#10
Re: Lazarus + Firebird how to delete from table!?
« Reply #6 on: September 26, 2010, 02:41:55 pm »
Lacak2 open SQLTransaction1 solve my problem for Insert and Update but real problem was in QuotedStr like jarogath wrote..
And Yes!!!!It solved my problem thanks you a lot for help jarogath :D :D
ArchLinux X64 (XFCE) & Windows 7 SP1 Ultimate X64
FPC 2.7.1 / Lazarus 1.1 / ZeosDBO / fortes4lazarus -- all svn

 

TinyPortal © 2005-2018