Auto Calculated Field on Firebird 1 with ZeosLib does not get calculated - delphi

Delphi XE2 + Zeos 7.0.3 Stable + Firebird 1.0
I am porting an old app from Delphi 5 + IBX and got this problem:
I have a table that one for the fields is auto calculated:
NUMERIC(18,2)
COMPUTED BY (( (VAL_ITENS +
VAL_SERVICO +
TAXAENTRADA +
VAL_COUVERT +
VAL_ESTACION +
VAL_CONSUM +
VAL_TAXA-DESCONTO_V) - ((VAL_ITENS*DESCONTO_P)/100)))
On IBX it is calculated fine. On ZeosLib it does not get calculated. Using the same database file and server.
Is there a way to force this calculation to happen? I have tried to update the field by program, however it is read only.
ANSWER: I had some problems with Zeos and Firebird, so I was thinking ALL the problems were related to Zeos, and this is not the case, the problem is that one of the fields were NULL and the result was getting calculated as NULL.

Related

How do I use datatable data in a variable for writing to a file?

I'm grabbing some data off of webpages and trying to concatenate with some data pulled from other pages but keep getting the error that the data-tables need to be the same size. What am I missing here?
The datatables are myCoID (just a string) and NumStaff and NumClients- each of which has 1 row and 1 column. I've tried almost every permutation of
%myCoID + NumStaff + NumClients%
%myCoID + NumStaff[0] + NumClients[0]%
%[myCoID + NumStaff + NumClients]%
Where am I going wrong?

Swift InputStream status does not match any possible enum values

I have an InputStream in my iOS app (Swift 4) and check the status a few seconds after opening it. The returned value is 7
print(String(self.inputStream!.streamStatus.rawValue)) // prints 7
But there is no corresponding entry with the value 7 in the enum described in the docs: https://developer.apple.com/documentation/foundation/stream.status
How can the value be 7? How can I get a textual representation of the status?
My guess was that the 7 is maybe a combination of other values that can be obtained by interpreting the 7 binary and looking which bits are 1. So in this case the first 3 bits are 1 (decimal 1,2,4) and they belong to (opening=1, open=2, writing=4). But this seems strange to me
EDIT: As Martin said in the comments, 7 is error.

ActiveRecord limit(7) - should always pull 7

I have the following rails query:
#related_products = #taxon.products.offset(rand(Spree::Product.count)).limit(7)
And sometime it outputs 7 and sometimes it will output less, but when it outputs less it messes up the styling. Anyway to make it always output 7 and only 7?
Thanks!
That's because the offset that you are choosing has the possibility of being less than 7 away from the last record. Instead force the offset to max out at 7 below the maximum:
#related_products = #taxon.products.offset(rand(Spree::Product.count - 7)).limit(7)

dbExpress and SQL Server 2008 slow

I recently migrated from Delphi 7 with SQL Server 2000 to Delphi 2010 with SQL Server 2008. I am using dbExpress.
After installing the new version I have found that the on sites that have a lot of data that system has become slow and unstable.
Can any one tell me if there is an issue between dbExpress and SQL Server 2008? Please help!!!!!
By performing a profiler trace you can see if you have any bottlenecks on SQL Server. Your default profiler trace (include TextData for RPC:Completed) should be good enough to start with.
The profiler trace can be analysed to see what takes the longest time. You can easily load the trace into a table and analyse it there. Note that when loaded into a table, the duration column is in microseconds. See the function fn_trace_gettable for a quicker way of loading a trace file into a table.
A common cause for poor performance, especially after a major change, is bad indexing.
Since SQL Server 2005 the optimiser stores within in-memory structures the indices it would like to have seen. These can be accessed with the dynamic management views sys.dm_db_missing_index_details, sys.dm_db_missing_index_groups and sys.dm_db_missing_index_groups_stats.
Here is a simple sample SQL to create your own missing index report, including the basic code to generate the missing index.
select
d.statement
, d.equality_columns
, d.inequality_columns
, d.included_columns
, s.user_seeks Seeks
, s.last_user_seek
, cast (s.avg_total_user_cost as decimal (9,2)) Cost
, s.avg_user_impact [%]
, 'CREATE INDEX MissingIndex_ ON ' + d.statement + '('
+ case when equality_columns IS NOT NULL then equality_columns else '' end
+ case when equality_columns IS NOT NULL AND inequality_columns IS NOT NULL then ', ' else '' end
+ case when inequality_columns IS NOT NULL then inequality_columns else '' end
+ ')'
+ case when included_columns IS NOT NULL then ' INCLUDE (' + included_columns + ')' else '' end
AS SQL
from sys.dm_db_missing_index_details d
INNER JOIN sys.dm_db_missing_index_groups g ON d.index_handle = g.index_handle
INNER JOIN sys.dm_db_missing_index_group_stats s ON g.index_group_handle = s.group_handle

Ctrl+- (Ctrl+Hyphen-Minus) as ShortCut Key?

It might seem natural to use Ctrl + +, Ctrl + -, and Ctrl + 0 as shortcuts for an application's zoom in, zoom out, and restore default zoom (typically 100 %) actions. Now, in Delphi, I am able to assign Ctrl + + and Ctrl + 0 as shortcuts. The former, though, requires that the plus sign of the main part of the keyboard is used; the plus sign of the numerical keypad cannot be used.
Problem arises, however, when I want to assign Ctrl + - as a shortcut. It simply doesn't work. If I assign "Ctrl+-" in the IDE, the value stored in the ShortCut property is 16495. If we subtract ssCtrl from this, we obtain 111. A work-around, one would believe, would be to assign ShortCut := 45 + ssCtrl, or, equivalently, ShortCut := Menus.ShortCut(45, [ssCtrl]), because ord('-') = 45. But that doesn't work.
However, I have found a working solution: ShortCut := 189 + ssCtrl. I choose 189 because that is the number I receive when I depress the "-" key and listen to the KeyDown event.
So, why am I not happy with this? Well, I am afraid that the constant 189 only is valid on Swedish keyboards. I have tried to read about this, and, as usual, the MSDN documentation is rather clear, but then, who knows how Delphi handles things.
The key code 189 is VK_OEM_MINUS in Windows.pas, so your solution isn't just for Swedes.
the correct to use menu shortcut on the numeric pad is
CtrlNum + for the [+]
CtrlNum - for the [-]
there is a space between Num + and Num -
I'm not sure why you're getting 16495 for Ctrl + -. When I add that shortcut to an action, it gives me 16573, and it does show up on the menu as Ctrl + -, and that shortcut does work.
However, you are correct that Menus.ShortCut(ord('-', [ssCtrl]) does not work. It gives the value 16429 and shows up on the menu as Ctrl + Ins, and Ctrl + Ins works as the shortcut.
Maybe this is a problem with Delphi 2009 and later since they added Unicode.

Resources