SQL or ORA exceptions caused due to invalid sql, database package state or some database exceptions - bi-publisher

I am getting the above error in BIPublisher's Data model when I try to view sample data.
Does anybody know how to fix this?

Try enclosing your SQL within another "Select * from ()"
It Worked for me.
For Ex. If your code is
Select Sysdate From Dual
Then make it
Select * from (Select Sysdate From Dual)

Related

RexCall cannot be cast to RexInputRef exception in Apache Beam SQL

I'm trying to do a simple join using Beam SQL but I'm getting an exception while compilation:
Exception in thread "main" java.lang.ClassCastException: org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.rex.RexCall cannot be cast to org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.rex.RexInputRef
The join is something like:
select T1.x from table1 T1 join table2 T2
on
(case when T1.a = 'ABC' then 'ABC' else T1.b end = T2.c)
This condition works fine when executed in BigQuery (tried as a sanity check). Not sure why it's breaking in Beam SQL. I even tried using Beam SQL UDF but it did not help either. I assume it's because of Apache Calcite and the format it follows but I do not know how to handle it.
Can someone please help with this.
Interesting. Can you try the IF conditioning? I hope this will work:
select T1.x from table T1 join table T2 on IF(T1.a = 'ABC', 'ABC',T1.b) = T2.c

Wonderware Historian: query the Runtime.Events view

I'd like to query the Runtime.Events view with SQL. I have tried the followings:
select * from Runtime.dbo.Events gives the following error:
OLE DB provider "INSQL" for linked server "INSQL" returned message "Event History no longer supports queries that do not provide time".
select * from Runtime.dbo.Events where EventTime >= '2018-09-01 00:00:00' and EventTime <= '2018-11-01 00:00:00' gives this not descriptive error:
Cannot execute the query "..." against OLE DB provider "INSQL" for linked server "INSQL".
The date format seems to be right, because when I have tried with different format I got error referring to wrong date format.
How to query this view?
Perhaps you're trying to query for these events:
SELECT TOP 1000 *
FROM [A2ALMDB].[dbo].[v_EventHistory]
or these events:
SELECT * FROM Runtime.dbo.EventHistory
WHERE DateTime >= '2018-10-11'
I'm unable to clarify this by a comment due to lack of reputation, so let me post an answer. May be your alarms and events are in A2ALMDB database. If that is the case, try the following query.
SELECT * FROM [A2ALMDB].[dbo].Events WHERE [EventStamp] between '2018-09-01 00:00:00' AND '2018-11-01 00:00:00'

Apache Spark SQL: Automatic Inner Join?

So I have a weird situation.
Whenever I run a sqlContext.sql with a inner join statement, I actually get an error but when I read the error, it looks like Spark has already automatically joined my two separate tables once it tries to execute the on statement.
Table1:
patient_id, code
Table2:
patient_id, date
Select code, date
from Table1
inner join Table2
on Table1.patient_id = Table2.patient_id <- exception shows the table is joined already by this point.
Any ideas about this behavior?
Error looks like thisish
org.apache.spark.sql.AnalysisException: cannot resolve 'Table2.patient_id' given input columns [patient_id, code, date]
I think that you have a typo in your program.
However, what you can do is the following:
tableOneDF.join(tableTwoDF, tableOneDF("patient_id") === tableTwoDF("patient_id"), "inner").select("code", "date")
whereas tableOneDF and tableTwoDF are two dataframes created on top of the two tables.
Just try it out, and see if it still happens.

RuntimeError: ERROR Mrelation "tablename" does not exist

Rails - 2.3.8
Database - Postgres(9.2)
Active record query is not able to generate tablename in double quotes ie
# this ran fine
Table.find_by_sql('Select * from "Table" Limit 1')
Sql generated - Select * from "Table" Limit 1
But issue comes in,
Table.find(:first)
Sql generated - Select * from Table Limit 1 (Clearly noticed that table not in double quotes)
Active record displaying error
ActiveRecord::StatementInvalid: RuntimeError: ERROR
C42P01 Mrelation "Table" does not exist
P15 Fparse_relation.c L864
RparserOpenTable: SELECT * FROM Table LIMIT 1
I feel that postgresql adapter is not able to generate tablename in double quotes.
I never get a chance to work on Postgres. But I have a workaround solution for this. Try as follows:
table_name = '"Table"'
table_name.find(:first)
I haven't try this in my machine since I do not have the required setup. I hope it should work.

delphi "Invalid use of keyword" in TQuery

I'm trying to populate a TDBGrid with the results of the following TQuery against the file Journal.db:
select * from Journal
where Journal.where = "RainPump"
I've tried both Journal."Where" and Journal.[Where] to no avail.
I've also tried: select Journal.[Where] as "Location" with the same result.
Journal.db is a file created by a third party and I am unable to change the field names.
The problem is that the field I'm interested in is called 'where' and understandably causes the above error. How do I reference this field without causing the BDE (presumably) to explode?
Aah, I'm loving delphi again... I found a workaround. The TQuery component has the Filter property :-)
I omitted the "Where=" where clause from the query whilst still keeping all the other 'and' conditions.
I set the Filter property to "Where = 'RainPump'".
I set the Filtered property to True and life is good again.
I'm still wondering if there's a smarter way to do this using this old technology but if it's stupid and it works, then it's not stupid.
I'm afraid that someone reading this thread will get the impression that the BDE SQL engine cannot handle the query:
select * from Journal where Journal."Where" = "RainPump"
and will waste their time unnecessarily circumlocuting around it.
In fact this construction works fine. The quotes around "Where" keeps the BDE from interpreting it as a keyword, just as you would expect.
I don't know what is wrong in Baldric's particular situation, or what he tried in what order. He describes the problem as querying a *.db table, but his SQL error looks more like something you'd get in passthrough mode. Or, possibly he simplified his code for submission, thus eliminating the true cause of the error.
My tests performed with:
BDE v.5.2 (5.2.0.2)
Paradox for Windows v. 7 (32b)
Delphi 5.0 (5.62)
Various versions of the statement that succeed:
select * from Journal D0 where D0."Where" = "RainPump"
select * from Journal where Journal."Where" = "RainPump"
select * from ":common:Journal" D0 where D0."Where" = "RainPump"
select * from ":common:Journal" where ":common:Journal"."Where" = "RainPump"
select * from :common:Journal where Journal."Where" = "RainPump"
select * from ":common:Journal" D0 where D0."GUMPIK" = 3
select * from ":common:Journal" where ":common:Journal"."GUMPIK" = 3
select * from :common:Journal where Journal."GUMPIK" = 3
Versions of the statement that look correct but fail with "Invalid use of keyword":
select * from ":common:Journal" where :common:Journal."Where" = "RainPump"
select * from :common:Journal where :common:Journal."Where" = "RainPump"
select * from ":common:Journal" where :common:Journal."GUMPIK" = 3
select * from :common:Journal where :common:Journal."GUMPIK" = 3
-Al.
You can insert the resultset into a new table with "values" (specifying no column names) where you have given your own column names in the new table and then do a select from that table, Using a TQuery, something like:
Query1.sql.clear;
query1,sql.add('Insert into newtable values (select * from Journal);');
query1.sql.add('Select * from newtable where newcolumn = "Rainpump";');
query1.open;
Rewrite it like this, should work:
select * from Journal where Journal.[where] = "RainPump"
Me, I'd rename the awkward column.
In MySQL, table/column names can be enclosed in `` (the angled single quotes). I'm not sure what the BDE allows, but you could try replacing [where] with `where`
select * from Journal where Journal."where" = "RainPump"
Ok, so naming columns after keyboards is bad in ANY SQL system. Would you name a column "select" or "count" or "alter" or "table" or perhaps just for the fun of it "truncate" or "drop"? I would hope not.
Even if you build in the work around for this instance you are creating a mine field for whomever comes after you. Do what mj2008 said and rename the bloody column.
Allowing this column name to persist is the worst example of someone who is building a system and would get you on the poop list for any project manager.

Resources