I have a table scm.agreement_rebate where the column genericrx_percent is of type Decimal(18,4), and when I try to execute this statement
INSERT INTO scm.agreement_rebate (agreement_id, rebate_type_cd, genericrx_percent, percent_override,
monthly_fee, monthly_fee_override, percent_amount, sales_type_cd,
system_generated_flag, last_user_id, last_ts)
VALUES (43958, 192, 1000.0, NULL, NULL, NULL, 1.0, 154, 'N', 1, GETDATE())
I get the error
Msg 8115, Level 16, State 8, Procedure TRG_A_R_A_INS_A, Line 11
Arithmetic overflow error converting numeric to data type numeric.
The problem is definitely with the generixrx_percent column. If I change the value to 100.0, it works. As I understand the decimal data type, Decimal(18, 4) should give me 18 digits total, with 4 on the right side of the decimal.
What am I missing?
Good call, Shnugo. Turns out that even though I'm the sole developer, there were still some objects in there that I didn't have access to which were doing some funky things.
Related
I have date value stored in a format like this:
"timestamp": [
2020,
2,
14,
15,
45,
47,
8000000
]
I have no idea what this format is. I haven't found any solution on how to convert this array of numbers into a MySQL timestamp via MySQL tools. Could anybody give me a clue about it?
In MS Access , I have a field by name "TargetDays" that has values like "0", "13", 20", "6", "1", "9", ".""2", "28"
I want them to be sorted as
., 0, 1, 2, 6, 9, 13, 20, 28
I tried doing ORDER BY val(TargetDays)
But this sorts sometimes as ., 0, 1, 2, 6, 13, 20, 28. But other times it sorts as 0, ., 1, 2, 6, 13, 20, 28. The problem is coming with "." and "0".
Could someone please tell me a solution to sort in the intended order (as mentioned above)?
That happens because Val(".") and Val("0") both return 0, so your ORDER BY has no way to distinguish between those 2 characters in your [TargetDays] field ... and no way to know it should sort "." before "0".
You can include a secondary sort, based on ASCII values, to tell it what you want. An Immediate window example of the Asc() function in action ...
? Asc("."), Asc("0")
46 48
You could base your secondary sort on that function ...
ORDER BY val(TargetDays), Asc(TargetDays)
However, I don't think you should actually need to include the function because this should give you the same result ...
ORDER BY val(TargetDays), TargetDays
I am having a JSON array of numbers like [16, 9, 11, 22, 23, 12]. I would like to get the index of numbers within the array. For example is I say that I would like to have the index of 9, it should return 1.
I tried using below mentioned query in MySQL, but getting null.
SELECT JSON_SEARCH(CAST('[16, 9, 11, 22, 23, 12]' AS JSON),'one',9)
Do you guys have solution for this ?
CAST is not necessary here. But array values should be quoted as
JSON_SEARCH(json_doc, one_or_all, search_str[, escape_char[, path] ...])
Returns the path to the given string within a JSON document.
SELECT json_search('["16", "9", "11", "22", "23", "12"]', 'one', '9');
returns "$[1]"
I'm encountering an issue while develloping some report on RB.
I have a tablix that where the columns are the hours of the day, and the rows are different products. I also have a parameter with 3 values (AM, PM, NIGHT).
The point here is that if the parameter is set to AM, the tablix only display columns from 6 to 12, if it's set to PM, the tablix display from 12 to 18,...
I can display time intervals (6 to 12) by using filter where i tell him "Hour" IN "6, 7, 8, 9, 10, 11, 12". But it doesn't work when i set the filter value as following:
Expression: =Cstr(Fields!ProdHour.Value)
Operator: IN
Value:
=iif(join(Parameters!Shift.Value) = "AM",
"6, 7, 8, 9, 10, 11, 12" ,
iif(join(Parameters!Shift.Value) = "PM",
"13, 14, 15, 16, 17, 18",
iif(join(Parameters!Shift.Value) = "NIGHT",
"19, 20, 21, 22, 23, 0",
false)
)
)
Do you have any idea how I could solve this? Tried to change every number in Integer but didn't work...
I found a working solution:
I had to create 2 new fields in the same dataset as the table,I named those fields "ShiftStart" and "ShiftStop".
ShiftStart value : =iif(join(Parameters!Shift.Label)="AM","6",iif(join(Parameters!Shift.Label)="PM","12",iif(join(Parameters!Shift.Label)="NIGHT","0","0")))
Same with ShiftStop but with others values (12,18,0). So with those 2 data, when I pick "AM", ShitStart= 6 and ShiftStop=12, now i can create a filter to display columns where [Hour] is between [ShiftStart] and [ShiftStop].
Simple as that!
Thanks guys for you help! Sorry I can't Uptvote you, not enough reputation :(
I would suggest change the binding of your parameter like (ID,Value) see screen shot below
Now you can use the expression to get selected value
=Parameters!ReportParameter1.Value
You can also use below query to bind your dropdown, if don't want to hard code
Select ID,Value From
(Values('6,7,8,9,10,11,12','AM'),
('13,14,15,16,17,18','PM'),
('19,20,21,22,23,0','Night'))
tblTime(ID,Value)
I think that is what you are looking for
I would abandon using the In operator in the SSRS Filter Expression. I have only had universally bad experiences with Filters using any operator apart from "=" and also issues with datatypes.
My preference would be to filter this data out in the dataset query using SQL. However that is not the question.
In SSRS Filters, from hard experience, I now only always set datatype: "Boolean", operator: "=" and Value: "True". Then your challenge is to code an expression that only returns True for the rows you want to keep.
That could be something like:
=Iif ( ( Parameters!Shift.Value = AM and ("6,7,8,9,10,11,12").Contains(Fields!Hour.Value) )
Or ( ...
Is the Shift parameter multi-select?
I have a struct, where one of the fields was declared as String, but it was intended to store a Time. Therefore I changed it to *time.Time (see the commit), note the use of a pointer to bypass the issue where ",omitempty" doesn't really omit the value in case of an blank date.
So far so good. The problem is that now I'm trying to write a code that tests the correct deserialization of the JSON string, but I can't compare the result with
want := Record{Id: 1539, UpdatedAt: time.Date(2014, 01, 15, 22, 03, 04, 0, time.UTC)}
because UpdatedAt is expected to be a pointer *time.Time, whereas time.Date returns a time.Time.
I can't use
want := Record{Id: 1539, UpdatedAt: &time.Date(2014, 01, 15, 22, 03, 04, 0, time.UTC)}
because it is indeed rejected (it expects a pointer, I try to assign a struct)
cannot take the address of time.Date(2014, 1, 15, 22, 3, 3, 0, time.UTC)
Here's my question. Is there a way to create a Record with a time.Date on the fly (hence without assigning the time.Date to a variable and then get the pointer) and/or a workaround for the issue that guarantees I can have a proper nil value assigned when the object is serialized/deserialized and the date is blank?
You can't take the address of a function return value because you can only take the address of something that can be assigned to.
Think of it this way: if you store the result in variable, you can then take the address of that variable, but if you don't, then there's nothing you can take the address from.
You want to store the date value in a variable first and then use the pointer of the variable.
myDate := time.Date(2014, 01, 15, 22, 03, 04, 0, time.UTC)
want := Record{Id: 1539, UpdatedAt: &myDate}
Just for the record, you can define a function like this:
func toTimePtr(t time.Time) *time.Time {
return &t
}
And then do that:
want := Record{Id: 1539, UpdatedAt: toTimePtr(time.Date(2014, 01, 15, 22, 03, 04, 0, time.UTC))}
You cannot take the address of literals as they get inlined in the code (at least that's my current understanding of the reason).
I often have the following in my test code:
func literalAddressProvider[T any](s T) *T { return &s }
which works for any type (well, all those I have tried so far!). Eg string and time.Time.
You can also use the ToPtr() function of the lo package on github (over 9k stars as I'm writing this post). This works the same, you can write ptr := lo.ToPtr("hello world") (the go compiler is able to infer T as string so no need to specify it, contrary to the many examples that appear in the lo package docs).