I'm attempting to create a shared dataset in SSRS based on a DB2 query. The data source uses the DB2OLEDB provider.
When I enter the query directly as text, it executes correctly:
SELECT BTCH_DT FROM FMSCHEMA.TTRANS_HIST_DETL WHERE REC_NO = 13288604
However, when I click the expression button next to the query window, and enter the following:
="SELECT BTCH_DT FROM FMSCHEMA.TTRANS_HIST_DETL WHERE REC_NO = 13288604"
the query fails with
ILLEGAL SYMBOL "=?<ERR_STMT> <WNG_STMT> GET SQL SAVEPOINT HOLD FREE ASSOCIATE". SOME SYMBOLS THAT MIGHT BE LEGAL ARE: SQLSTATE: 42601, SQLCODE: -104
it appears as if SSRS is trying to pass the expression itself to the DB2OLEDB provider instead of evaluating the expression and passing the results of that evaluation.
I've already checked out IBM's site:
http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/core/rsql0100.htm but the information provided for SQSLSTATE 42601 wasn't very helpful: "A character, token, or clause is invalid or missing."
Can anyone shed some light on this? Or point me in the right direction? Thanks!
Related
I have just set up a connection to connect SQL Server Reporting Services (SSRS) to my Databricks SQL endpoint. The connection works and I can query data. I am using the Simba Spark ODBC driver to do this and it works just fine.
Now, my report datasets in SSRS need to use some parameters. In regular SQL Server, I would just use #Parameter in my query. However, Databricks SQL works different passing parameters and the syntax should be {{ Parameter }}. I've tried multiple versions of this, for example {{ #Parameter }}, '{{ Parameter }}' et cetera.
This is what it looks like in SSRS:
Unfortunately, this doesn't work and it will give me:
ERROR [42000] [Simba][Hardy] (80) Syntax or semantic analysis error thrown in server while executing query. Error message from server: org.apache.hive.service.cli.HiveSQLException: Error running query: [PARSE_SYNTAX_ERROR] org.apache.spark.sql.catalyst.parser.ParseException: [PARSE_SYNTAX_ERROR] Syntax error at or near '{'(line 3, pos 28)
In Databricks SQL itself, this works fine! A parameter box pops up and I can fill it in.
Now, what DOES work, but is sub-optimal in my opinion, is setting the parameters as '?'
SELECT *
FROM table
WHERE column = ?
Then I will also need to put a '?' in the parameters section in SSRS, but this way you'll never know which parameter is which (in case of more than 1 parameter). Ofcourse I have tried ?Parameter and different versions of it... With no luck
Now I'm wondering: Am I doing something wrong, is this simply not possible? I am really starting the assume the latter.
Really appreciate any help or suggestions. Thanks in advance!
According to MSDN the syntax to convert a number to decimal in VBA is
CDec(expression)
I often use conversion function in access SQL as well. eg Clng, Cint etc...
However when I use CDec I sometime get this error
Compile error:Wrong number of arguments or invalid property assignment
Consider:
In the immediate window
? cdec(round(0.00023,4))
0.0002
? CDec(Round(0.12345678+0.00000001,6))
0.123457
? CDec(Round(0.12345679,6))
0.123457
? CDec(Round(0.12345679,6),10)
This gives the above error (ie as expected as no parameter is allowed)
In a SQL query column
CDec(Round(0.12345678,6))
This gives the above error.
CDec(Round(0.12345678,6),2)
This WORKS and give the answer 0. What does the parameter do!?
CDec(Round(0.12345678,6),2,1)
This gives the above error.
I guess when a function is called from access SQL it is using different code to the one used by VBA. However, I'm stuck and don't understand.
Help!
I'm using MS Access 2013: Build: 15.0.4727.1003 32bit
Harvey
Dennis Wilmar of MS tells, that this is a confirmed bug from Access 2003 - not up to be removed:
Error message when you use the CDec() function in an Access query
The suggested work-around is to wrap CDec in a custom function:
Function NewCDec(MyVal)
NewCDec = CDec(MyVal)
End Function
I have a database that stores teams. Each of these team names is unique. In the event that one is named Bob's Team. I have successfully managed to % encode the symbols when it is sent through the querystring to the next file. In this file I am getting an error with the SQL due to the apostrophe and I don't know how to fix it. Not quite sure about all this escaping stuff I'm reading. It's pretty confusing. Here is the line causing the problem:
strSQL = "SELECT * FROM Teams WHERE TeamName='" & TheTeamName & "'"
In the event that Bob's Team is the name of the team. The error I get is:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'TeamName='Bob's Team''.
/DeleteTeam.asp, line 35
I'd like to know what I have to do in order to make it properly delete a team with an apostrophe (and possibly other annoying symbols) in it.
To make your query work as is you can try the following:
Replace in TheTeamName the Single Quote ' by ''
Then use it in your query. (#least this works in MySQL not sure abt your DB engine but give it a try).
Note that it is better to use prepared statement to prevent SQL-Injection
I have a view with one column containing domain\useraccount as an nvarchar(100). I need to convert the value in this column from domain\useraccount to Last, First Middle. I have successfully created a linked server (ADSI), and can resolve a hard-coded account name to an actual name via an OpenQuery call.
However, making the OpenQuery call from within the view is proving impossible. I've tried the following options:
Use string substitution/concatenation in the OpenQuery call.
Create a function to wrap the OpenQuery call, and call that function from the view.
Neither of the above options works. #1 fails because OpenQuery only accepts a pre-formed string as an argument and it isn't possible to create one (as far as I know) in a view. #2 fails because, based on the error message I got when I tried, functions called from views can't themselves contain calls to EXEC(string). #2 is actually a variation on the official workaround per this KB article:
http://support.microsoft.com/kb/314520
Can anyone shed some light on this? It almost seems like there's no way to make parameterized OpenQuery calls in a view.
Thanks!
I am trying to learn how to do radius search on records using the new SqlServer 2008 managed spacial type and methods (geography) for doing geospatial calculations. I am following the samples on this web page:
http://msdn.microsoft.com/en-us/magazine/dd434647.aspx
I am specifically trying to do this sample:
-- or declare POINT for "downtown Seattle"
-- 1609.344 meters per mile
DECLARE #Seattle geography = 'POLYGON(....)'; SELECT c.customerid FROM
customer c WHERE c.geog.STIntersects(#Seattle.STBuffer(10 * 1609.344));
However, even before running the query (or when I run the quer--both compile and runtime error)I am getting the following error message:
An expression of non-boolean type specified in a context where a condition is expected, near ')'
I am really baffled by this. I am not doing exactly the same query (I am using my own data with a geography column) but it is almost identical to the sample. I am running Sql SErver 2008 SP2 Standard Edition 64-bit. When I type the query it uses intellisense for the STIntersection method and shows a (other_geography geography) sample so it knows that the method exists. I am properly closing the parentheses and delimiting the expression with a semi-colon but I cannot figure out why I am getting the error. Googling has not worked.
Any thoughts?
Seth
STIntersects returns 0 or 1. Try this:
WHERE c.geog.STIntersects(#Seattle.STBuffer(10 * 1609.344)) = 1