Archive auto Primary Keys?
Re: Archive auto Primary Keys?
The Quanta archives hold some family tree programs running in Archive. There was also a version published in the QL-World exchange series. Several _dbf's were linked together. For that each person is identified by a unique number that is generated automatically in field one when a new individual is inserted.
The same way Marriages and Families records are numbered. This famarch.zip (18KB) - Family Archive database - might be worth a look.
https://dilwyn.theqlforum.com/database/index.html
BSJR
The same way Marriages and Families records are numbered. This famarch.zip (18KB) - Family Archive database - might be worth a look.
https://dilwyn.theqlforum.com/database/index.html
BSJR
Re: Archive auto Primary Keys?
Code: Select all
proc addEntry
cls
rem if count()=0: let RefNo=0: endif
display
last
let RefNo=RefNo+1
let dataval1$=""
append
display
alter
endproc
proc CreateDB
create "ram1_test_dbf"
RefNo
dataval1$
endcreate
endproc
proc openFile
open "ram1_test_dbf"
endproc
The secret lies in not using the INSERT command, rather ALTER.
In the routine above, the procedure CreateDB creates a database with two fields to play with - the first field is the Reference Number (RefNo) field, which increments by one for each entry added. The second is any old text field (dataval1$).
The routine assumes the database is held in order sorted by the reference number. Or could be assigned as the number of records already in the file possibly, if not already in order: let RefNo=count()
We jump to the end of the file, the displayed fields take the values of that record. We increment the value of the RefNo field and blank the data field and DISPLAY it with the new reference number token and blank text field. Now we APPEND that as the next new record in the database. Then ALTER it. Effectively an insert with a new system-generated auto-incrementing field value.
Now this may not necessarily be exactly what Sparrowhawk was trying to achieve, but it may give an idea for further developing as he required. Hope it's of some help.
--
All things QL - https://dilwyn.theqlforum.com
All things QL - https://dilwyn.theqlforum.com
- Sparrowhawk
- Super Gold Card
- Posts: 720
- Joined: Wed Dec 15, 2010 12:33 pm
- Location: @131072
Re: Archive auto Primary Keys?
Many thanks to everyone. This all looks rather promising Dilwyn, I'll certainly have a play, and look at the family tree one too.
I keep meaning to take a further look at dbas - I did skim the code examples very briefly over lockdown and also played around with it a few years back. Seems impressive. Will definitely look again.
SQLite (or even a more modest SQL engine) would be amazing though. Obviously lots of issues (quite apart from the porting ones) - for example, I've always wondered how one would map NULLs to S*BASIC. Probably have any SELECT query return both an array of results as strings, and also a binary string of which fields (based on ordinal position) are NULL, eg '0000010001' - 6th and 10th field is NULL?
Anyway, again, thanks for all he replies.
PS. I'd forgotten that Firebird was Interbase. Am I imagining it or would I have used Interbase with early Delphi for local dev? Seems to ring a vague bell.
I keep meaning to take a further look at dbas - I did skim the code examples very briefly over lockdown and also played around with it a few years back. Seems impressive. Will definitely look again.
SQLite (or even a more modest SQL engine) would be amazing though. Obviously lots of issues (quite apart from the porting ones) - for example, I've always wondered how one would map NULLs to S*BASIC. Probably have any SELECT query return both an array of results as strings, and also a binary string of which fields (based on ordinal position) are NULL, eg '0000010001' - 6th and 10th field is NULL?
Anyway, again, thanks for all he replies.
PS. I'd forgotten that Firebird was Interbase. Am I imagining it or would I have used Interbase with early Delphi for local dev? Seems to ring a vague bell.
Last edited by Sparrowhawk on Mon Nov 06, 2023 9:54 am, edited 1 time in total.
a.k.a. Jean-Yves
- Sparrowhawk
- Super Gold Card
- Posts: 720
- Joined: Wed Dec 15, 2010 12:33 pm
- Location: @131072
Re: Archive auto Primary Keys?
Ahah! I say I'll look at the family tree one, but of course I forgot that I am not currently a QUANTA member and so alas cannot access the library. But that's a whole other conversation of course 

a.k.a. Jean-Yves
Re: Archive auto Primary Keys?
The link I gave to Dilwyn's site is a program by Andy Carmichael who also wrote the one in QL-World's MDV Exchange so it's most likely the same program.Sparrowhawk wrote: Mon Nov 06, 2023 9:53 am Ahah! I say I'll look at the family tree one, but of course I forgot that I am not currently a QUANTA member and so alas cannot access the library. But that's a whole other conversation of course![]()
Having looked at the Quanta entries, these are based on many of the same Archive Procedures including the record numbering.
BSJR
Re: Archive auto Primary Keys?
Don't know how well it'd tie into what you wish to do in Archive, but it was the best I could come up with.Sparrowhawk wrote: Mon Nov 06, 2023 9:50 am Many thanks to everyone. This all looks rather promising Dilwyn, I'll certainly have a play, and look at the family tree one too.
--
All things QL - https://dilwyn.theqlforum.com
All things QL - https://dilwyn.theqlforum.com
- Sparrowhawk
- Super Gold Card
- Posts: 720
- Joined: Wed Dec 15, 2010 12:33 pm
- Location: @131072
Re: Archive auto Primary Keys?
Thanks, will investigate.BSJR wrote: Mon Nov 06, 2023 11:26 am The link I gave to Dilwyn's site is a program by Andy Carmichael who also wrote the one in QL-World's MDV Exchange so it's most likely the same program.
Having looked at the Quanta entries, these are based on many of the same Archive Procedures including the record numbering.
BSJR
a.k.a. Jean-Yves
-
- Font of All Knowledge
- Posts: 4684
- Joined: Mon Dec 20, 2010 11:40 am
- Location: Sunny Runcorn, Cheshire, UK
Re: Archive auto Primary Keys?
Hi,
With regards to sqlite, the main source code is merged into a single file, with is over 1mb in size, on compiling with C68, the source code is too large for the compilef to handle.
I supple QDOS-GCC would solve this, but I have got this to run, maybe the Docker version would do it, I will investigate this.
However, there is sqlite source code in a standard C format with all the fucyions as separate files, which I have managed fo compile most of the to an objecft format ready to be linked into an executable, this where a Make will help. So just got write makefile and it should compile.
There is an issue with the compiling of the FTS functions, which is FullText Search. I just need to see if this can be disabled.
With regards to sqlite, the main source code is merged into a single file, with is over 1mb in size, on compiling with C68, the source code is too large for the compilef to handle.
I supple QDOS-GCC would solve this, but I have got this to run, maybe the Docker version would do it, I will investigate this.
However, there is sqlite source code in a standard C format with all the fucyions as separate files, which I have managed fo compile most of the to an objecft format ready to be linked into an executable, this where a Make will help. So just got write makefile and it should compile.
There is an issue with the compiling of the FTS functions, which is FullText Search. I just need to see if this can be disabled.
Regards,
Derek
Derek
- NormanDunbar
- Forum Moderator
- Posts: 2470
- Joined: Tue Dec 14, 2010 9:04 am
- Location: Buckie, Scotland
- Contact:
Re: Archive auto Primary Keys?
Yes, all the Delphi releases came with, and still do AFAIK, Interbase.Sparrowhawk wrote:vPS. I'd forgotten that Firebird was Interbase. Am I imagining it or would I have used Interbase with early Delphi for local dev? Seems to ring a vague bell.
Cheers,
Norm.
Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.