Subject | RE: [firebird-support] editing a header/detail document. |
---|---|
Author | Sasha Matijasic |
Post date | 2008-08-31T00:04:12Z |
>Ok, so you need to lookup the documentation and demos for ibx components. Basically, study TDataSet descendant and TDataSource classes and learn how to connect visual components (like, TDBEdit, TDBGrid and such...) to them. Google it and you'll find examples and tutorials on the net.
> Hi Sasha, no offence at all. And though I've been working with FB for 4
> years
> now, It's true that I'm still a newbie in a lot of points. I use Delphi
> 6 & IBX
> and the database is FB2.1
>
> I don't understand why is that bad what I'm doing. But you may knowIf I understood you correctly you are constructing sql and sending it to the server. That code is not neccesary nor desired, because ibx components are already capable to do that for you. All you need is to write your query and if it's single table query without joins, you get automatic updates, inserts and deletes. No code at all.
> much more
> than I do, so it's very important to me to have your opinion. I'm
> curious: can
> you describe me (just the main steps, of course) how you edit a
> header/detail
> document? I'm interested in the detail records...
>
I never worked with ibx but all TDataSet descendants classes work the same way more or less, and all have those capabilites. Simple google search gave me this which could be a good read
http://www.ibphoenix.com/main.nfs?a=ibphoenix&s=1123813924:136594&page=ibp_ibx
> I like to open the document with the same form that I use to make a newIn this context, it does not matter what happens with a .doc file. It's a file, and we are talking database.
> one. I
> think that the concept is similar to what hapens when you open a .DOC
> with Word.
> Probably it has nothing to do with it (sorry if I'm wrong!) But what if
> you open
> a .DOC, change just a character and save it againg? Don't *all* the
> document is
> saved again? I'm just asking... I actually don't know what happens !
>
Never confuse a file with a table in relational database. Those are not the same and you can not treat them the same way. You must learn the basics of relational theory and how it applies to relational data. That applies to any RDBMS, not just firebird.
> By the way, I do not delete records constantly. The records are deletedThe sooner you change it, the better. Let me ask you a question, how many lines of delphi code do you have on your form to "save a document"? Btw, those quotes are on purpose, there are no documents in the database, and there is no saving. What you do have are tables, rows and columns, and commits ("save") and rollbacks ("cancel") of transactions. In my opinion, any database developer must understand those and what concepts do they represent.
> only
> when the user opens an existing document (lets say an invoice) changes
> someting
> and saves it. It's true, however, that if the only change whas the
> invoice date,
> all the detail is deleted and inserted again without changes. I could
> work on
> that. But if I'm totally out direction, I'd rather change everything.
>
If you generate a script (as you said in original question) you must be careful to escape strings and there is no way you're gonna work with binary blobs that way (you don't need them? Maybe you will some day and how will you handle them?)
You mention example of invoice as master table and its item details. What happens if your invoice get another details table, for example payment tracking? You need to write more code to handle that too.
It's a mess... you do not want any of that.
Google for examples, buy some delphi database books, find a mentor... those things are not hard, you'll soon be able to get done more with less code.
And when you figure out those, then you can really start learning about database and firebird. Believe me, there is a lot more than CRUD to databases and it takes years to master it, but it's a time well spent.
Sasha