[Solved] Simple incrementing counter

Discuss the database features
Post Reply
dreamquartz
Posts: 881
Joined: Mon May 30, 2011 4:02 am

[Solved] Simple incrementing counter

Post by dreamquartz »

Hi All,

Can't seem to find a simple auto incrementing counter.
I have a table (tblServiceCounter) [see viewtopic.php?f=13&t=69091#p308127], where I need to auto increment a record, based on use.
Every time a Service is selected, the counter should increase with '1'.

Dream
Last edited by dreamquartz on Mon Apr 21, 2014 7:11 am, edited 2 times in total.
LO 7.x, HSQLDB 2.7.x & Ubuntu 22.04 LTS.
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Simple incrementing counter

Post by Villeroy »

Add the service to a table every time a service is used.

Code: Select all

CREATE TABLE "tblServiceUsage"(
  "SID" INT NOT NULL,
  "TS" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  "ID" INT GENERATED BY DEFAULT AS IDENTITY,
  FOREIGN KEY ("SID") REFERENCES "tblServices"("ID")
)
This records an automatic time stamp too. All you need is a "new records only form" with one list box of services.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
dreamquartz
Posts: 881
Joined: Mon May 30, 2011 4:02 am

Re: Simple incrementing counter

Post by dreamquartz »

Villeroy wrote:Add the service to a table every time a service is used.

Code: Select all

CREATE TABLE "tblServiceUsage"(
  "SID" INT NOT NULL,
  "TS" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  "ID" INT GENERATED BY DEFAULT AS IDENTITY,
  FOREIGN KEY ("SID") REFERENCES "tblServices"("ID")
)
This records an automatic time stamp too. All you need is a "new records only form" with one list box of services.
Thank you Villeroy,

I will investigate.
I am, however at this point, not quite sure what you mean by: "All you need..........", but I should be able to figure that out.

Keep you posted of the progress,

Edit: figured out what you meant by: "All you need..........".

OK.
Turns out that I did not ask the right question in the 1st place.
I thought I could make it into a separate topic, but apparently that does not work.
So, I will state this topic as [SOLVED] and will continue with viewtopic.php?f=13&t=69091 where this question originated.

So please, look at that topic to see if you can help me with the counter.

Dream.
LO 7.x, HSQLDB 2.7.x & Ubuntu 22.04 LTS.
Post Reply