I think I have an encoding problem that needs to be fixed.
Is there a way to compare strings across code pages?
Oracle returns a string "TEST - My String" with the minus sign encoded as ascii 63.
SQL Server quite correctly returns the string with the minus encoded as 45.
Is there a way to compare these strings?
Does the framework contain a comparison that is capable of ignoring code page mismatches.
Use one of the overloads of string.compare, probably:
if (string.Equals(value1, value2, StringComparison.OrdinalIgnoreCase))
{
...
}
More useful info here:
http://msdn.microsoft.com/en-us/library/dd465121.aspx
Related
In my bigquery table i have some string values that for some unkown reason to me show up like;
BIQUÃ\215NI or BRASÃ\u008dLIA.
I know Ã\215 and Ã\u008d are equivalent to "Í", but i can't find a way to convert them to i'ts equivalent inside my query, i don't want to do a replace for each value that appears like that inside my bank, and i can't find a way to convert them to it's text equivalent inside bigquery documentation.
I already tried FORMAT('%o', 215) but it only converts octal to byte and it only work`s with numeric tables.
I tried REGEXP_REPLACE too but can`t find a way to refer to all octal forms inside the strings.
By using this online tool, Ã\215 and Ã\u008d are equivalent to "Í". But when you put in BigQuery, both gave an "Ã" value as it reads à only and both \215 and \u008d are not used or simply don't have an equivalent.
The CAST() function can be simply used in converting these UTF-8 encoded values, but the query reads ISO 8859-1(Latin-1) Unicode Mappings, and as I stated earlier, it will only return a null value.
My take on this case, you can convert first using the tool that I mentioned, and find the right Unicode Hex in unicode mappings.
SELECT CAST('BIQU\u00cdNI' AS STRING) AS Converted
Whereas, \u00cd is equivalent to Í.
I have a parametrized SQL query that I want to execute from (local) R on Exasol database as described here:
https://db.rstudio.com/best-practices/run-queries-safely/#parameterized-queries.
with tab as
(select
t.*,
position(value in ?) as pos
from MY_TABLE t
)
select * from tab where pos > 0;
The value that is passed to ? is a (long) string. When this string is 2000 characters long or less, everything works fine. When I increase it to 2001 characters, I get an error:
Error in result_bind(res#ptr, as.list(params)) :
nanodbc/nanodbc.cpp:1587: 40001: [EXASOL][EXASolution driver]GlobalTransactionRollback
msg: data exception - string data, right truncation. (Session: 1640027176042911503)
I guess the source of the problem is that my parameter is recognized as CHAR and not as VARCHAR.
The Exasol User Manual states:
"The length of both types is limited to 2,000 characters (CHAR) and 2,000,000 characters (VARCHAR), respectively".
Is there any way to cast ? to VARCHAR?
If you establish your db connection via ODBC you could try having a look at these parameters:
MAXPARAMSIZE and DEFAULTPARAMSIZE.
Probably, if you set DEFAULTPARAMSIZE to a higher value in the odbc config:
https://docs.exasol.com/connect_exasol/drivers/odbc/using_odbc.htm?Highlight=varchar
The problem above has been present when I tried using the first suggested method for running parametrized queries described in tutorial here: https://db.rstudio.com/best-practices/run-queries-safely/. This first approach uses a combination of functions dbSendQuery() and dbBind().
My problem with long strings has been solved when I switched to the second (less safe) method which uses the sqlInterpolate() function.
I am using VBA in Ms Access environment, to handle long string (memo field storing HTML originally).
After positioning by Instr(), I put the position into Mid(vStr,vStartPos,vEndPos-vStartPos+1) to extract the string, but the output doesn't match. I have already carefully checked this in immediate windows, as well as NotePad++. What I can say is Instr() and NotePad++ have given the same counting result, while Mid() is different. Mid()'s result are former than Instr()'s in some cases, and latter in other cases. I don't know the reason, and can just believe Mid() use different mechanism or have defeative (surprised!) in handling long string mixed with single-byte and bi-byte chars (but this is common in the world, and meet no problem before), and possibly some special characters.
I believe I need to custom-make a Mid() function. Any idea how to do it effectively and efficiently?
Thanks all for your reply. After I created a custom Mid() by RegEx and find that the problem has no change, I have found out the silly mistake I made. The Instr() and Mid() have no problem, but the string has been carelessly modified between them. So this case should be closed now.
Question is in the title, how can I escape commas of a given decimal? Do I really need to workaround: get the value, convert it to String, replace commas with dots?
Is there a simpler solution to this? Or is there a good library or function I can use for this?
EDIT: I know I can enter values by replacing commas with dots. I'm asking for internal functions or external libraries for escaping SQL queries, as StringEscapeUtils in Java.
Having re-read your post it looks to me like the best way to be sure is to change the culture to en-US before you run your SQL statement. This will change all commas to dots in numbers. So something like
Thread.CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture("en-US");
It depends on the current culture. You're culture is using dot as a separator.
Consider this code where you provide a culture that uses comma as a separator:
var dec = "123,45";
decimal parsed;
decimal.TryParse(dec, NumberStyles.Any, new CultureInfo("es-ES"), out parsed);
I have a string data which I need to parse into a dictionary object. Here is my code:
NSString *barcode = [NSString stringWithString:#"{\"OTP\": 24923313, \"Person\": 100000000000112, \"Coupons\": [ 54900012445, 499030000003, 00000005662 ] }"];
NSLog(#"%#",[barcode objectFromJSONString]);
In this log, I get NULL result. But if I pass only one value in Coupons, I get the results. How to get all three values ?
00000005662 might not be a proper integer number as it's prefixed by zeroes (which means it's octal, IIRC). Try removing them.
Cyrille is right, here is the autoritative answer:
The application/json Media Type for JavaScript Object Notation (JSON): 2.4 Numbers
The representation of numbers is similar to that used in most programming languages. A number contains an integer component that may be prefixed with an optional minus sign, which may be followed by a fraction part and/or an exponent part.
Octal and hex forms are not allowed. Leading zeros are not allowed.