Is there a binary literal in Interbase? - literals

I have downloaded a trial version of Interbase 2017, and am using Windows 64 bit builds, and ODBC drivers on Windows 10 Pro Version 1703.
I created a database like this
CREATE TABLE "REBBINARY" (ID integer, "SQLVALUE" CHAR(3) NOT NULL)
and attempt to insert some binary data like this
INSERT INTO "REBBINARY" ("SQLVALUE") VALUES (x'000000')
which works fine in Firebird.
But I get this error
** Error: [ODBC InterBase Driver][InterBase]Dynamic SQL Error
SQL error code = -104
Token unknown - line 1, char 47
'000000'
So, what's the correct literal for binary data in statements?

The answer from Interbase's current developer
InterBase does not offer a literal binary. The only way that you can add a binary value to a char field would be to use a parameterised query. For example, FireDAC's TFDParam offers the AsByteStr property: http://docwiki.embarcadero.com/Libraries/Berlin/en/FireDAC.Stan.Param.TFDParam.AsByteStr

Related

Can't receive text from PostgreSQL into Excel via ODBC due to character coding problem (UTF-8 vs Win1250)

My base scenario is that I want to make an excel report with data from a PostgreSQL DB.
I get them via ODBC, making a simple linked table with PowerQuery.
For DSN I choose (None), then I write the connectio string and the SQL statement. Generally it works fine, but with one column, it doesn't. I recive the following error message:
ODBC: ERROR [22P05] ERROR: character with byte sequence 0xc2 0xb2 in encoding "UTF8" has no equivalent in encoding "WIN1250";Error while executing the query
So that is clear, the source is in UTF-8 with characters that are not compatible with Win1250.
What I am looking for is a general solution either on DB or excel site.
The used SQL statement is a simple SELECT * FROM [view], so I can use any replacement or converting or anything just to be able to hanle it with transformations on the column. I can replace the view with function if that is better.
But it would be better, if you can suggest an excel site solution.
With it there is some criteria. That scenario, when "I get the data first in text, then I convert it to Win1250, then import to excel" wont't fit, and I need something which connects to the excel file itself, so if I move it to an other pc, it need to work too without any more modification.
Thanks for all the help!

Getting Bad request; Syntax error- invalid string literal if backslash is present in query

I am trying to search for a record in Cosmos DB using Azure SDK for Python. I have a string in my query that contains double backslash.
Azure functions core tools version - 3
Python 3.7.5
'SELECT * from c where ... "Cardiac Imaging Followup\\unplanned")'
With this Query string, I receive an error like below:
azure.cosmos.errors.HTTPFailure: Status code: 400
{"code":"BadRequest","message":"Message: {\"errors\":[{\"severity\":\"Error\",\"location\":{\"start\":327,\"end\":355},\"code\":\"SC1012\",\"message\":\"Syntax error, invalid string literal token '\\\"Cardiac Imaging Followup\\\\un'.\"}]}\r\nActivityId: 4155710f-facb-4b96-a6b9-169f6e463f13, Microsoft.Azure.Documents.Common/2.14.0"}
However, when we use the same query on Azure Cosmos DB Web Data explorer, it works.
I assume this is due to escape characters.
Tried with one backslash - Did not work on SDK, Did not work on Web Data explorer
Tried with two backslash - Did not work on SDK, Worked on Web Data explorer
I tried escaping the string (with double \) in SDK using re.escape, but that also did not work.

Malformed SQL Statement: Expected token 'USING' but found Identifier with value 't' instead

I am trying to merge to a SQL Database using the following code in Databricks with pyspark
query = """
MERGE INTO deltadf t
USING df s
ON s.SLAId_Id = t.SLAId_Id
WHEN MATCHED THEN UPDATE SET *
WHEN NOT MATCHED THEN INSERT *
"""
driver_manager = spark._sc._gateway.jvm.java.sql.DriverManager
con = driver_manager.getConnection(url) #
stmt = con.createStatement()
stmt.executeUpdate(query)
stmt.close()
But I'm getting the following error:
SQLException: Malformed SQL Statement: Expected token 'USING' but found Identifier with value 't' instead at position 25.
Any thoughts on where might be going wrong?
I don't know why you're getting this exact error. However I believe there are a number of issues with what you are trying to do.
Running the query via JDBC makes it run in SQL Server only. Construct like WHEN MATCHED THEN UPDATE SET * / WHEN NOT MATCHED INSERT * will not work. Databricks accepts it, but for SQL Server you need to explicitly provide columns to update and values to insert (reference).
Also, do you actually have tables named deltadf and df in SQL Server? I suppose you have a Dataframe or temporary view named df... this will not work. As said, this query executes in SQL Server only. If you want to upload data from Dataframe use df.write.format("jdbc").save (reference).
See this Fiddle - if deltadf and df are tables, running this query in SQL Server (any version) will only complain about Incorrect syntax near '*'.
SQLException: Malformed SQL Statement: Expected token 'USING' but found Identifier with value 't' instead at position 25.
if you missed updating any specific field or specific syntax, you will get this error.
I performed merge operation its working fine for me without error, Please follow below reference .
Reference:
https://www.youtube.com/watch?v=i5oM2bUyH0o
https://docs.databricks.com/delta/delta-update.html#upsert-into-a-table-using-merge
https://www.sqlshack.com/sql-server-merge-statement-overview-and-examples/

Rocket Software SQL ODBC, Retrieve Wrong Filenames

I installed Rocket Software for accessing an Unidata Db through SQL Server 2008. The idea is to write SQL Procedures for populating SQL Tables, but the problem I am getting is retrieving wrong filenames i. e. Select * from MyDb_Members. I got the field names as Member{Name, Phone{number. In my unidata core these fields are named as Member Name, Phone Number.
Do you know if there is way to run sql queries with those field names without getting sql query errors. It looks sql server does not like to use that name convention:
Select Member{Name from MyDb_Members
Error near '{'
Thanks for your help
Try formatting the query using NATIVE keyword. I don't use Unidata, but in UniVerse this works well. I have a lot of columns that contain periods and those are illegal column names in standard SQL.
{ NATIVE "Select * from MyDb_Members" }

Vim errorformat / efm for PL/SQL

Im trying to get the standard vim :clist, :cope functionality working with vim.
Specifically, I'm trying (and failing) to capture the filename from the compiler output.
I have the PL/SQL code compiling okay (well, when there is no errors =), and I've got errorformat picking up the error messages, line numbers and column numbers, but I can't get it to pick up the filename (which vim needs in order to be able to jump to the file).
This is the best errorformat I've been able to come up with:
:set efm=%+P[%f],%E%l/%c%m,%C%m,%Z
This is the output from the compiler. It only has the filename on the first line (which I try and pick up with the +P[%f].
output:
[code/voyager/db/db_source/pck_policy_2.pks]
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Sep 8 14:51:24 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
Warning: Package created with compilation errors.
SQL> Errors for PACKAGE PCK_POLICY_2:
LINE/COL ERROR
-------- --------------------------------------------------------------
21/7 PLS-00103: Encountered the symbol "EXP_PBIT_ID" when expecting
one of the following:
:= . ) , # % default character
The symbol "," was substituted for "EXP_PBIT_ID" to continue.
185/1 PLS-00103: Encountered the symbol "END" when expecting one of the
following:
constant exception <an identifier>
<a double-quoted delimited-identifier> table long double ref
char time timestamp interval date binary national character
nchar
LINE/COL ERROR
-------- -------------------------------------------------------------
SQL> Disconnected from Oracle Database 11g Enterprise Edition
:clist afterwards shows the errors have been caught, but not the filename:
:clist
19:21 col 7 error: PLS-00103: Encountered the symbol "EXP_PBIT_ID" when expecting one of the following: := . ) , # % default character The symbol "," was substituted for "EXP_PBIT_ID" to continue.
21:185 col 1 error: PLS-00103: Encountered the symbol "END" when expecting one of the following: constant exception <an identifier> <a double-quoted delimited-identifier> table long double ref char time timestamp interval date binary national character nchar
Does anyone know how I can make this pick up the filename?
Thanks
Dave Smylie
The syntax you're using looks OK to me. So all I have to offer is thoughts...
Even though the file names are not displayed, can you still jump to the correct line in the quickfix window?
Does the compiler produce any output before the file name? Tried a %E before the %+P?
Even though it's not the error format you are looking for, have you tried the oracle.vim plugin?
Knowing NOTHING about efm or vim or this parsing you are trying to do, I would say that you might have better luck performing a query to get the error information. Check out the view
user_errors to gather the error information. It should be easier to get the data the way you want using this method.

Resources