Recent

Recent Posts

Pages: [1] 2 3 ... 10
1
Databases / Re: Database standards OR Am I doing this right?
« Last post by paweld on Today at 07:52:10 am »
The Zeos as of version 8 has a TZTransaction component. But also in SQL itself you can combine several queries into one, for example:
Code: SQL  [Select][+][-]
  1. BEGIN tran
  2. UPDATE tableA SET col1='aaa' WHERE id=1
  3. UPDATE tableB SET [DATE]=getdate() WHERE ida=1
  4. INSERT INTO history (ida, changes_date)
  5. SELECT 1, getdate()
  6. commit tran
Of course, the query can be more compiled and have some additional functions/procedures which can significantly increase the transaction time.
2
Databases / Re: Database standards OR Am I doing this right?
« Last post by cdbc on Today at 07:40:30 am »
Hi
I seem to remember, that Zeos uses (can use) 'automatic transactions', so he might run into a *snafu* there...
The /Select-hint/ is kind of what I was thinking about...
Regards Benny
3
Databases / Re: Database standards OR Am I doing this right?
« Last post by paweld on Today at 07:21:12 am »
It is normal that you can't write one record in two separate queries at the same time.
In general, the idea is that you should not keep the transactions open for a long time, but immediately after adding/modifying/deleting data close the transaction, then the record lock will be released and the second job will perform another data modification without any problem.
You can also set in MSSQL the amount of time the queries will wait for the lock to be released (LOCK_TIMEOUT https://learn.microsoft.com/en-us/sql/t-sql/statements/set-lock-timeout-transact-sql?view=sql-server-ver16), then if two programs call UPDATE of the same record, the application that did it second will wait the specified time, and if still the record locked then return an error.
But to start with, check if the database has indexes you can use. Because the lack of suitable indexes can strongly increase the execution time of each query.
And remember that each SELECT also waits for the release of the lock on the records it has to retrieve, but here you can use the WITH(NOLOCK) table hint ( https://www.sqlshack.com/understanding-impact-clr-strict-security-configuration-setting-sql-server-2017/ ), the use of which will not wait for the release of locks, but will retrieve the data immediately, and for the locked records the state of the data will be from before the transaction.
4
Third party / Re: Big Numbers Math
« Last post by iLya2IK on Today at 07:13:20 am »
Hello! Here is my approach :)

Code: Pascal  [Select][+][-]
  1. Program project1;
  2. // handles very large numbers
  3.  
  4. type
  5.   bignum = record
  6.     mant :Extended;
  7.     expn :uint64;
  8.     end;
  9.  
  10. var
  11. //  AA, BB, prod :bignum;  // test
  12.   i :uint32;
  13.   accum, multiplier :bignum;
  14.  
  15. //====================================
  16. procedure multiply( var A :bignum; B :bignum );
  17.   begin
  18.   A.mant *= B.mant;
  19.   A.expn += B.expn;
  20.   if (A.mant >= 10.0) then
  21.   begin
  22.     A.mant/=10.0;
  23.     Inc(A.expn);
  24.   end;
  25.   end;
  26.  
  27. const MAX_ORDER = 5;
  28. const dividers : array [0..MAX_ORDER] of extended   = (100000, 10000, 1000, 100, 10, 1);
  29. const exps     : array [0..MAX_ORDER] of integer    = (5,      4,     3,    2,   1,  0);
  30. const multip   : array [0..MAX_ORDER+1] of integer  = (999999, 99999, 9999, 999, 99, 9, 0);
  31. //=============== MAIN ===============
  32. var
  33.   m, mn:integer;
  34. begin
  35. accum.mant := 1;  // accumulates the product
  36. accum.expn := 0; //  set it to 1 to begin with
  37.  
  38. mn := multip[0];
  39. for i := 0 to MAX_ORDER do
  40. begin
  41.   m  := mn;
  42.   mn := multip[i + 1];
  43.   while (m > mn) do
  44.   begin
  45.     multiplier.mant := Extended(m) / dividers[i];
  46.     multiplier.expn := exps[i];
  47.     multiply( accum, multiplier );
  48.  
  49.     m := m - 2;
  50.   end;
  51.   writeln( i:7, ' acc=', accum.mant:0:20, 'x10^', accum.expn,
  52.              ' multi=', multiplier.mant:0:20, 'x10^', multiplier.expn );
  53. end;
  54.  
  55. // displaying the final answer:
  56. writeln( '        acc=', accum.mant:0:20, 'x10^', accum.expn,
  57.          ' multi=', multiplier.mant:0:20, 'x10^', multiplier.expn, ' <====' );
  58. end.
  59.                
  60.  

The result is:
(for original code)
acc=8.12013661044774699965x10^2782852 multi=1.00000000000000000000x10^0 <====
(for modified code)
acc=8.12013661044774706643x10^2782852 multi=1.00000000000000000000x10^0 <====
5
Windows / Re: Lazarus for Windows on aarch64 (ARM64) - Native Compiler
« Last post by dbannon on Today at 07:02:55 am »
The RPi Foundation specially "trimmed" and adapted Linux (Raspberry Pi OS) so that it could run on their board.

I use a plain debian, works at least as well as the "trimmed" one. Most of the trimming the Foundation does is undesirable IMHO.

But I would not see it as a desktop workstation replacement. However, thats not particularly relevant to the discussion, the ARM chips in Mac or those silly Surface things are far more powerful than the RasPi chips, they don't boot off a SDCard, they have decent  NVMe 'disks' attached, serious graphics hardware.

So, I think the OP's original question is valid. We support an Alpha chip running Tru64 but not the hardware/software combo anyone can buy in their local (computer) shops today ?

Makes me want to ask that question that will earn me a rebuke, is FPC development in trouble ? While Lazarus is booming ahead, FPC promised us a 3.2.4 release "soon" back in October 2021.

Davo
6
rpm: Failed  make: *** There are no rules for making target "rpm". Stop it.
deb: Failed ! /usr/bin/echo "Debian version (3.2.0) is not correct, expect 3.2.2"
inno: Not available on Linux
innox64: Not available on Linux

Building debs, rpms and using inno all require quite specific software tools on your system. Do you already have those things ? Without them, no chance of a build working. I don't think there is any reason to think that the average FPC user, you or me, would be attempting to use those "make targets".

I imagine the necessary build environment is documented somewhere, but again, not something you would find with understanding the process.

Davo
7
Databases / Re: Database standards OR Am I doing this right?
« Last post by cdbc on Today at 06:24:05 am »
Hi
@TRon: Primoz Gabrielski once wrote an interesting article in "The Delphi Magazine", about 'File-based Locking'.
Would have to sift through all the old magazines to find it, though  :P
Regards Benny
8
Databases / Re: Database standards OR Am I doing this right?
« Last post by TRon on Today at 06:16:49 am »
.. and might have to use critical sections, so that other uses may not access the same record whey you are doing something with a record. 
Critical sections apply to code in the same executable and usually when using multiple threads.
9
Databases / Re: Database standards OR Am I doing this right?
« Last post by cdbc on Today at 06:16:39 am »
Hi
It looks like a locking issue, so if the second /offender/ is *only* reading, it should work.
Can you, by any chance, make sure, that when you only want to read data, the 'ZQuery' is marked "ReadOnly" e.g.: via a property?!? _Live_ so to speak...
Regards Benny
10
Databases / Re: Database standards OR Am I doing this right?
« Last post by egsuh on Today at 05:53:03 am »
I do not know very much about this issue. AFAIK you should take care of transaction, and might have to use critical sections, so that other uses may not access the same record whey you are doing something with a record. 

https://www.freepascal.org/docs-html/prog/progse45.html
Pages: [1] 2 3 ... 10

TinyPortal © 2005-2018