Oracle NoSQL Error : [ILLEGAL_ARGUMENT] PUT: Illegal Argument: Value should not be set for a generated always identity column: id - oracle-nosql

I’m trying to update a row with the Node sdk and I keep getting Error: NoSQLArgumentError: [ILLEGAL_ARGUMENT] PUT: Illegal Argument: Value should not be set for a generated always identity column: id.
What am I doing wrong here?
async function update(id, data, table)
{
var timestamp = new Date
res = await client.putIfPresent(table, {
id: id,
last_modified: timestamp,
json_document: data
})
}

I've created this "Answer your own question" because the first time dealing with this error, I've decided to change ALL my code in order to use the SQL API and so use the UPDATE command. I was thinking that it was the only solution
It appears that you have created a table with an identity column for the field "id" and that you used "generate always." In this case, when you perform a put operation there must be no value set for "id" or you will get this error. Further, if you are trying to update (vs create) an existing row with an identity column you cannot use put() at all but must instead use an update query
In fact, We can use the command putIfPresent if the table was created using generate by default. In this case, the previous constraints will not apply
Oracle NoSQL supports the following options :
GENERATED ALWAYS AS IDENTITY
GENERATED BY DEFAULT AS IDENTITY
GENERATED BY DEFAULT ON NULL AS IDENTITY
Depending your requirements, this is interesting to know

Related

retrieve a record using Dynamics 365 Web API with empty alternate key

Problem
I'm trying to query records from Dynamics 365 using the Web API where a key attribute is null.
Approach
For testing purposes I created an entity with a string attribute, an integer attribute, and a decimal attribute. I then created an alternate key and put those three attributes in it, making this combination of attributes unique. I then created some records.
Querying the data using the Web API works as expected. I created a record with those values:
{
"my_string_key": "s1",
"my_integer_key": 1,
"my_decimal_key": 1.23
}
And query it like this:
/my_entities(my_string_key='s1',my_integer_key=1,my_decimal_key=1.23)
This returns the desired record.
However I can't get it to work when any of the key fields is empty, it always returns a 400 with message "Bad Request - Error in query syntax". Just for clarification: I purposely created records where one of the key attributes is empty, like this:
{
"my_integer_key": 1,
"my_decimal_key": 1.23
}
{
"my_string_key": "s1",
"my_decimal_key": 1.23
}
{
"my_string_key": "s1",
"my_integer_key": 1
}
Notice how each record is missing one of the key attributes, which effectively leaves it at null.
I tried using =null, =empty, ='', = and =Microsoft.OData.Core.ODataNullValue but nothing works. I tried to query them like this:
/my_entities(my_string_key=null,my_integer_key=1,my_decimal_key=1.23)
/my_entities(my_string_key='s1',my_integer_key=null,my_decimal_key=1.23)
/my_entities(my_string_key='s1',my_integer_key=1,my_decimal_key=null)
I also tried omitting the attribute with null in it, like this:
/my_entities(my_integer_key=1,my_decimal_key=1.23)
/my_entities(my_string_key='s1',my_decimal_key=1.23)
/my_entities(my_string_key='s1',my_integer_key=1)
None of this works. Can anyone provide a solution?
Final Words
I know that key attributes shouldn't be empty because that's not the point of key attributes. My scenario however requires to handle this specific case.
I also know that I could just use the $filter parameter, but I'd like a solution without having to resort to this "workaround". After all, it is a key and I'd like to treat it as one.
I think your efforts prove that key attributes cannot be empty. So, time for another approach.
Create a custom attribute and fill it with the combined values of the three key attributes. You can do this in a plugin registered in the pre operation stage of the Create and eventually Update messages of your entity.
Use the custom attribute as the key attribute.

Open formula doesn't return name

I have written open formula in Pentaho Report Designer 5.0.1 as:
=SINGLEVALUEQUERY("SELECT name FROM income_product where order_no=1";)
Rather than writing a query on data set and call from SINGLEVALUEQUERY() I want the string value from the above query.
PRD doesn't complain about the above formula as syntax error; it just returns null/nothing. What (if anything) is wrong in that formula?
I want to write that formula to generate dynamic column name for a report having order number 1 or greater. Is there any other way to make the column name dynamic for a report?
By "Dynamic column name", I mean making different organization have unique income_product_order.
If I just assign the order_no of income_product it automatically gets income_product_name as the column name for all organizations.
Did you set up your connection correctly? try adding a query over that connection and paste that query there. Does it return any data?
This is a good blog post on the subject: https://www.on-reporting.com/blog/using-queries-in-formulas-in-pentaho/
You can enable the "Display the index columns (...)" option under Settings. It'll allow you to reference columns either by name or by index (column0, column1, etc.)

Handling null values with PowerShell dates

I'm working on a module to pull data from Oracle into a PowerShell data table, so I can automate some analysis and perform various actions based on the results. Everything seems to be working, and I'm casting columns into specific types based on the column type in Oracle. The problem I'm having has to do with null dates. I can't seem to find a good way to capture that a date column in Oracle has a null value.
Is there any way to cast a [datetime] as null or empty?
Here's an easy function to test if a value from a database column is NULL:
function test-sqlnull{
Param($value)
return [System.DBNull]::Value.Equals($value)
}
If you need to store a null in a datetime field, just set it to [DBNull]::Value.
I think I have a solution that will work. Rather than attempting to set the field as null or empty, I'm not setting it at all. Now the empty value can be identified by checking if the file type is [System.DBNull].
$data | ? {$_.myDate.GetType() -eq [System.DBNull]}

ServiceNow Encoded Query validation

I intend to let users specify encoded query in ServiceNow SOAP requests.
The problem is that if user specifies invalid query string (e.g. "?##" or "sometext"), ServiceNow do not return any exception, but every row or no rows at all.
Is there a way to check validity of encoded query via webservice?
Fandic,
If you know ahead of time which table the SOAP query will be running against (or can get that information from the user when they submit the query) you can set up your own web service exclusively for checking the validity of a query string.
GlideRecord has the "addedEncodedQuery" method for putting in encoded queries, and it has a getEncodedQuery for turning the current query into an encoded string. If you instantiate a GlideRecord object, and pass it an invalid query string like this:
var myGR = new GlideRecord('incident');
myGr.addEncodedQuery('invalid_field_foo=BAR');
You can then call getEncodedQuery out to see if it is valid:
var actual_query = myGR.getEncodedQuery(); //sys_idNotValidnull
You shouldn't do simple comparison between the input and the output, as the API doesn't guarantee that a valid query will be returned as the exact same string as entered. It's better to simply validate that the actual_query does not equal 'sys_idNotValidnull'.
I always recommend enabling the system property 'glide.invalid_query.returns_no_rows' to avoid this effect. The property does just what it says. I never understood why you'd ever want to return all rows for an invalid query. I've seen a number of cases where developers had a query defect and never knew it since rows were coming back.
You can use the below code so that query will return the result only when it correct.
gs.getSession().setStrictQuery(boolean);
This overrides the value of system property :
glide.invalid_query.returns_no_rows
Reference : https://docs.servicenow.com/bundle/istanbul-platform-administration/page/administer/reference-pages/reference/r_AvailableSystemProperties.html
Check the property value glide.invalid_query.returns_no_rows. If it's true, the invalid query returns no rows. If false (or not available) it is ignored.
This can be overridden with gs.getSession().setStrictQuery(boolean); on a script-by-script basis.

Oracle: error while trying to use formulas

I created an element with an input value of type "Day" , when i write a formula i get this error.
Any idea what's wrong?
APP-FF-33232:
EATC_EXTRA_DAYS_ENTRY_EFFECTIVE_DATE_ENTRY_VALUE has null or not found allowed, but no
default set specified.
Cause: If a Database Item has
null allowed, or not found allowed,
then the item must also specify a
default set to be used to provide
default values in the event of these
occurring. The item named has one of
these conditions allowed, but the
default set column in the
FF_DATABASE_ITEMS table is null.
Action: Please refer to your
local support representative.
-
I'm not an expert in Oracle Apps (to say the least) but the error message is fairly clear. You - or someone - have written a Fast Formula which references a database column EATC_EXTRA_DAYS_ENTRY_EFFECTIVE_DATE_ENTRY_VALUE. Apparently this column can be nullable, in which case your Formula needs to provide a default value. Something like:
default for EATC_EXTRA_DAYS_ENTRY_EFFECTIVE_DATE_ENTRY_VALUE is 01-JAN-2010
Or perhaps you can use SYSDATE or CURRENT_DATE rather than a fixed value.
Solution to error: You called database item in Fast formula,
you need to initialize the date to specific date
alias EATC_EXTRA_DAYS_ENTRY_EFFECTIVE_DATE_ENTRY_VALUE as day
default for day is 01-jan-2010

Resources