Hibernate envers not working with mssql - sql-server

I am facing a problem and I can't find a solution for it. I am using Hibernate envers to audit a table (I am using MS SQL as a database).
I get an error when I try to update the table:
com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '-'. "
Any help ?
Thank you

This issue is caused because the sql server being generated contains the square braces around the table name.
i.e. [YOUR_TABLE]
When envers is engaged, it attempts to put auditing output into the table [YOUR_TABLE]_AUD, hence the error message indicating a syntax error near the _ character (following the right square brace).

Related

shp2pgsql "ERROR: INSERT has more target columns than expressions"

I'm using the script provided by loader_generate_script in Postgis to load Tiger census data and I'm getting an error while loading EDGE data. I was able to locate the error by appending -v ON_ERROR_EXIT=1 to all psql calls.
NOTICE: INSERT INTO tiger_data.al_edges(statefp,countyfp,tlid,tfidl,tfidr,mtfcc,fullname,smid,lfromadd,ltoadd,rfromadd,rtoadd,zipl,zipr,featcat,hydroflg,railflg,roadflg,olfflg,passflg,divroad,exttyp,ttyp,deckedroad,artpath,persist,gcseflg,offsetl,offsetr,tnidf,tnidt,the_geom) SELECT statefp,countyfp,tlid,tfidl,tfidr,mtfcc,fullname,smid,lfromadd,ltoadd,rfromadd,rtoadd,zipl,zipr,featcat,hydroflg,railflg,roadflg,olfflg,passflg,exttyp,ttyp,deckedroad,artpath,persist,gcseflg,offsetl,offsetr,tnidf,tnidt,the_geom FROM tiger_staging.al_edges;
ERROR: INSERT has more target columns than expressions
LINE 1: ...tpath,persist,gcseflg,offsetl,offsetr,tnidf,tnidt,the_geom) ...
The error says pretty clearly that the columns don't match (the SELECT statement is missing a column called divroad. How do I mitigate that in shp2psql since that is what is creating the INSERT statement. Any help is appreciated!
Turns out the issue stems from my postgis version. The Azure managed postgres uses POSTGIS="2.3.2 r15302" as the Postgis extension and it looks like TIGER2017 data issues were patched in 2.4.1 of postgis. The solution is to upgrade Postgis, though that may mean not using Azure managed for now.

SQL "WITH" doesn't work in Spotfire

I try to run a query in Spotfire (7.8) from a MS SQL server.
Everything works well with simple queries, however I can't get Common table expressions get working.
This is a very simple example which run without issues from MS SQL Server Management studio:
with test as ( select * from myTable)
select * from test
In Spotfire I get following error:
An error occurred when executing a query in the external data source.
External error:
Incorrect syntax near the keyword 'with'.
Incorrect syntax near the keyword 'with'. If this statement is a
common table expression, an xmlnamespaces clause or a change tracking
context clause, the previous statement must be terminated with a
semicolon.
Incorrect syntax near ')'.
I've tried adding ; as suggested also here, but it didn't help:
An error occurred when executing a query in the external data source.
External error:
Incorrect syntax near ';'.
Incorrect syntax near ')'.
I've played a bit adding ;s to various location (after end of select statements, closing brackets...), but couldn't get it working.
My real query is very long, so putting everything together and getting rid of CTEs is not really an option.
Just for clarification, I've tried all below positions and also combinations without success:
;with test as ( select * from myTable)
select * from test
with test as ( select * from myTable;)
select * from test
with test as ( select * from myTable);
select * from test
TL;DR If you have all the right permissions, and have used Spotfire more than once or twice, make a stored procedure (see below for details). If you haven't, sorry, you're going to have to put the CTEs all together into one really long query.
So I have found that Spotfire will only actually run "one query" in a standard Information Link or Direct Connection.
Sadly, this means that it doesn't get along very well with temp tables or CTEs.
If leaving everything together really isn't an option, you will have to turn it into a stored procedure, as Sean mentioned in the comments.
The only downside to this, is it requires more access than a lot of Spotfire users have.
First things first, you will need to create your stored procedure in your database, or contact someone who can create the stored procedure for you.
Second, you will need to use the Information Designer (which, again, requires the correct permissions). If you have access, Information Designer is located under Tools. When you open it up, you will have "Create Information Link" at the top, and below that you will see things like "Create Elements" which includes "Procedure".
This is where you select the stored procedure from your data sources.
You then need to make an Information Link ("Create Information Link"), and select the Procedure you just built, which will now be in the "Elements" tab.

MS Access 2013 : Reserved error ( -7713 ): There is no message for this error

In MS Access 2013, an error displays after trying to open/view a Query: Reserved error (-7713): There is no message for this error
For me, I had Table relink performed (it was linking to an SQL Server) and I had deleted a column (as well as added one), which seemed to break that specific Query. Relinking SQL a second time fixed it.
Please find solution describe below.
Replace dbFailonerror with dbSeeChanges when using SQL update Statements
"CurrentDb.Execute StrSQL, dbSeeChanges"

ASP Classic - TSQL function call failiing

I'm working on a quick ASP Classic form that calls a TSQL proc. The first one that I created works great since it doesn't send any values in. Now I'm working on my second one and it looks a bit like this:
exec update_allocation(#Anum='164360',#mTeam='5',#Team='9',#Perc='14',#Bill=140000,#Mons=164360)
Also tried as:
exec update_allocation('164360','5','9','14',140000,164360)
First one gives me an error of:
Microsoft OLE DB Provider for SQL Server error '80040e14' Incorrect
syntax near '#Anum'.
The second gives me:
Microsoft OLE DB Provider for SQL Server error '80040e14' Incorrect
syntax near '164360'.
I'm not sure what to make of these errors. The issue must be the parameters, but not sure how they should be sent in.
The comments are correct but here is a bit of explanation as to why that is the case.
Both errors;
Microsoft OLE DB Provider for SQL Server error '80040e14' Incorrect syntax near '#Anum'.
and
Microsoft OLE DB Provider for SQL Server error '80040e14' Incorrect syntax near '164360'.
are actually quite descriptive and pinpoint where the issue is. Usually in a situation like this an error is highlighting a problem just before the word or phrase in an error description in these cases the #Anum parameter and the 164360 value. If we follow this through the previous character in both cases is an open bracket (.
Unlike functions in T-SQL, Stored Procedures do not require brackets around their parameters and doing so will raise an error (like the ones above) to correct this remove the brackets from both statements.
With named parameters;
EXEC update_allocation #Anum='164360', #mTeam='5', #Team='9', #Perc='14', #Bill=140000, #Mons=164360
Without named parameters;
EXEC update_allocation '164360', '5' ,'9' ,'14' ,140000 ,164360
Either method is acceptable syntax but personally I find it more useful to use the named parameter approach as that allows you to pick and choose what parameters to pass and even exclude ones that have defaults. You can still do this with the nameless approach but ordinal position of the values is more important.
#sean-lange makes a valid point here about SQL Injection vulnerability, consider using the ADODB.Command object to execute stored procedures rather then just calling the Execute() method on a ADODB.Connection object.
Here is an example of calling Stored Procedures using Classic ASP and the ADODB.Command object.
Answer to Using Stored Procedure in Classical ASP .. execute and get results
Answer to How to use ASP variables in SQL statement

DATASTAGE- SQL Server from datastage: load table with strange name

I have a SQL Server table, whose name is like Vers-xxx_yyy.
As you can see, there is a character "-".
I don't know why this table was made so, but I have to load it from datastage job.
So when I run my job, I obtain error "table doesn't exist".
I use odbc stage.
Directly on SQL Server it is possible to use syntax [Vers-xxx_yyy], but not in datastage.
This db already exists and it is used by other applications.
Is there a way to avoid/resolve the problem?
Try using double quotes over the table name. Also it is good practice not to use hyphen, instead you can use underscore
Try using a backslash \ to escape the - character - Vers\-xxx_yyy.
You should be able to put the table name in this form on the ODBC Connector too: [Vers-xxx_yyy]
Another solution would be to inform the SQL to query this table: SELECT * FROM [Vers-xxx_yyy]

Resources