SQL query using Firebird and foreign characters causes a malformed string error - sql

I have a simple example that is causing an error using Firebird SQL.
I have a table with a column called Details which is defined as:
DETAILS varchar(261) COLLATE UNICODE
If I try to do the following query:
SELECT a.DETAILS
FROM MODHISTORY a
WHERE
a.DETAILS LIKE '%Â%'
I get the error:
Error: *** IBPP::SQLException ***
Context: Statement::Prepare( SELECT a.DETAILS
FROM MODHISTORY a
WHERE
a.DETAILS LIKE '%Â%'
)
Message: isc_dsql_prepare failed
SQL Message : -104
Invalid token
Engine Code : 335544849
Engine Message :
Malformed string
If I connect to the database using CHARSET=UTF8 in the connection string this error goes away but unfortunately I cannot use UTF8 as the character set when connecting to the database because some other tables contain, for example:
SampleData blob sub_type 1 CHARACTER SET ASCII,

I have solved my problem as suggested. I am binding the parameters and now everything works fine

Related

How to use the ENCRYPT function on Firebird?

I'm new to using the Firebird Database Management System and I need to use the ENCRYPT function in my project.
In my project I have been trying to use the following statement for testing:
INSERT INTO state (name)
values (ENCRYPT('MG' using aes mode cbc key 'password' iv '01234567'));
But I have been getting the following Firebird error:
Statement failed, SQLSTATE = 42000
Dynamic SQL Error
-SQL error code = -104
-Token unknown - line 1, column 43
-(
I accessed the documentation and the only example I found there was:
select encrypt('897897' using sober128 key 'AbcdAbcdAbcdAbcd' iv '01234567')
from rdb$database;
The structure of the function is:
ENCRYPT (input
USING <algorithm> [MODE <mode>]
KEY key
[IV iv] [<ctr_type>] [CTR_LENGTH ctr_length]
[COUNTER initial_counter] )
I already tried several modifications in the instruction, but I didn't succeed. Could anyone help me with fixing this problem?

DBEAVER Cloud Impala Connection Property Null has Invalid Value of {1}. Valid values are {2}

[Cloudera][ImpalaJDBCDriver](500174) Connection Property null has invalid value of {1}. Valid values are: {2}.
IncorrectTypeException
com.cloudera.impala.dsi.exceptions.IncorrectTypeException
Has anyone seen this error message before when trying to connect to Cloudera Impala from DBeaver? I got this when creating the database connection.
I can't find anything on this error message.
Figured it out, check your URL Template. If you are like me, you are missing a semi-colon somewhere.

DB2 Error: String data right truncation when inserting data into DB

I have a web scraper that scrapes the title and description and for some URLs, I get an error:
[Error: [IBM][CLI Driver] CLI0109E String data right truncation. SQLSTATE=22001] {
error: '[node-ibm_db] SQL_ERROR',
sqlcode: -99999,
state: '22001'
}
The column for the title is VARCHAR(1024) and description VARCHAR(3072), and I even limit the string length before inserting it to 200 characters just to check, but I still get this error for some URLs.
Does this mean I'm trying to insert data that won't fit into the column?

SQL Contains: Query operators

I got a query working from long ago, the query is build by JPA, but today threw an exception:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.orm.hibernate3.HibernateJdbcException: JDBC exception on Hibernate data access: SQLException for SQL [n/a]; SQL state [99999]; error code [29902]; could not extract ResultSet; nested exception is org.hibernate.exception.GenericJDBCException: could not extract ResultSet at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:973)
Long story short, it gives SQL state [99999]; error code [29902]; a parameter problem.
The query its build like this:
select * from mytable where CONTAINS(field1, 'BT');
A little google-fu show me that BT its a query operator for Contains. This error can be reproduced searching by NOT, DIFMERGE, ABOUT, AND..
The question is, there is a way to escape the text so i can search by the word BT or his friends?
EDIT: i build the contains like this:
return builder.greaterThan(
builder.function("CONTAINS", Integer.class, exp, builder.literal(((String) param.getValue()).toUpperCase())),
0);
EDIT: I tried converting the text BT to unicode, but doesn't work either.
select * from myTableWHERE CONTAINS(field1, UNISTR('\0042\0054')) > 0

SSIS Execute SQL Task Error using Parameters

SSIS 2012....I want to post a success message to a SQL table in the same DB where I'm working. I created a variable called "InputRowCount" as Int32, and set it in the RowCount transform. Then, in a SQL Task, I set it as an input parameter, incidentally giving it a name. My DB connection is OLEDB, so the book says I just use a "?" to reference the lone Parameter (I expect to insert more parameters later....) It gets a "Parameter name is unrecognized" error. Here's the SQL Statement:
[Edit...now I get that the parameter type cannot be deduced...]
[Execute SQL Task] Error: Executing the query "INSERT INTO dbo.tblpendingmessages
([Recipi..." failed with the following error: "The parameter type for '#P1' cannot be uniquely deduced; two possibilities are 'float' and 'datetimeoffset(7)'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
INSERT INTO dbo.tblpendingmessages
([Recipient]
,[MessageSubject]
,[MessageBody]
,[MessageGenerated]
,[MessageUser]
,[MessageFormat])
VALUES
(N'CPAS_Administrator#xxxxxx.COM' -- Recipient
,N'All Projects Import' -- Subject Line
,N'ALL Projects Import has replaced ' + FORMAT(?,'N','en-us') + N' rows of the AllProjects Table in CPAS.' -- MessageBody
,GETDATE() -- MessageGenerated
,N'SSIS'
,N'TEXT')