What's the right sintax to search for a X(6) format var in Progress 4gl? - progress-4gl

On the statement below I have an error telling me that attribute type is not compatible with. I consult database properties and this attribute format is x(6). Does anyone know which the right sintax to get it ?
P.s. I already tried = '1', EQ 1, EQ '1', = "1" and EQ "1"
FOR EACH bd.tablename WHERE bd.tablename.attribute = "1"

When you say property/attribute, do you mean a field? If you're talking about buffer/table attributes, such as type, for example, the separator should be colon, this -> :
Not period (.), unlike most other OO languages.
But if you're talking about a field, TheMadDBA is correct, and you should check the data type, it's way safer than just the field format.
If you still have this issue, maybe provide more information and we can try to help you further.

The code statement is:
FOR EACH multipos.mp_mvlj WHERE multipos.mp_mvlj.mvl_codmov = 1 NO-LOCK:
The error is (translated from portuguese):
Incompatible Data type in expression or attribution

Related

I need to change the output of a query so that instead of it coming back as the abbreviation 'em' it says 'employee'. Tsql

I have the correct result coming back. I just need to convert 6 abbreviations in that result to their correct names. There are 20k names assigned to 1 of 6 abbreviated names.
I tried aliasing but that seems to only work for table names.
I tried doing a case statement but that didn't work.
You need to provide more details (like some sample input and output), but if you have data like EM100, and you want to make it EMPLOYEE 100, then you could use an expression such as:
CASE WHEN ColumnName like 'EM%' THEN 'EMPLOYEE ' + SUBSTRING (ColumnName,3,100)
WHEN ColumnName like 'RN%' THEN 'REGNURSE' + SUBSTRING (ColumnName,3,100)
else ColumnName END
But providing more details will help provide a more specific answer.

Can I use rowmode: 'array' in combination with named parameters?

Is it possible to have rowMode: 'array' and named parameters at the same time? Right now, with the code below, I'm getting syntax error at or near "$"
db.query({
text: `
select task_nr, commitment
from surveys
where email = $<email> and id = $<id>
order by task_nr
`,
values: {email: email, id: id},
rowMode: 'array',
})
No, it is not possible, because rowMode is strictly part of the Parameterized Query, which by definition forwards query formatting to the driver->server where such thing as Named Parameters does not exist.
Unfortunately, if you really need to use rowMode, you can only use the basic $1, $2... variable formatting as supported by the server.
Strictly speaking, rowMode is not that valuable, it is fairly easy to reformat the data, and then just use pg-promise default formatting with all its nice formatting features.

Erlang mnesia equivalent of "select * from Tb"

I'm a total erlang noob and I just want to see what's in a particular table I have. I want to just "select *" from a particular table to start with. The examples I'm seeing, such as the official documentation, all have column restrictions which I don't really want. I don't really know how to form the MatchHead or Guard to match anything (aka "*").
A very simple primer on how to just get everything out of a table would be very appreciated!
For example, you can use qlc:
F = fun() ->
Q = qlc:q([R || R <- mnesia:table(foo)]),
qlc:e(Q)
end,
mnesia:transaction(F).
The simplest way to do it is probably mnesia:dirty_match_object:
mnesia:dirty_match_object(foo, #foo{_ = '_'}).
That is, match everything in the table foo that is a foo record, regardless of the values of the fields (every field is '_', i.e. wildcard). Note that since it uses record construction syntax, it will only work in a module where you have included the record definition, or in the shell after evaluating rr(my_module) to make the record definition available.
(I expected mnesia:dirty_match_object(foo, '_') to work, but that fails with a bad_type error.)
To do it with select, call it like this:
mnesia:dirty_select(foo, [{'_', [], ['$_']}]).
Here, MatchHead is _, i.e. match anything. The guards are [], an empty list, i.e. no extra limitations. The result spec is ['$_'], i.e. return the entire record. For more information about match specs, see the match specifications chapter of the ERTS user guide.
If an expression is too deep and gets printed with ... in the shell, you can ask the shell to print the entire thing by evaluating rp(EXPRESSION). EXPRESSION can either be the function call once again, or v(-1) for the value returned by the previous expression, or v(42) for the value returned by the expression preceded by the shell prompt 42>.

Display blank value ("") as date in SSRS

I have the column DiscontinuedDate with either a datetime or a blank value. I used the expression
FormatDateTime(Fields!DiscontinuedDate.Value, DateFormat.ShortDate)
To show the date time as just a date but then when the value is blank it shows as an error with the following message "Conversion from string "" to type 'Date' is not valid."
So i've been trying to use an IIF expression like the below:
=IIF(Fields!DiscontinuedDate.Value is "", "", FormatDateTime(Fields!DiscontinuedDate.Value, DateFormat.ShortDate))
I've tried a few variations but they all bring back the same error. Any ideas?
Thanks,
Adam
Your issue is that SSRS IIf expressions do not short circuit, so whenever you have a blank string your code will still be trying the FormatDateTime conversion, so you get this error even with your check.
You can add some logic to stop the empty string being evaluated in the FormatDateTime expression by using another IIf to change it to a NULL value, which won't fail:
=IIF(Fields!DiscontinuedDate.Value = ""
, ""
, FormatDateTime(IIf(Fields!DiscontinuedDate.Value = ""
, Nothing
, Fields!DiscontinuedDate.Value)
, DateFormat.ShortDate))
That solves your immediate issue, but assuming the underlying data is text based, I would also recommend looking at your underlying data and using explicit DateTime type data types instead of strings to prevent these at the lowest possible level.

Get statuscode text in C#

I'm using a plugin and want to perform an action based on the records statuscode value. I've seen online that you can use entity.FormattedValues["statuscode"] to get values from option sets but when try it I get an error saying "The given key was not present in the dictionary".
I know this can happen when the plugin cant find the change for the field you're looking for, but i've already checked that this does exist using entity.Contains("statuscode") and it passes by that fine but still hits this error.
Can anyone help me figure out why its failing?
Thanks
I've not seen the entity.FormattedValues before.
I usually use the entity.Attributes, e.g. entity.Attributes["statuscode"].
MSDN
Edit
Crm wraps many of the values in objects which hold additional information, in this case statuscode uses the OptionSetValue, so to get the value you need to:
((OptionSetValue)entity.Attributes["statuscode"]).Value
This will return a number, as this is the underlying value in Crm.
If you open up the customisation options in Crm, you will usually (some system fields are locked down) be able to see the label and value for each option.
If you need the label, you could either do some hardcoding based on the information in Crm.
Or you could retrieve it from the metadata services as described here.
To avoid your error, you need to check the collection you wish to use (rather than the Attributes collection):
if (entity.FormattedValues.Contains("statuscode")){
var myStatusCode = entity.FormattedValues["statuscode"];
}
However although the SDK fails to confirm this, I suspect that FormattedValues are only ever present for numeric or currency attributes. (Part-speculation on my part though).
entity.FormattedValues work only for string display value.
For example you have an optionset with display names as 1, 2, 3,
The above statement do not recognize these values because those are integers. If You have seen the exact defintion of formatted values in the below link
http://msdn.microsoft.com/en-in/library/microsoft.xrm.sdk.formattedvaluecollection.aspx
you will find this statement is valid for only string display values. If you try to use this statement with Integer values it will throw key not found in dictionary exception.
So try to avoid this statement for retrieving integer display name optionset in your code.
Try this
string Title = (bool)entity.Attributes.Contains("title") ? entity.FormattedValues["title"].ToString() : "";
When you are talking about Option set, you have value and label. What this will give you is the label. '?' will make sure that the null value is never passed.