I am using line protocol to write simple data as shown below into Influx DB.
interface1,KEY=bytes_allocated,fieldname=KV datavalue=761
Above statement is working fine,now,
If the data value contains any alphabet it gives error.
interface1,KEY=bytes_allocated,fieldname=KV datavalue=761A
Error i am getting is
Failed to write: {"error":"unable to parse
'interface1,KEY=bytes_allocated,fieldname=KV datavalue=761A': invalid number"}
Wondering how can i write "761A" into DB? or force influxDB to consider 761A as string value instead of number?
If you want a field value to be treated as a string, it must be wrapped in "s.
For example
interface1,KEY=bytes_allocated,fieldname=KV datavalue="761A"
Related
Is it possible to pass table as input parameter in Monetdb function/procedure?
I tried prepare statement but was not able to get it working.
Also it would be nice to get statementid returned directly by 'prepare' statement rather then query sys.prepared_statements
No, you cannot pass (table) identifiers to functions/procedures.
You could use this trick, but I wouldn't recommend it for production use.
I need to encrypt data saved onto my DB. I am currently using spring and hibernate to save data.
I have looked at some materials and tried to implement the code, however, it has resulted in various generic errors, some of the material was not targeted to MySQL etc.
Here's the code that has got me furthest
#Column(name="disability_description")
#Length(max=500)
#ColumnTransformer(
read = "AES_DECRYPT(disability_description, 'mykey')",
write = "AES_ENCRYPT(?, 'mykey')"
)
private String disabilityDescription;
This, however, doesn't work as I get the following errors
org.hibernate.exception.GenericJDBCException: could not execute statement
java.sql.SQLException: Incorrect string value: '\xF9\x82u\x01\x99\x1A...' for column 'disability_description' at row 1
Please point in the right direction. I am lost. Also mykey doesn't point to anything, I just entered a random word.
I doubt that your column is not of type BINARY:
Mysql Doc:
AES_ENCRYPT() encrypts the string str using the key string key_str and
returns a binary string containing the encrypted output.
Given the CSV input file below:
name,amount
Abc,"1,234.56"
Def,"2,222,222.222222"
The amount field contains decimal number with comma. How to parse it into a number in NiFi? I don't want to parse it into a string.
I thought of using the UpdateRecord processor, Expression Language, and Java's NumberFormat to parse it, but it seems that NumberFormat is inaccessible from Expression Language. Alternatively, I want to use ScriptedRecordSetWriter to parse, but couldn't find any working example out there.
Appreciate any help especially with a working example.
When we are reading the incoming data we still needs to use String type(as the data is enclosed in ") while writing out the data from UpdateRecord processor we can use int/decimal types to write the output flowfile records.
1. Using Record Path Value:
You can read the incoming data as String datatype, Output flowfile will have integer type defined() and using UpdateRecord processor replace the ',' with ''
Add new property in UpdateRecord processor as
/amount
substringBefore(replace(/amount,',',''),'.')
Now the output flowfile will have integer datatype for the amount field.
2. Using Literal Value:
If we are using literal value we can use NiFi expression language functions on field.value by using replace and toNumber functions we are able to get int value for amount field.
Both ways we are going to get output flowfile in json format as
[{"name":"Abc","amount":1234},{"name":"Def","amount":2222222}]
In the same way if you want to have decimal as output flowfile type define avro schema with decimal type and don't use substringBefore and toNumber functions.
In Jmeter , I have created a DB connection with Oracle, and executing below query.
select address , city , zip from table where city='Delhi';
Now this is giving result as:
212 Kamla nagar Delhi 11011
Now I want to use this into 3 variable using regular expression and pass all these 3 parameters to another soap request.
I tried to use regular expression as (\d+) but it only stored value in variable 1.
How to extract values and use them in another request?
you can use JDBC preprocessor and from which you use either Variable names or Result variable name
The ones you specify in the Variable names box map to individual columns returned by your query and these you can access by saying columnVariable_{index}.
OR
The one you specify in the Result variable name contains the entire result set and in practice this is a list of maps to values. The above syntax will obviously not work in this case. you will have to access it by BeanShell and create variables.
...and then you can use these variables as ${name_1}, ${city_1}, ${zip_1} in soap request to access value from DB. or as ${name}, ${city}, ${zip} if you use Result variable name object
Configure your JDBC Sampler as follows:
i.e. add the next line to "Variable Names" input:
address, city, zip
You will be able to access the extracted values as:
${address_1}
${city_1}
${zip_1}
later in the script. 1 stands for Result Set row, i.e. if there will be 2 rows in JDBC response - ${address_1} will stand for 1st row address, ${address_2} - for 2nd row address, etc.
See Debugging JDBC Sampler Results in JMeter article for details.
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.