Recent

Author Topic: Dataset is read only  (Read 7806 times)

lwolynski

  • Newbie
  • Posts: 2
Dataset is read only
« on: October 26, 2017, 01:15:34 pm »
Hello there.

I have a program that needs to get data from three tables. I needed to use JOIN in SQLQuery but because of that the Dataset is read only and I can't edit anything.

How can I make it writable?

tudi_x

  • Hero Member
  • *****
  • Posts: 532
Re: Dataset is read only
« Reply #1 on: October 26, 2017, 01:40:15 pm »
hi,
could it work using a writable VIEW created with the query?
you could use a simple select * afterwards from the VIEW.
Lazarus 2.0.2 64b on Debian LXDE 10

Thaddy

  • Hero Member
  • *****
  • Posts: 14198
  • Probably until I exterminate Putin.
Re: Dataset is read only
« Reply #2 on: October 26, 2017, 05:20:55 pm »
Views are not writable.
Specialize a type, not a var.

korba812

  • Sr. Member
  • ****
  • Posts: 391
Re: Dataset is read only
« Reply #3 on: October 26, 2017, 05:25:56 pm »
Views are not writable.
depends on the database. eg firebird has updatable views:
https://www.ibphoenix.com/resources/documents/how_to/doc_401

Thaddy

  • Hero Member
  • *****
  • Posts: 14198
  • Probably until I exterminate Putin.
Re: Dataset is read only
« Reply #4 on: October 26, 2017, 06:16:02 pm »
Firebird is not a proper database engine. Never has been.
Maybe I am to strict, but view means view.
Specialize a type, not a var.

korba812

  • Sr. Member
  • ****
  • Posts: 391
Re: Dataset is read only
« Reply #5 on: October 26, 2017, 06:30:55 pm »
Firebird is not a proper database engine. Never has been.
I'm not sure what you mean. Could you explain?

Maybe I am to strict, but view means view.
I guess you are. It all depends on the database and the design assumptions.
https://en.wikipedia.org/wiki/View_(SQL)

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1106
Re: Dataset is read only
« Reply #6 on: October 26, 2017, 06:54:57 pm »
I have a program that needs to get data from three tables. I needed to use JOIN in SQLQuery but because of that the Dataset is read only and I can't edit anything.
How can I make it writable?

Start reading a similar topic:
[Solved] Help on Database Insert
http://forum.lazarus.freepascal.org/index.php/topic,38543.0.html

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1106
Re: Dataset is read only
« Reply #7 on: October 26, 2017, 07:15:43 pm »
Firebird is not a proper database engine. Never has been.

@Thaddy
Have you ever used Firebird?

I have been using it since 1991 in many companies and clients including, but not limited to, replacing big RDBMS such as Oracle, DB2, Sybase and MS SQL Server without performance loss, of course, in a proper hardware, sysadmin and DBA.
In all those years, what I see most is people wanting a tremendous performance without spending a penny in specialized manpower and huge modern expensive infra-structure...

Where can I learn about history of Firebird?
http://www.firebirdfaq.org/faq238/

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1106
Re: Dataset is read only
« Reply #8 on: October 26, 2017, 07:17:06 pm »
Maybe I am to strict, but view means view.
I guess you are. It all depends on the database and the design assumptions.
https://en.wikipedia.org/wiki/View_(SQL)

+1

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Dataset is read only
« Reply #9 on: October 26, 2017, 10:34:42 pm »
I have a program that needs to get data from three tables. I needed to use JOIN in SQLQuery but because of that the Dataset is read only and I can't edit anything.

How can I make it writable?
Depends on the database library you are using SQLDB, zeos etc but in general most of the libraries support it. In the SQLDB the SQLQuery component has 3 properties that are usefull for this situation.
1) SQL, 2)UpdateSQL and 3) InsertSQL. SQL, as you might have already found out is where you place your select query with its parameters. Insertsql is where you write your insert command to be executed on the server but instead of values you add the fieldname as parameters eg
Code: SQL  [Select][+][-]
  1. INSERT IN TO my TABLE (Field1, field2, field3, field4) VALUE (:Field1, :field2, :field3, :field4)
  2.  
The dataset it self will set the values for the Field parameters (they always start with then char ":") when a call to applyupdates is made.
The same logic extends to UpdateSQL as well but with an update statement instead. Pay attention to the readonly property of the dataset it must be false.

Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

ASerge

  • Hero Member
  • *****
  • Posts: 2222
Re: Dataset is read only
« Reply #10 on: October 27, 2017, 05:44:19 pm »
Firebird is not a proper database engine. Never has been.
Maybe I am to strict, but view means view.
Oracle is also not a proper database?
Quote
Users can query views, and with some restrictions they can perform DML on views.

 

TinyPortal © 2005-2018