Solved

Embarcadero Interbase

Posted on 2014-02-06
9
785 Views
Last Modified: 2014-02-11
I want to create an Interbase table at run time like
var
  MyTable : TIBTable;
begin
  MyTable := TIBTable.Create(nil);
  MyTable.TableName := 'MyTableName';
  MyTable.Database := AnExistingDatabase;
  MyTable.FieldDefs.AddFieldDef.Name := 'Field1';
  MyTable.FieldDefs.AddFieldDef.DataType := ftInteger;
  MyTable.FieldDefs.AddFieldDef.Size := 0;
  MyTable.FieldDefs.AddFieldDef.Required := False;

  AnExistingDatabase.Open;
  MyTable.CreateTable;

This generates: Unsupported Field Type.


Also Tried to use TIBSQL component

Assign to a TIBSQL components SQL property with the text below
and set the TIBSQL database property to an IBDatabase component that points to
my database

Create Table "Table2"
(
  "Field1" Varchar(20) not null,
  "Field2" Float,
  primary key ("Field1")
);

procedure TForm1.Button2Click(Sender: TObject);
begin
  IBDatabase1.Open;
  IBSQL1.ExecQuery;
end;

I get the message Transaction Not assigned
0
Comment
Question by:CiaoBaby
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 27

Expert Comment

by:Sinisa Vuk
ID: 39840706
You want to create real table in ib database? If so - use plain sql (create table ...)
I you by create mean: TIBTable.Create(nil) - then you can use some of memory tables.
0
 
LVL 19

Assisted Solution

by:NickUpson
NickUpson earned 250 total points
ID: 39844970
(you don't need all the " characters in the create table statement

procedure TForm1.Button2Click(Sender: TObject);
begin
  IBDatabase1.Open;
         Here you need to start a transaction, IBSQL1.StartTrans I think;
  IBSQL1.ExecQuery;
          and here you need a commit
end;
0
 
LVL 24

Expert Comment

by:jimyX
ID: 39845001
I use FireBird which is close enough to Interbase:

Drop SQLTransaction and link it to the DBConnection and SQLQuery.
So you should have the following linking done first:
DBConnection.Transaction = SQLTrans
SQLTrans.Database = DBConnection
SQLQuery.Database = DBConnection
SQLQuery.Transaction = SQlTrans
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

Author Comment

by:CiaoBaby
ID: 39848396
JimyX
When you say link SQLTransaction to the DBConnection and SQLQuery How?

TIBTransaction does not have a Database property
SQLQuery does not have a Database Property
SQLQuery does not have a Transaction property
0
 
LVL 24

Expert Comment

by:jimyX
ID: 39849282
I was referring to IBxxx components.
0
 
LVL 24

Accepted Solution

by:
jimyX earned 250 total points
ID: 39849402
So it should read:
  IBDatabase.DefaultTransaction := IBTransaction;
  IBTransaction.DefaultDatabase := IBDatabase;
  IBSQL.Database := IBDatabase;
  IBSQL.Transaction := IBTransaction;

Open in new window

0
 

Author Comment

by:CiaoBaby
ID: 39851422
Finally, success. That was painful.   I can't believe that on all the web there is no reference to how to do this.

It's so not complicated if you know all the steps and relationships.  It took me 2 days to figure this out.  Maybe I should have said that I do not know any SQL.  Maybe it's assumed that if you know any programming that you know all this crap.

Thanks for the help you guys.

procedure TForm1.Button1Click(Sender: TObject);
begin
  IBDatabase1.DatabaseName := 'c:\backupdbs\JPBD.IB';
  IBDatabase1.Params.Clear;
  IBDatabase1.Params.Add('user_name=sysdba');
  IBDatabase1.Params.Add('password=masterkey');
  IBDatabase1.Open;
  IBDatabase1.DefaultTransaction := IBTransaction1;
  IBTransaction1.DefaultDatabase := IBDatabase1;

  IBQuery1.Transaction := IBTransaction1;
  IBQuery1.SQL.Clear;
  IBQuery1.SQl.Add('Create Table Employee4(PersonID Int, LastName varchar(255))');
  IBQuery1.Transaction.StartTransaction;
  IBQuery1.ExecSQL;
  IBQuery1.Transaction.Commit;

  //This also works
  //IBTransaction1.Commit;

  IBDatabase1.Close;
end;
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Append Query Access 2010 4 62
Delete old Sharepoint backups 2 54
mysql vs miscrosoft sql server 6 61
Posting a string with PostMessage 23 48
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

734 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