• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 327
  • Last Modified:

Executing Querys in code

IBDatabase1.Open;
  IBQuery1.Database := IBDatabase1;
  IBQuery1.SQL.Clear;

   //All the examples show
  //  Insert into employee(Field1, Field2) Values('1','Price')
  // Problem is that the entire string has to be in single quotes

  //None of these work
  IBQuery1.SQL.Add('Insert into Employee(PersonID, LastName) Values(1, Price)');
  IBQuery1.SQL.Add('Insert into Employee(PersonID, LastName) Values(1, "Price")');
 
  IBQuery1.Transaction.StartTransaction;
  IBQuery1.ExecSQL;

   // This generates the error - 'Dynamic SQL Error SQL Error Code = -206
   // column unknown
   // PRICE
 
 
  IBQuery1.Transaction.Commit;
  IBDatabase1.Close;
0
CiaoBaby
Asked:
CiaoBaby
  • 2
1 Solution
 
QlemoC++ DeveloperCommented:
You used " instead of two single quotes for each inline single quote:
IBQuery1.SQL.Add('Insert into Employee(PersonID, LastName) Values(1, ''Price'')');

Open in new window

0
 
CiaoBabyAuthor Commented:
Thanks, for the fast and perfect response.  Is there some place I can find all the little gotcha's in SQL?
0
 
QlemoC++ DeveloperCommented:
Sorry, no. This depends on the programming language used, and is no part of SQL specification.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now