Kentico Import Toolkit 9.0 - special-characters

We have been using Kentico Import Toolkit v9.0 to import some of the legacy data from the SQL Server 2008 R2 into the newly created proprietary (Kentico Custom tables).. and at one step, the CMS query is NOT ABLE to handle the SQL Server comparison (with an apostrophe in the string value).. Is there anything in the Tookit that can help overcome that kind of handling? We would not want to alter the source (legacy) data as a text without an apostrophe will likely alter the meaning of the text itself!
A sample query is as below:
SELECT NodeID FROM View_CMS_Tree_Joined WHERE ClassDisplayName ='Custom Table Name' and NodeName =
'Alzheimer's Disease' (as an example)
Your help is much appreciated! The key ask is how and where can we ESCAPE apostrophe in the CMS query, while inside the Kentico Import Tool?

Try escaping the single quote in the string by repeating it:
SELECT NodeID FROM View_CMS_Tree_Joined WHERE NodeName = 'Alzheimer''s Disease'
Hope this helps;

If you're using display names, you need to convert them to code names. Code names don't allow you to use special characters like single and double quotes. Typically underscores and dashes are about it aside from alpha/numeric characters.
If you can modify the WHERE statement make sure to escape your quotes when writing the query.

Related

"sqlLike" and "sqlLikeCaseInsensitive" escape character?

Is there any way to escape SQL Like string when using "sqlLike" and "sqlLikeCaseInsensitive"?
Example: I want a match for "abc_123". Using "_______" (7 underscores) would also return "abcX123", how can I enforce "_" as the 4th character?
If you issue the query in persistence, this is actually not a mdriven issue but an SQL issue as mdriven converts the Expression into SQL. So if you really want to restrict the results to underscores only take a look to this question:
Why does using an Underscore character in a LIKE filter give me all the results?
The way to escape the underscore may depend on the needs of your SQL database as the different answers indicate.

question marks instead of text in excel export from DB2 via SQL Developer

Does anyone do exports to excel from DB2 via SQL developer? I have a field in my table which doesn't get exported right, but comes full of question marks instead. All the other fields are fine. This field doesn't contain anything special, just numbers and standard latin characters. I don't know in which enconding it is and how to check it, alas - tried options like "Default", "UTF-8" and "CP-1251", as program suggests on export form, but it still comes out as a bunch of question marks. I know z/OS uses EBCDIC, but there's nothing like that in the encodings list. Does anyone has any idea on how to fix it? Thank you in advance :)

Single quotes stored in a Postgres database

I've been working on an Express app that has a form designed to hold lines and quotes.
Some of the lines will have single quotes('), but overall it's able to store the info and I'm able to back it up and store it without any problems. Now, when I want do pg_dump and have the database put into an SQL file, the quotes seem to cause some things to appear a bit wonky in my text editor.
Would I have to create a method to change all the single quotation marks into double, or can I leave it as is and be able to upload it back to the database without causing major issues. I know people will continue to enter in lines that contain either single or double quotations, so I would like to know any solution or answer that would help greatly.
Single quotes in character data types are no problem at all. You just need to escape them properly in string literals.
To write data with INSERT you need to quote all string literals according to SQL syntax rules. There are tools to do that for you ...
Insert text with single quotes in PostgreSQL
However, pg_dump takes care of escaping automatically. The default mode produces text output to be re-imported with COPY (much faster than INSERT), and single quotes have no special meaning there. And in (non-default) csv mode, the default quote character is double-quote (") and configurable. The manual:
QUOTE
Specifies the quoting character to be used when a data value is quoted. The default is double-quote. This must be a single one-byte character. This option is allowed only when using CSV format.
The format is defined by rules for COPY and not by SQL syntax rules.

SQLite update to change double-double quotes ("") to regular quotation marks (")?

working on an iPhone app. I just imported some records into a SQL Lite database, and all my regular quote marks have been "doubled". An example:
Desired final format:
The song "ABC" will play at 3 PM.
The record is currently appearing in the database as:
The song ""ABC"" will play at 3 PM.
Does anyone know how to do a SQL update to change all "double-double" quotes to just regular quotation marks?
Just to clarify, I'm looking directly at the database, not via code. The code will just display these as "double-double" quotes just as they appear in the database, so I want to remove them. The "double-double" quotes are actually in the import file as well, but if I try to remove them, then the import fails. So I kept them there, and now that the records are successfully imported into the database, now I just want to correct the "double-double" quote thing with a mass SQL update if it's possible. Thanks in advance for any insight!
SQLite uses single quotes to escape string literals. It escapes single quotes by adding another single quote (likewise for double quotes). So technically as long as your SQL is well constructed, the import process should work properly. The strings should be enclosed in single quotes, and not double quotes. I suspect that your code may be constructing the SQL by hand instead of binding/properly escaping the values.
SQLite has a built in function to quote string's. It's called quote. Here are some sample inputs, and the corresponding output:
sqlite> SELECT quote("foo");
'foo'
sqlite> SELECT quote("foo ""bar""");
'foo "bar"'
sqlite> SELECT quote("foo 'bar'");
'foo ''bar'''
So you could remove the twice escaped double quote before it even goes to SQLite using NSString methods.
[#"badString\"\"" stringByReplacingOccurrencesOfString:#"\"\"" withString:#"\""];
If the database already contains bad values, then you could run the following update SQL to clean it up:
UPDATE table SET column = REPLACE(column, '""', '"');

How to insert asian characters using Squirrel Sql

I'm running Squirrel-SQL on Ubuntu.
I cannot write chinese characters on Squirrel, but I can write them in another text editor and copy+paste into squirrel. However, when I run the update and select the data I just inserted, the characters I write show up as question marks.
When I insert the data from a web interface, or when I right click on results and choose "make editable", I can paste in the data which will show up fine when I select again.
This tells me that the database saves the characters fine. Squirrel is capable of displaying the characters fine. The problem seems to be in the sql text editor.
Anyone have this problem before?
I finally found the answer! Looks like hibernate was doing some extra work for me (via web interface or squirrel's "make editable" option on results) that I wasn't aware was necessary. Looks like the problem was actually a syntactical mistake for Microsoft SQL Server. I needed to prepend the letter 'N' right before the characters I wish to insert.
For example:
update title_product
set synopsis = N'我很高兴 test'
where title_product_id = 26
This converts chinese and english characters correctly. Yay.
Although I still cannot write chinese characters directly into Squirrel, I have to copy+paste from another editor.