Solved

Executing Querys in code

Posted on 2014-02-11
3
319 Views
Last Modified: 2014-02-11
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
Comment
Question by:CiaoBaby
  • 2
3 Comments
 
LVL 69

Accepted Solution

by:
Qlemo earned 500 total points
ID: 39851858
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
 

Author Closing Comment

by:CiaoBaby
ID: 39851871
Thanks, for the fast and perfect response.  Is there some place I can find all the little gotcha's in SQL?
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 39851884
Sorry, no. This depends on the programming language used, and is no part of SQL specification.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Creating and Managing Databases with phpMyAdmin in cPanel.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question