SQL statement "WITH" doesn't work on Visual basic 6 - sql

I've just created a query which involves a selection on a table created by the WITH statement; I'd like to run in on a Visual Basic 6 application (connected to the database by an ADODB object) but I got an error message "incorrect syntax near the keyword "WITH", when I use the open method of a ADODB.recordset Object; it's like Visual Basic 6 doesn't understand this statement. How could I fix this? Is there an alternative way to perform the sql's WITH statement on Visual Basic 6?

A pound for a penny (in the absence of any more information and most likely incompleete error message) that the WITH does not have a preceeding ; because of a SET statement or DECLARE or some such.
Incorrect syntax near the keyword 'with'...previous statement must be terminated with a semicolon
Or OP is using SQL Server 2000 still...

Related

Validate PL/SQL without permanent changes in database

Is it possible to validate a PL/SQL code without permanent changes.
I know one can commit and then rollback, but I'm looking if there's another solution.
If I write a procedure and I want to know it will compile correctly for example.
I'm using Oracle SQL Developer and didn't see any option to do this.
You can compile your procedure and check if it's valid (doesn't return compilation error).
But in this case Oracle does just Syntactic and Semantic analysis.
Syntactic analysis – Oracle verifies that keywords, object names, operators, delimiters, and so on are placed correctly in your SQL statement. So such queries like select * foRm dual will fail during this validation. For example, we can get here such errors like:
ORA-00900: invalid SQL statement
ORA-00923: FROM keyword not found where expected
ORA-00924: missing BY keyword
ORA-00933: SQL command not properly ended
…
Semantic analysis – it verifies that references to host variables and database objects are valid(including their grants) and that host-variable datatypes are correct. For example, select * from nonexisting_table will fail this validation.
Ie, you will not get errors like ORA-00979 not a group by expression on these steps, since Oracle them later, during optimization phase.
More about this:
http://orasql.org/2017/05/01/sql-validation-during-plsql-compilation/
A different answer is to try the editions feature which has been around for awhile now

Problem running embedded firebird sql query in LibreOffice

I am trying to run the following Firebird SQL query in LibreOffice, which has embedded Firebird:
SELECT RDB$GET_CONTEXT('SYSTEM', 'ENGINE_VERSION') AS "VERSION"
FROM "RDB$DATABASE";
I get the message Syntax error in SQL statement. Can anyone tell me what I am doing wrong? This works in FlameRobin, but not in LibreOffice.
The error "Syntax error in SQL statement" is a HSQLDB error. So, first, make sure your LibreOffice Base project is actually created as a Firebird Embedded project.
I was able to reproduce the error in LibreOffice Base 6.4.4.2 with a Firebird Embedded project. It looks like LibreOffice first tries to parse the query using HSQLDB (probably to be able to transform HSQLDB syntax to Firebird syntax), and only then forwards it to Firebird.
The cause of the error is the $ in RDB$GET_CONTEXT which is not a valid character in an unquoted object name in the HSQLDB SQL syntax, while it is valid in the Firebird SQL syntax. Normally, double quoting the specific object name would solve this, but RDB$GET_CONTEXT is not actually a function, but a syntax construct, so it can't be quoted in Firebird.
To be able to execute this query, you need to enable the 'Run SQL command directly' option in the SQL View, either under Edit > 'Run SQL command directly', or using the 'Run SQL command directly' button in the toolbar (database icon with >_).

visual studio 2012 query builder

Can anybody tell me what does the error mean? Whenever I open the query builder it will prompt with an error indicating that SQL syntax errors were encountered.
https://msdn.microsoft.com/en-us/library/ms189012.aspx
I looked at the following page in MSDN but I don't understand what it means...
For instance, what do these bullet points from the MSDN article mean?
The SQL statement is incomplete or contains one or more syntax errors.
The SQL statement is valid but is not supported in the graphical panes (for example, a Union query).
The SQL statement is valid but contains syntax specific to the data connection you are using.
USER (which you've apparently decided is an appropriate table name) is a SQL Server reserved word.
The best solution is to rename your table, so you don't have to escape the table name every time you want to query it and to make it clear it's your user data (hey, there's a table name suggestion - userdata).
The other option is to escape the name by surrounding it with square brackets:
SELECT * FROM [users]
Note that it will get old fast having to do this with every query. Again, the best solution would be to rename the table to something that isn't a reserved word.

SQL Query "Syntax error near field"

I am using a middleware system to connect to a Database system. We are using a lookup functionality which in turn creates an SQL Query based on the conditions we have provided in it.
SQL QUERY CREATED:
SELECT "FunctionCode", "AUM", "Numerator", "Denominator", "EANUPC", "Length", "Width", "Height", "CategoryofEAN" FROM "tblIdocAlternateUOMs" WHERE MaterialNumber='09792021'
Error:
'Error processing request in sax parser: Error when executing statement for table/stored proc. 'table' (structure 'statement'): com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'FunctionCode'.'.
I have executed the above query in database system and it is working fine without the errors but I am seeing the error in my system when I am trying to retrieve the data from DB.
DB System : Microsoft SQL SERVER
Could you please let me know why are these kind of errors usually appear?
SELECT
FunctionCode,
AUM,
Numerator,
Denominator,
EANUPC,
Length,
Width,
Height,
CategoryofEAN
FROM
tblIdocAlternateUOMs
WHERE
MaterialNumber='09792021'
one thing keep in mind that only value needs quotation mark and that is single quotes... nor field name...
Remove that quotation mark from coding side query.... Just because of this its hapening

IBDAC / UniDAC + interbase 6 or 7 + a table field named "returning"

I am porting REALLY old code to use the UniDAC components. I have hit a wall with a specific UPDATE sql that changes a field named "returning." Simply wrapping the field in quotes does not resolve the issue, because the SQL dialect in the database is 1, which does not support double quote field delimiters. Is there any way around this without changing the field? I am on delphi 7, and am moving away from the interbase db components.
Edit: SQL is as follows:
update logger set
returning = :RETURNING
where locator = :LOCATOR
returns the following error when trying to prepare:
---------------------------
Ww
---------------------------
Dynamic SQL Error
SQL error code = -104
Token unknown - line 3, char -1
where.
---------------------------
OK
---------------------------
This occurs even when I set the client SQL dialect to 1 in code:
query1.Connection.SpecificOptions.Values['SQLDialect'] := '1';
I had to talk to the developer. It has been addressed to a certain point, but I need to remove all parameters in the query before executing it. Very odd, but its a workaround :/
Is it possible for you to create a view leaving everything the same except for this field and use that view in your application?
Is it possible to run this application with the client dll of a Firebird < 2.1 (1.5 for example) and a server with the same version?
I think this is due to the new syntax where returning is a reserved word!