Thanks for the answer, Villeroy, I understand that it would be better to use a different database design, to divide one complicated table into multiple simplier ones. Maybe I'll do it later.
Now, I don't have problems with adding redundant data. I asked question 1, because there is one "Universal" nutrition pack, which has the same compostion all the time. So I want to add this one with a simple click of a button. How can I add a current date there? What should I put as a value for date there?
Here is the code from the mentioned post:
Code: Select all
Sub Insert2Table
REM INSERT RECORDS INTO DATABASE TABLE
Dim Context
Dim DB
Dim Conn
Dim Stmt
Dim Result
Dim strSQL As String
Context=CreateUnoService("com.sun.star.sdb.DatabaseContext") '< get the database context
DB=Context.getByName("Vaky") '<- change database name
Conn=DB.getConnection("","") '<- username & password pair - HSQL default blank
Stmt=Conn.createStatement()
strSQL="INSERT INTO ""tbl-nov""(""Name"", ""Surname"", ""SubstanceA"", ""SubstanceB"",""SubstanceC"",""SubstanceD"") VALUES('UNI','vak','145','50','8','2')" '<- change tablename, column name/s and data to be inserted
Stmt.executeUpdate(strSQL) '<- update the inserted data
Conn.close() '<- close the db connection
End Sub
Ad. Question 2 : Is there a way to copy previous record in my "complicated" table, just with unique ID and date?
Thank you very much for your effort and time
Openoffice 3.4.1. on Windows 7