Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Databases
»
SQLite3 Relational bases
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
IRC channel
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Demo Scene Picture sinwav...
by
Gigatron
[
Today
at 12:48:52 am]
open dialog - default dir...
by
KodeZwerg
[
Today
at 12:34:53 am]
Can function be used for ...
by
jamie
[
Today
at 12:26:42 am]
DbGrid, grid column check...
by
KodeZwerg
[
Today
at 12:08:29 am]
Colore celle StringGrid
by
JuanBell
[April 24, 2024, 10:37:56 pm]
Likely bug
by
440bx
[April 24, 2024, 10:12:59 pm]
Any upgrades to fpWeb pag...
by
verasan
[April 24, 2024, 10:11:46 pm]
Web Applications with Pas...
by
Handoko
[April 24, 2024, 08:56:29 pm]
AI, NLP and CAI: Text Gen...
by
indydev
[April 24, 2024, 08:54:00 pm]
Offical launch of the 1 B...
by
Gustavo 'Gus' Carreno
[April 24, 2024, 08:48:22 pm]
Multidimensional arrays a...
by
KodeZwerg
[April 24, 2024, 08:34:38 pm]
Ho Ho Ho IntraWeb in Laza...
by
Thaddy
[April 24, 2024, 08:31:29 pm]
[SOLVED] System.Now gives...
by
alpine
[April 24, 2024, 08:29:19 pm]
Installing and using Vamp...
by
Odacir
[April 24, 2024, 07:58:22 pm]
Demo Scene Bitmap Font Sc...
by
KodeZwerg
[April 24, 2024, 07:21:14 pm]
what's difference between...
by
ASerge
[April 24, 2024, 07:09:52 pm]
splitting an image
by
KodeZwerg
[April 24, 2024, 07:07:21 pm]
Debugger error
by
bobonwhidbey
[April 24, 2024, 07:03:07 pm]
How to: create DLL file f...
by
paule32
[April 24, 2024, 07:02:31 pm]
Your best UI design - con...
by
circular
[April 24, 2024, 06:48:12 pm]
Converting a string/index...
by
1HuntnMan
[April 24, 2024, 06:35:19 pm]
Drawing grid lines on a t...
by
KodeZwerg
[April 24, 2024, 05:42:19 pm]
Compile/Convert Delphi pr...
by
Martin_fr
[April 24, 2024, 05:29:03 pm]
Lazarus features in a non...
by
Lutz Mändle
[April 24, 2024, 05:26:34 pm]
Lazarus for Windows on aa...
by
msintle
[April 24, 2024, 05:03:57 pm]
« previous
next »
Print
Pages: [
1
]
2
Author
Topic: SQLite3 Relational bases (Read 15004 times)
Pe3s
Hero Member
Posts: 533
SQLite3 Relational bases
«
on:
December 16, 2021, 09:21:17 pm »
Hello, where can I find an example of a SQLite relational database written in lazarus?
Logged
af0815
Hero Member
Posts: 1291
Re: SQLite3 Relational bases
«
Reply #1 on:
December 17, 2021, 08:21:23 am »
Is something unclear with
https://wiki.freepascal.org/SQLite
,
https://wiki.freepascal.org/TSqlite3_Master_Detail_Example
and some more site ? found with searchin on google with lazarus wiki sqlite
and in the wiki is a tutorial
https://wiki.freepascal.org/SQLdb_Tutorial1
«
Last Edit: December 17, 2021, 08:23:26 am by af0815
»
Logged
regards
Andreas
Pe3s
Hero Member
Posts: 533
Re: SQLite3 Relational bases
«
Reply #2 on:
December 18, 2021, 11:30:26 am »
Do I need to duplicate components when creating a relational database?
Logged
JanRoza
Hero Member
Posts: 672
Re: SQLite3 Relational bases
«
Reply #3 on:
December 18, 2021, 05:29:33 pm »
What components are you talking about?
Normally for databases you need one connection, one transaction and one or more queries per table in that database.
Logged
OS: Windows 10 (64 bit) / Linux Mint (64 bit)
Lazarus 3.2 FPC 3.2.2
CodeTyphon 8.40 FPC 3.3.1
Pe3s
Hero Member
Posts: 533
Re: SQLite3 Relational bases
«
Reply #4 on:
December 19, 2021, 01:06:15 pm »
How do I build a SELECT query to display the entire contents of both tables?
Logged
JanRoza
Hero Member
Posts: 672
Re: SQLite3 Relational bases
«
Reply #5 on:
December 19, 2021, 03:06:24 pm »
Something like SELECT * FROM table2 WHERE field1 = table1.field1
Not sure what you want exactly but I think the SQL JOIN is what you are looking for.
I advise you to visit W3schools website
https://www.w3schools.com/sql/
, they have tutorials for almost anything you can do with SQL.
«
Last Edit: December 19, 2021, 03:11:13 pm by JanRoza
»
Logged
OS: Windows 10 (64 bit) / Linux Mint (64 bit)
Lazarus 3.2 FPC 3.2.2
CodeTyphon 8.40 FPC 3.3.1
Pe3s
Hero Member
Posts: 533
Re: SQLite3 Relational bases
«
Reply #6 on:
December 19, 2021, 04:09:29 pm »
I want to combine these two queries
Code: Pascal
[Select]
[+]
[-]
SQLQuery1
.
SQL
.
Text
:
=
'SELECT * FROM table'
;
SQLQuery2
.
SQL
.
Text
:
=
'SELECT * FROM table_1 WHERE table_1.Col_id = :id'
;
«
Last Edit: December 19, 2021, 04:19:08 pm by Pe3s
»
Logged
JanRoza
Hero Member
Posts: 672
Re: SQLite3 Relational bases
«
Reply #7 on:
December 19, 2021, 04:56:08 pm »
Like I already mentioned, check out the SQL JOIN statement.
Logged
OS: Windows 10 (64 bit) / Linux Mint (64 bit)
Lazarus 3.2 FPC 3.2.2
CodeTyphon 8.40 FPC 3.3.1
balazsszekely
Guest
Re: SQLite3 Relational bases
«
Reply #8 on:
December 19, 2021, 05:04:48 pm »
@Pe3s
Quote
Like I already mentioned, check out the SQL JOIN statement.
Take a look at the union command, column count from table and table_1 must be the same. A better approach would be something like this:
Code: MySQL
[Select]
[+]
[-]
SQLQuery1.SQL.
Text
:=
'select tb.id, tb.firstname, tb.lastname, tb.salary from table tb'
+
'union '
+
'select tb
_
1.id, tb
_
1.firstname, tb
_
1.lastname, tb
_
1.salary from table
_
1 tb
_
1 where tb
_
1.id = :id'
;
«
Last Edit: December 19, 2021, 05:07:36 pm by GetMem
»
Logged
JanRoza
Hero Member
Posts: 672
Re: SQLite3 Relational bases
«
Reply #9 on:
December 19, 2021, 06:49:18 pm »
Thanks GetMem, even better.
Logged
OS: Windows 10 (64 bit) / Linux Mint (64 bit)
Lazarus 3.2 FPC 3.2.2
CodeTyphon 8.40 FPC 3.3.1
Pe3s
Hero Member
Posts: 533
Re: SQLite3 Relational bases
«
Reply #10 on:
December 21, 2021, 10:44:53 am »
Thank you
Logged
Pe3s
Hero Member
Posts: 533
Re: SQLite3 Relational bases
«
Reply #11 on:
December 21, 2021, 10:48:58 am »
I still have a question, how can we update the data in the table, e.g. after deleting the record, we are alive select or can we refresh the view differently?
Logged
paweld
Hero Member
Posts: 1003
Re: SQLite3 Relational bases
«
Reply #12 on:
December 21, 2021, 11:49:24 am »
Code: Pascal
[Select]
[+]
[-]
SQLQuery1
.
Refresh
;
Logged
Best regards / Pozdrawiam
paweld
Pe3s
Hero Member
Posts: 533
Re: SQLite3 Relational bases
«
Reply #13 on:
December 21, 2021, 04:53:57 pm »
Why is SQLQuery1.Refresh; causes an error Operation cannot be performed on an inactive dataset.
Logged
JanRoza
Hero Member
Posts: 672
Re: SQLite3 Relational bases
«
Reply #14 on:
December 21, 2021, 05:22:31 pm »
I think you will have to show some code of how you delete and then refresh your table.
Now we can only guess.
Logged
OS: Windows 10 (64 bit) / Linux Mint (64 bit)
Lazarus 3.2 FPC 3.2.2
CodeTyphon 8.40 FPC 3.3.1
Print
Pages: [
1
]
2
« previous
next »
Lazarus
»
Forum
»
Programming
»
Databases
»
SQLite3 Relational bases
TinyPortal
© 2005-2018