Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 13 total
Thread Longtime DBISAM User Getting Started - Help
Mon, Jan 28 2013 9:01 PMPermanent Link

Rick Hillier

Greetings,

After a couple of false starts, I want to get going with ElevateDB (about time, I've had this since v1.00 was introduced)... I recall asking about this back about a year+ ago and I didn't really get too far and I simply sent back to DBISAM.

In a nutshell, I'm starting off with a simple application.  It will be standalone - no admins, no predefined databases, all files will reside in the same folder as the executable.  There will be no preset files - I want the application to create them all.

I am absolutely flabbergasted as to where to begin, and I feel absolutely stupid asking this.

I have an TEDBEngine component's UseLocalSession setting to true.
I have a TEDBSession component set to use the engine component above and the LocalConfigPath setting set to the application executable's folder.

- all seems fine here.  I get a config file set to the defaults in the correct folder and I can log into it with the default username/password in the session component.

I then drop an EDBDatabase component on it, and I do see the session that I created present in the dropdown list, and I also set the database name here.  But at this point, the database list is empty.  I guess that I need to create a database if it does not exist.  I am not sure how to do that.  If I try a "CREATE DATABASE" statement with a query component connected to the database component, I get an error about the database not existing (of course not, that's why I'm trying to make it)...

I don't know where to go from here.

Sorry if I have insulted anyone's intelligence, but this is so easy in DBISAM and seems so convoluted in EDB.

>>> Rick <<<
Tue, Jan 29 2013 2:56 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Rick

>Sorry if I have insulted anyone's intelligence, but this is so easy in DBISAM and seems so convoluted in EDB.

If I had any I'm sure it would be!

There's a major change in thinking about things when moving from DBISAM to ElevateDB and it seems to trip most of us up in some way.

In your case the problem is that the session "manages" the database so the query needs to be "run" from the session. If you look at how things work in EDBManager its the same. You create databases from the session. Or more correctly the database you need to point the query at is Configuration.

In EDBManager look at the status bar at the bottom. When you open a session it tells you the database is Configuration. When you open a database that changes to the name of the database.

So drop your components on the form. Set the query components database to Configuration and you should be able to create your database. Or, since you want to do it in code, you could use Session.Execute(sqlstring) and that will do the job for you.

In case you haven't discovered it in EDBManager look at Explorer|SQL History - I test things out in EDBManager and when I've got it right cut'n'paste the code from there.

Hope that gets you started. If not come and insult us some more Smiley

Roy Lambert [Team Elevate]
Tue, Jan 29 2013 9:06 AMPermanent Link

Rick Hillier

Okay, I have it creating the database if it doesn't exist and I am now at the point where I want to verify the existence of the tables and create them if necessary.  I've read around the forum a bit and am confused by what I have read.  How do I verify if a table exists?  I'm not sure where to even look.  Do I need to learn how to do scripts, etc to do this?  This is so easy and straightforward with DBISAM.

I am just creating a simple program to manage dive logs for scuba divers.  Is it possible that EDB is overkill for what I need and that I should just stick with DBISAM?

Sorry for asking more stupid questions.

>>> Rick <<<
Tue, Jan 29 2013 9:18 AMPermanent Link

Raul

Team Elevate Team Elevate

Rick,

On 1/29/2013 9:06 AM, Rick Hillier wrote:
> Okay, I have it creating the database if it doesn't exist and I am now at the point where I want to verify the existence of the tables and create them if necessary.  I've read around the forum a bit and am confused by what I have read.  How do I verify if a table exists?  I'm not sure where to even look.  Do I need to learn how to do scripts, etc to do this?  This is so easy and straightforward with DBISAM.

You need to query the information schema using SQL :
http://www.elevatesoft.com/manual?action=viewtopic&id=edb2sql&topic=Information_Schema

In this case the tables table.

Note that the actual table file is only created when you add data so
lack of file on disk is not an indicator of needing to create the table.


> I am just creating a simple program to manage dive logs for scuba divers.  Is it possible that EDB is overkill for what I need and that I should just stick with DBISAM?

Can't really answer that one but if you do not need unicode support then
yes dbisam would be a valid choice still IMHO.  One of our mains apps is
still in DBISAM and we're not likely going to upgrade since everything
is working fine and DBISAM has been well supported.

On the other hand there is lot more capability in EDB (and bit of a
learning curve) so if any of the new features are important to you...

Also in short term there might be more support headaches with EDB as you
get used to it - for example use relative paths so you can move things
around more easily etc.

Raul
Tue, Jan 29 2013 9:57 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Rick


To respond to your last comment first - don't apologise - most of us have been there.

Second comment: DBISAM was and is a brilliant product. There are parts of it that I miss every time I open Delphi. It is, however, on maintenance so the future is with ElevateDB. Once you master it and have a few simply utilities its good. You'll have your own bits of DBISAM that you'll miss in perpetuity which will probably be different to mine. Mine don't stop me using ElevateDB and (generally) liking it. Is it overkill for a simple app - yes and no. Its inexpensive, easy to use once you're past the initial learning curve and offers additional features which you may want to take advantage of (eg encryption). Only you can may the decision.

First point last Smiley

To find out if a table exists you need to read the Information.Tables table (remember ElevateDB has a catalog). You need to do this from in the context of the database ie your query has to point at the database not at Configuration.

You could do it with Delphi and queries but a script would make it pretty much the same as DBISAM. Scripts aren't difficult (well OK they are compared to DBISAM scripts because they're a proper programming language not just a series of sql statements) and one set up can do a lot of the drudgery for you.

In addition to what I've written below you can also define the tables in your app with a TEDBTable component and then use that to create the actual tables. I've attached some of my utilities - look at SelfMakeMemoryTable  to give you an idea.

The way to start the script creation is to initially create your tables in EDBManager then on the Database Tasks menu use Reverse-Engineer Database. That will give you the basic script. eg

SCRIPT
BEGIN
EXECUTE IMMEDIATE 'CREATE TABLE "Movies"
(
....
)
VERSION 1.00
...';.

EXECUTE IMMEDIATE 'CREATE TABLE "Actors"
(
....
)
VERSION 1.00
...';.
EXECUTE IMMEDIATE 'CREATE INDEX "Film" ON "Movies" ("_Film" COLLATE "ANSI_CI")';

EXECUTE IMMEDIATE 'CREATE INDEX "Type" ON "Movies" ("_Type" COLLATE "ANSI_CI")';

EXECUTE IMMEDIATE 'CREATE INDEX "Format" ON "Movies" ("_Format" COLLATE "ANSI_CI")';

EXECUTE IMMEDIATE 'CREATE TEXT INDEX "fti_Film" ON "Movies" ("_Film" COLLATE "ANSI_CI")
INDEXED WORD LENGTH 30
WORD GENERATOR "Default"';

EXECUTE IMMEDIATE 'CREATE TEXT INDEX "fti_Comments" ON "Movies" ("_Comments" COLLATE "ANSI_CI")
INDEXED WORD LENGTH 30
WORD GENERATOR "Default"';
END

An easy way to then only create if they don't exist is to wrap each item in a TEXCEPTION block (pretty much as in Delphi) eg

SCRIPT
BEGIN
BEGIN
EXECUTE IMMEDIATE 'CREATE TABLE "Movies"
(
....
)
VERSION 1.00
...';.
EXCEPTION
END;
BEGIN
EXECUTE IMMEDIATE 'CREATE TABLE "Actors"
(
....
)
VERSION 1.00
...';.
EXCEPTION
END;
BEGIN
EXECUTE IMMEDIATE 'CREATE INDEX "Film" ON "Movies" ("_Film" COLLATE "ANSI_CI")';
EXCEPTION
END;
BEGIN
EXECUTE IMMEDIATE 'CREATE INDEX "Type" ON "Movies" ("_Type" COLLATE "ANSI_CI")';
EXCEPTION
END;
BEGIN
EXECUTE IMMEDIATE 'CREATE INDEX "Format" ON "Movies" ("_Format" COLLATE "ANSI_CI")';
EXCEPTION
END;
BEGIN
EXECUTE IMMEDIATE 'CREATE TEXT INDEX "fti_Film" ON "Movies" ("_Film" COLLATE "ANSI_CI")
INDEXED WORD LENGTH 30
WORD GENERATOR "Default"';
EXCEPTION
END;
BEGIN
EXECUTE IMMEDIATE 'CREATE TEXT INDEX "fti_Comments" ON "Movies" ("_Comments" COLLATE "ANSI_CI")
INDEXED WORD LENGTH 30
WORD GENERATOR "Default"';
EXCEPTION
END;

END


Roy Lambert [Team Elevate]




Attachments: nlhEDB.pas
Tue, Jan 29 2013 12:02 PMPermanent Link

Adam Brett

Orixa Systems

Rick,

>> I am just creating a simple program to manage dive
>>logs for scuba divers.  Is it possible that EDB is overkill
>>for what I need and that I should just stick with DBISAM?

Others are giving you tips, so I won't do that here. EDB is a great big product, DBISAM is a great little product. I am sure for the use you describe DBISAM would be more than adequate.

Honestly there are only 3 reasons to use EDB:

1. You want to use this easy program to get to grips with EDB for bigger stuff.
2. You need any one of the excellent additional features of EDB (wide-strings, views, triggers, replication, procedures, jobs, roles, users, extra SQL capability including a wider range of file-handling ...)
3. You fancy a challenge & something new in your life Smile

... if the answers to all the above are "no" stick with DBISAM.

--

When I moved over a "simple" program from DBISAM to EDB I think it took me a week of head scratching & asking questions to get it done ... I didn't need to transfer it over, but I was glad I did, as when a more complex project came along I had already done a lot of the most important learning.
Tue, Jan 29 2013 8:19 PMPermanent Link

Adam H.

Hi Rick,

> I am just creating a simple program to manage dive logs for scuba divers.  Is it possible that EDB is overkill for what I need and that I should just stick with DBISAM?

You've got my interest! Are you planing on having this interface with
any computers in the end, or import data from other systems, or will it
be something that the user will enter in all itself? Smile

As for DBISam vs EDB. I've written a few programs in EDB, but my larger
existing programs are still in DBISam. (Mainly because they're so large
it's just not practical to change them over. Too many large SQL's that
won't go to EDB easily).

I plan on continuing to use DBISam for small applications. It's simple,
neat, and robust. (Just copy and paste to another computer and away you
go).

I'm using EDB for my new larger programs because it's easier to do that,
than to upgrade later if I want - and it gives me an opportunity to
learn it better.

If I was developing an app like you are suggesting, I would probably use
DBISam, unless I wanted to use it as an opportunity to learn EDB better.

Anyway - get back to me with information on this app. I'm interested. Smile

Cheers

Adam.
Wed, Jan 30 2013 3:13 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Adam


>When I moved over a "simple" program from DBISAM to EDB I think it took me a week of head scratching & asking questions to get it done ... I didn't need to transfer it over, but I was glad I did, as when a more complex project came along I had already done a lot of the most important learning.

You're lucky. I used my head to demolish three brick walls when I started <vbg>

Roy
Fri, Feb 1 2013 12:23 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Rick,

<< I have an TEDBEngine component's UseLocalSession setting to true. >>

First rule - don't do that, you're just over-complicating things
unnecessarily.  Leave it at the default of False.  Second rule, ignore the
scary warnings on the support forums. True, there are lots of changes in EDB
from DBISAM.  However, they are, on balance, a huge improvement over DBISAM,
and you'll be happy to have switched after a short learning curve.  Just
about everything that was a limitation/problem/inconsistency in DBISAM is no
longer the case with EDB.

If you want things to be as close to DBISAM as possible, then do this:

1) In your TEDBEngine component, set the ConfigMemory to True.  This will
enable in-memory configuration file usage, which means that you won't have
any configuration file on disk to worry about.

2) In a TEDBSession.BeforeConnect event handler, put in code like this:

procedure TForm1.EDBSession1BeforeConnect(Sender: TObject);
var
  TempDBPath: String;
begin
  with Sender do
     begin
     TempDBPath:=IncludeTrailingBackslash(ExtractFilePath(Application.ExeName))+'Data';
     if (Execute('SELECT * FROM Databases '+
                 'WHERE Name='+Engine.QuotedSQLStr('MyDatabase'))=1) then
        Execute('ALTER DATABASE MyDatabase PATH
'+Engine.QuotedSQLStr(TempDBPath))
     else
        Execute('CREATE DATABASE MyDatabase PATH
'+Engine.QuotedSQLStr(TempDBPath));
     end;
end;

(alter the TempDBPath as necessary to fit your application requirements)

That's it.  After this, as long as the database exists in the location that
you tell it, you'll have exactly what you have with DBISAM.

However, there is one downside to this type of arrangement, and that is that
the EDB Manager won't be able to use the configuration file to determine
where your database is located.  So, if you want the EDB Manager to be able
to use the same configuration file as your application and be able to
automatically "see" your database, then set the TEDBEngine.ConfigMemory
property to False and add a TEDBEngine.BeforeStart event handler (none of
the above code needs to change):

procedure TForm1.EDBEngine1BeforeStart(Sender: TObject);
begin
  Engine.ConfigPath:=ExtractFilePath(Application.ExeName);
end;

(alter the path as necessary to fit your application requirements).

In the EDB Manager, just make sure that the configuration path is set to the
same value that you're using here (select Session node/Edit Session/Local
tab/Configuration File).

As for creating the tables, etc. on the fly, please check out the data
module for the CDCollector sample application that can be found in the
\Examples subdirectory under the main installation directory.  It shows how
to do the above, as well as create all of the database objects on the fly.

If you have any other questions, please let me know.

Tim Young
Elevate Software
www.elevatesoft.com
Fri, Feb 1 2013 1:42 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim



><< I have an TEDBEngine component's UseLocalSession setting to true. >>
>
>First rule - don't do that, you're just over-complicating things
>unnecessarily. Leave it at the default of False.

I personally find it easier mainly I think because it allows me to put in user id & password - saves me having to type it in when setting everything up in the IDE (naturally these are the development ones and strangely enough user XX doesn't seem to exist on any of the live systems Smiley.

Roy Lambert
Page 1 of 2Next Page »
Jump to Page:  1 2
Image