Recent

Author Topic: Sql query with dbf [solved]  (Read 15378 times)

Cz-David

  • New Member
  • *
  • Posts: 12
Sql query with dbf [solved]
« on: February 24, 2008, 10:49:12 am »
Can someone show me (step by step) how to connect sql query component to tdbf. I have tried everything and looked everywhere (i hope) but I still get "database not assigned" error.

Let's say that I have a table with 2 columns.
Id -autoincrement
otazka -string

How can I transfer otazka with id=2 to label or variable.

Thanks.

gerardus

  • Jr. Member
  • **
  • Posts: 84
RE: Sql query with dbf
« Reply #1 on: February 24, 2008, 12:05:37 pm »
Hi,

AFAIK SQL querys only work with SQL database backends.
TDBF reads/writes DBF flat files and has no support for SQL.

Regards,

Gerard.

Cz-David

  • New Member
  • *
  • Posts: 12
RE: Sql query with dbf
« Reply #2 on: February 24, 2008, 12:20:22 pm »
That's bad... So what do you recommend for a database? Where i can use sql select to work with variables. But I certainly don't want to use server but files. Even though most of my program's targeted end users has access to such technology, it's just not very user-friendly. And I don't want users to install extra files for work with databases.

Edit: SQLite looks good.

Cz-David

  • New Member
  • *
  • Posts: 12
RE: Sql query with dbf
« Reply #3 on: February 24, 2008, 03:19:50 pm »
I have succesfully converted my app to sqlite, but I still don't know how to get data from db to variable... sql query is still in "database not assigned" error... what should I do ?

Cz-David

  • New Member
  • *
  • Posts: 12
RE: Sql query with dbf
« Reply #4 on: February 24, 2008, 03:29:19 pm »
Code: [Select]
label1.caption:=sqlite.QuickQuery('SELECT otazka FROM Otazky where id=0');
works

OnixJr

  • Full Member
  • ***
  • Posts: 172
    • http://www.brlazarus.kit.net
RE: Sql query with dbf
« Reply #5 on: February 24, 2008, 04:22:46 pm »
Quote
I have succesfully converted my app to sqlite, but I still don't know how to get data from db to variable...


How do you do with TDbf?

I always do (in SQL or TDbf) something as:
Code: [Select]

  sqlite.recno := 0; // can use next, prior, last, first methods...
  label1.caption := sqlite.FieldByName('otazka').AsString;
Portal Lazarus Brasil - http://lazaruspascal.codigolivre.org.br/portal.php
Lazarus BOOK (in portuguese) - http://lazarus-book.blogspot.com
<hipernetjr@yahoo.com.br> - Curitiba/Brazil

Cz-David

  • New Member
  • *
  • Posts: 12
RE: Sql query with dbf
« Reply #6 on: February 24, 2008, 06:26:38 pm »
I suppose that can work too.

tatamata

  • Hero Member
  • *****
  • Posts: 732
    • ZMSQL - SQL enhanced in-memory database
Sql query with dbf [solved]
« Reply #7 on: February 25, 2008, 12:13:01 pm »
Oh, I see I am not the only one looking SQL engine for TDbf:)))
As I see it now, TDbf or any other flat file database (Sdf, for example) has great advantage over SQL servers in terms of portability, easy distribution and modular design when you want to develop cluster of different small front-end programs that operate with same set of data tables.
But the great disadvantage is lack of SQL.
The solution is to develop an SQL query component (SQL engine) that is TDataset descendant and can query different flat table datasets.
There is such component for Delphi, commercial though, called TxQuery...
The starting point could be TJanSQL engine...

gerardus

  • Jr. Member
  • **
  • Posts: 84
Sql query with dbf [solved]
« Reply #8 on: February 25, 2008, 05:49:20 pm »
Before you develop a SQL engine for flat files, you may want to have a look to Firebird. (http://www.firebirdsql.org)

tatamata

  • Hero Member
  • *****
  • Posts: 732
    • ZMSQL - SQL enhanced in-memory database
Sql query with dbf [solved]
« Reply #9 on: February 26, 2008, 07:53:14 pm »
Let's say you develop an application with Firebird embedded for Windows.
You created .exe to be distributed with Firebird embedded DLLs for Windows.
Your customers want it to be runnable on Linux.
OK, you can recompile your application on Linux, but what about Firebird embedded on Linux? What .so files to be distributed? Does it work without Firebird classic or superserver running in background? If not, then it is not true embedded solution....

Regards,

Zlatko

gerardus

  • Jr. Member
  • **
  • Posts: 84
Sql query with dbf [solved]
« Reply #10 on: February 27, 2008, 04:19:58 pm »
Quote from: "tatamata"
Let's say you develop an application with Firebird embedded for Windows.
You created .exe to be distributed with Firebird embedded DLLs for Windows.
Your customers want it to be runnable on Linux.
OK, you can recompile your application on Linux, but what about Firebird embedded on Linux? What .so files to be distributed? Does it work without Firebird classic or superserver running in background? If not, then it is not true embedded solution....
Zlatko


It seems that a Classic Firebird server can be set up and used as an embedded server (I haven't tried this):

http://www.firebirdfaq.org/Firebird-Embedded-Linux-HOWTO.html

Adding SQL support to DBF means writing a full SQL engine because DBF so far only gives the minimal features of a SQL engines, that is storage plus limited indexing.
It's up to you to make a decision based on what features of a SQL engine you need, (ANSI SQL compliance, stored procedures, generators, triggers, relational integrity...) what degree of "embeddedness" you want, and the cost of writing such a beast by yourself.

Regards,

Gerard.

 

TinyPortal © 2005-2018