Jaspersoft Studio - Oracle JDBC Data Adapter - Set Specific Schema as Current Schema - oracle

I have the latest version of Jaspersoft Studio and I am using Oracle's JDBC data adapter (ojdbc11.jar), but the connection is made with the default schema, while I want the queries of each report to be executed in another schema (let's call it that: "MySchema").
For example a report with this SELECT clause will not work:
select *
from myTable
while a report with this SELECT clause will work:
select *
from MySchema.myTable
I tried things like this:
jdbc:oracle:thin:#//10.1.1.55:1521/DOMAIN.COM;connectionProperties={currentSchema=MySchema}
or this:
jdbc:oracle:thin:#//10.1.1.55:1521/DOMAIN.COM;connectionProperties={CURRENT_SCHEMA=MySchema}
or this:
jdbc:oracle:thin:#//10.1.1.55:1521/DOMAIN.COM?searchpath=MySchema
or this:
jdbc:oracle:thin:#//10.1.1.55:1521/DOMAIN.COM??currentSchema=MySchema
but without success.
Do you have a solution in this direction or do you know of any other way to solve the problem?
This is an extremely big problem if you consider that I have reports that make selects to dozens of tables and functions.

Related

Apache Drill JDBC Plugin Doesnt Recognize Columns

I'm attempting to query a proprietary RDBMS using Apache Drill. I've created the plugin as a JDBC data source and put my JDBC jar in the jars/3rdparty directory, and I'm able to successfully run a query such as SELECT * FROM mytable.
However, if I use a column name in the query such as SELECT mycol FROM mytable, Drill returns the following error: Error: VALIDATION ERROR: From line 1, column 8 to line 1, column 9: Column 'mycol' not found in any table. Moreover, I've noticed that my schema is entirely missing if I run SELECT * FROM INFORMATION_SCHEMA.SCHEMATA, so I have a hunch that Drill is unable to retrieve my database schema from the JDBC driver.
I'm wondering what method of the JDBC driver may be implemented incorrectly that's causing this problem. The JDBC driver has been used with other 3rd party software such as Spark with no issue.
In order to perform a query on your table you need to prefix the name of your table with the name you gave your storage plugin. For example if you named your storage plugin rdbms your query should look like this:
SELECT * FROM rdbms.mytable
Your additional query SELECT * FROM INFORMATION_SCHEMA.SCHEMATA likely failed for the same reason. Try SELECT * FROM rdbms.INFORMATION_SCHEMA.SCHEMATA. And don't forget to replace rdbms with the name you gave your storage plugin.
I think we should query on drill like select * from dfs.<storagePlugin>.tableName
Can you check once.?

How to have sysdate result remoted across database link?

I'm running a query across a database link to a Sybase server from Oracle.
In it's where clause is a restriction on date, and I want it tied to sysdate, so something like this:
select * from some_remote_view where some_numeric_key = 1 and
some_date > sysdate+2
The problem is, when I do explain plan, only the condition some_numeric_key = 1 shows up in the actual sql that is getting remoted to the sybase server. Oracle is expecting to perform the date filter on its side.
This is causing a performance nightmare - I need that date filter remoted across to have this query working quickly
Even if I try something like casting the sysdate to a charcater string like this:
to_char(sysdate-2,'YYYY-MM-DD')
It still does not remote it.
Is there anything I can do to get Oracle to remote this date filter across the db link to Sybase?
Doing integration between Oracle and other platforms I often run into this problem, not just with SYSDATE but with other non-standard functions as well.
There are two methods to work around the issue, the first being the most reliable in my experience.
First, you can create a view on the remote db with the filters you need, then on the Oracle side you just select from the new view without additional filters.
Second, if you are not allowed to create objects on the remote side, try using bind variables (of the correct data type!) in your Oracle SELECT statement, e.g.:
declare
v_some_date constant date := sysdate + 2;
begin
insert into oracle_table (...)
select ...
from remote_table#db_link t
where t.some_numeric_key = 1
and t.some_date > v_some_date;
commit;
end;
/

Open ms-access data file (*.mdb) with OpenOffice

I'm trying to browse an ms-access data base on a mac. Best results so far, I had with using OpenOffice on a Mac like described here.
Now I can see all the tables. But when I try to access the data with selects, I only see 3 lines of the result set and the contents of string columns is only shown with the first letter.
However, somehow I can access all the data:
select count(*) from SomeTable gives me correct row count.
select * from SomeTable where SomeStringCol='SomeWord' returns the
expected row(s)(so the select seems to use more than the first
letter... and select * from SomeTable where SomeStringCol='S'
returns empty result)
Any idea why it is like it is and how to access the full data? (It's not necessary to go with OpenOffice, that was just the best way up to now)
select * from SomeTable where SomeStringCol='S' only selects those rows where the only text in SomeStringCol is the letter 'S'. This is probably unlikely (but not impossible)
You would need to change the query to select * from SomeTable where left(SomeStringCol, 1) ='S' or select * from SomeTable where SomeStringCol like 'S*'
. when I try to access the data with selects, I only see 3 lines of the result set
As mentioned in the comments to the blog post cited in the question, the unlicensed version of that ODBC driver is crippled and will only return 3 rows.
I recently answered a similar question here regarding LibreOffice Base on Linux. The solution was to use the (free) UCanAccess JDBC driver to connect LibreOffice to the Access database. The actual steps would be slightly different for Mac OS X, but the basic approach would be the same.
I finally installed MDB Tool which opened the full DB and allowed me csv-exports.

Oracle Execution Plan

I am using Oracle 11g and Toad for Oracle. How can I display execution plan for queries?
In Sql server management studio execution plan can be displayed as graphical format. Is there any functionality/tool like that on Toad for oracle?
CTRL-E
Make sure you've ended the query with a semi-colon (and the query above)
Edit:
You need to set-up the TOAD plan table for use. If you think it's already setup on your DB then you may just need to be granted access. Alternatively in my slightly older version of TOAD it's under:
Database --> Administer --> Server Side Objects Wizard. From here you can create the plan table(s) in a schema that you choose.
You should create the PLAN_TABLE using a script provided by Oracle
which is named UTLXPLAN.SQL and is located in one of the installation folders
on the database server.
Then, you should use the EXPLAIN PLAN statement for generating a plan for a SQL statement, like this:
EXPLAIN PLAN SET STATEMENT_ID = 'your_identifier_for_this_plan'
FOR
... your statement ... ;
Then, you can use either a select from PLAN_TABLE (usually using a hierarchical query) or the DBMS_XPLAN.DISPLAY_PLAN procedure to display the plan.
In the same folder where the UTLXPLAN.SQL file is located, there usually exist
examples of using this procedure.
Also, in SQL*PLUS you can use the SET AUTOTRACE feature.
For TOAD FOR ORACLE
this helped me How do I view the Explain Plan in Oracle Sql developer?, I just write what they did in sql developer and wrote in the toad editor and then execute.
Example
explain plan for select field1, field2 from TABLE_NAME;
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);
Check that all queries end with a semicolon, put the cursor on the query you want to analyze and hit CTRL-E.
The first time you could get a popup that asks for the name of the plan table, it suggests TOAD_PLAN_TABLE but it's better to use the standard Oracle table PLAN_TABLE that should be already available. So enter PLAN_TABLE in place of TOAD_PLAN_TABLE (do not specify a schema) and hit OK. You should get a message saying that the object already exists: hit OK again to acknowledge it. Now try CTRL-E again and you'll get the explain plan.
To view/change the currently configured plan table name go to menu "View / Toad Options / Oracle General".

Nhibernate Generate wrong SQL for Oracle with locking

yesterday I've been trying to make this code work inspite the fact it's just working fine with nhibernate and SQL server but when it come to oracle it generate wrong sql
UnitOfWork.Current.CreateCriteria<Bill>().Add(Restrictions.IsEmpty("ReqId"))
.SetMaxResults(BatchSize).SetLockMode(LockMode.Upgrade).List<Bill>();
the generated SQL will something like
Select * from
(Select bill_0.id,bill_0.BillNo ...... from Bill bill_0 where bill_0.reqId is Not null )
where ROWNUM < 10 for UPDATE of bill_0.ID
so i wont run because the allies bill_o is defined inside the inner sql statement so who got the solution ?
the correct sql would be something like this which i tried and worked on oracle db
Select bill_0.id,bill_0.BillNo ...... from Bill bill_0
where bill_0.reqId is Not null and ROWNUM < 10 for UPDATE of bill_0.ID
Since, as you say, NHibernate is generating invalid Oracle SQL, I suggest you file a bug with the NHibernate people. The SQL would work if the in-line view had been assigned an alias of "bill_0", or if the FOR UPDATE clause didn't use a table alias ("for UPDATE of ID"). Whether you can modify your NHibernate calls to make either of these happen I'm afraid I have no idea.

Resources