Eugénio Varejão wrote:
Hello!
I create a database for a list of products, the table with the products
is called Base, and have the following fields: ID, Sub-Familia, Marca,
Ref., Designação, Preço. Then I had created another table called Stock
with the following fields: ID, Ref., QUANT, LOCAL and have a
relationship between tables.
My idea was to relate the two tables and when I have a new product
create the record in Base table and automatically create a new record
with same ID and Ref. in table Stock, but this does not happen.
When I need to create a new record in the table Base I need to create a
new record in table Stock, and then update the other fields in this table.
Can the automatic update of the table Stock be done?
Regards,
Eugénio Varejão
Hello Eugénio,
A fairly often request it seems - unfortunately the answer is no -
unless you do a little coding. Depending on the database engine used
would determine exactly what kind of coding that is. I'll assume you are
working on a Base file with the embedded database tables. This would be
using the HSQLdb engine, by the way.
Here you are limited to one of two approaches. If you want to code this
at the table level - meaning that you could add a record to the "Base"
table and have a record inserted into the "Stock" table automatically -
then you would have to create a trigger for the "Base" table in a java
library. There are examples and template files for these triggers at the
HSQLdb.org website. ( as a side note to this, the HSQLdb team is slated
to release version 1.9 to alpha testing in the next 2 weeks - with this
new release one should be able to do this with a plSQL style statement.
Don't look for this new engine to be part of the Base package however
before release 3.0 of OO.o )
Alright the other option you have is to create a script and use this
script to perform the same actions. Doing this then you would tie the
script to a form and when that form is used to create a new record in
the first table it creates a record in the other.
Anyway what you are really talking abut here is a transaction and as it
happens there is an old post at OOoForum.org that goes into transactions
in Base. I think however I'll move it to the Community Forum and maybe
look at updating it with an example database.
So to start I have created the post at the OCF with the most of the
original, you can find it at:
http://user.services.openoffice.org/en/forum/viewtopic.php?p=5710#p5710
Over the next few days I'll try to flesh that out and put up a working
example.
Drew
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]