Flyway on Sybase ASE results in Invalid colum name error when there are double quotes in the SQL Statement - flyway

flyway migrate command on Sybase ASE returns an error when there is double quotes in the SQL statement.
Migration R__wes.sql failed
---------------------------
SQL State : 42S22
Error Code : 207
Message : Invalid column name 'C'.
Statement : SELECT count(1) from redemptions WHERE redem_type = "C"
I'm using Flyway 6.3.3 on linux and tried with both jConnect and jTDS drivers.
Simple solution is to replace the double quotes with singles.
However I have hundreds of complex stored procedures that will need to be updated so they will work with flyway.
Is there something I missed that would resolve this issue?
Thanks,
Wesley

With Mark's suggestion i was able to resolve this issue by adding
set quoted_identifier off in beforeMigrate.sql (flyway callback) to disable sybase to treat strings as identifiers
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc00801.1510/html/iqrefso/X315903.htm
Thank you all!

Related

specify a database name in databricks sql connection parameters

I am using airflow 2.0.2 to connect with databricks using the airflow-databricks-operator. The SQL Operator doesn't let me specify the database where the query should be executed, so I have to prefix the table_name with database_name. I tried reading through the doc of databricks-sql-connector as well here -- https://docs.databricks.com/dev-tools/python-sql-connector.html and still couldn't figure out if I could give the database name as a parameter in the connection string itself.
I tried setting database/schema/namespace in the **kwargs, but no luck. The query executor keeps saying that the table not found, because the query keeps getting executed in the default database.
Right now it's not supported - primarily reason is that if you have multiple statements then connector could reconnect between their execution, and result of use will be lost. databricks-sql-connector also doesn't allow setting of the default database.
Right now you can workaround that by adding explicit use <database> statement into a list of SQLs to execute (the sql parameter could be a list of strings, not only string).
P.S. I'll look, maybe I'll add setting of the default catalog/database in the next versions

Oracle SQL French script file

I need to do a mass insert into my database. I have French characters(e.g é) into my table
When i connect to SQLPlus and run the query manually
INSERT INTO TEST VALUES ('é');
Data is inserted properly.
When i save the same query in an Sql file and execute same through SQLplus
I get below error:
SQLPLUS>#test.sql;
ERROR:
ORA-01756: quoted string not properly terminated
Can anyone guide me.
thanks

Oracle SQL Developer create SDO_GEOMETRY invalid datatype

I am trying to create a spatial database in SQL Developer, which is connected to Oracle 11g Release 2 on AWS.
When I do this
CREATE TABLE cola_markets (
mkt_id NUMBER PRIMARY KEY,
name VARCHAR2(32),
shape SDO_GEOMETRY);
and compile, I always get this:
errormkt_id NUMBER PRIMARY KEY,
name VARCHAR2(32),
shape SDO_GEOMETRY)
Error at Command Line : 4 Column : 7
Error report -
SQL Error: ORA-00902: invalid datatype
00902. 00000 - "invalid datatype"
*Cause:
*Action:
It seems that SQL Developer cannot find the sdo_geometry datatype. How can I resolve this issue?
That should work. Are you sure your database does have Oracle Spatial or Oracle Locator installed.
Databases provided on AWS typically don't.
Please check the version of your database.
For oracle 12c onwards all of SDO_GEOM package is available to oracle locator users. Thus your should work.
However, in 12c you may need to deinstall spatial part as mentioned here : https://docs.oracle.com/database/121/SPATL/sdo_locator.htm#SPATL1433
In case this happens to anyone with oracle spatial or locator or anything needed correctly installed in MDSYS, and it still doesn't work, you can try granting EXECUTE privileges from MDSYS to your user as I read on
https://blog.ronnyegner-consulting.de/category/oracle-in-general/
It worked for us.

Invalid column definition error when using four part name to access Oracle DB as SQL Server linked server

I have setup a linked server in SQL Server 2008 R2 in order to access an Oracle 11g database. The MSDASQL provider is used to connect to the linked server through the Oracle Instant Client ODBC driver. The connection works well when using the OPENQUERY with the below syntax:
SELECT *
FROM OPENQUERY(LINKED_SERVER, 'SELECT * FROM SCHEMA.TABLE')
However, went I try to use a four part name using the below syntax:
SELECT *
FROM LINKED_SERVER..SCHEMA.TABLE
I receive the following error:
Msg 7318, Level 16, State 1, Line 1
The OLE DB provider "MSDASQL" for linked server "LINKED_SERVER" returned an invalid column definition for table ""SCHEMA"."TABLE"".
Does anyone have any insight on what my be causing the four part name query to fail while the OPENQUERY one works without any problems?
The correct path to follow is to use OPENQUERY function because your linked server is Oracle: the four name syntax will work fine for MSSQL servers, essentially because they understand T-SQL.
With very simple queries, a 4 part name can accidentally work but not often if you are in a real scenario. In your case, the SELECT * is returning all the columns, and in your case one of the column definition is not compatible with SQL Server. Try another table or try to select a single simple column (e.g. a CHAR or a NUMBER), maybe it will work without problem.
In any case, using distributed queries can be tricky sometime. Database itself does some optimizations before executing commands, so it is important for the database to know what it can do and what it can't. If the DB thinks the linked server is MSSQL, it will take some action that may not work with Oracle.
When using four part name syntax with a linked DB different from MSSQL, you will have other problems as well, for example using database builtin functions (i.e. to_date() Oracle function will not work because MSSQL would want to use its own convert() function, and so on).
So again, if the linked server is not a MSSQL, the right choice is to use OPENQUERY and passing it a query that use a syntax valid against the linked server SQL dialect.
If you use the OLEDB provider for Oracle you can query without using openquery

Failure to connect to odbc database in R

I've been trying to connect my company's DMS to R using the odbcConnect command, but get the following message:
myConn <-odbcConnect("NZSQL", uid="cejacobson", pwd="password")
Warning messages:
1: In odbcDriverConnect("DSN=NZSQL;UID=cejacobson;PWD=password") :
[RODBC] ERROR: state IM002, code 0, message [unixODBC][Driver Manager]Data source name not found, and no default driver specified
2: In odbcDriverConnect("DSN=NZSQL;UID=cejacobson;PWD=password") :
ODBC connection failed
The thing is, I'm positive the Data source name is NZSQL and my uid and password are correct as well. Any insight as to why R may not be finding my data source / driver (the driver is, by the way, specified and working).
How can I fix this?
I ran across this same problem when I was first trying to connect to an Oracle database. In the end what worked for me was using odbcDriverConnect and a connection string instead of odbcConnect.
myConn <-odbcDriverConnect("Driver={Oracle in OraClient11g_home1};Dbq=NZSQL;Uid=cejacobson;Pwd=password;")
You can check on https://www.connectionstrings.com/ for your specific connection string for your database. Mine happened to be this one.
Hope this helps.
This is IM02 error which means name of the DSN is incorrect.
GO to ODBC and check the USER/System DSN that you should be using. Once your name of DSN is correct, you might get IM014 state error which is archtecture mismatch. In that case,
The simpler solution is
IN r studio - go to tools and change the version of R to 32 bit.
It should be ready to work
I was trying to access SQL Server database and got the same error. After using the correct format of db connection, I got access to my sql server database.
dbhandle <- odbcDriverConnect("Driver={SQL Server};Server=mydbhost;Database=mydbname;Trusted_Connection=Yes")
I know this is old but also make sure that you remove the spaces around the '=' sign. That was my problem.
What worked for me was a 32 bit connection instead of a 64 bit connection.
I just spent days on this. If you are using a Microsoft Access database you have to use the full path to the database, it won't even find the file in the same folder.
So from the above question,
myConn <-odbcConnect("NZSQL", uid="cejacobson", pwd="password")
Would need to be something like
myConn <-odbcConnect("c:\\NZSQL", uid="cejacobson", pwd="password")
Phil's link really helped:
https://www.connectionstrings.com/
I had the same problem, what helped me was to add the driver manually:
Search for ODBC Data Source Administrator and click the 64 bit option
Click on "dBASE Files" and then "Add"
Double click on "Oracle in XE"
Fill Data Source Name (NZSQL in your example) and TNS Service Name fields.
Click on Ok.
After that you may go to RStudio again and you will be able to connect using odbcConnect().
I just used R x64 (64-bit) instead of R i386 (32-bit) and it worked

Resources