Obiee 12c DENSE_RANK function - obiee

I would like to know if it is possible to execute the dense_rank function in OBIEE12c in another way (for example mathematically), this is because to execute the dense_rank I need to add configs on the server and I don't have access to it.
Thanks.

Related

Jasper report with 2 differents databases (Oracle and postgresql)

I'm here to ask for your help, so my probleme is:
I have created report with jasperrerport 3.7.6 (queries based on oracle).
and now I'm trying to use the same report with PostgreSql Database and I'm getting errors for specific oracle functions like (NVL, sysdate ...), and I don't want to change the query for now (unless I have to).
Is there any thing to use to make autoconversion when executed on a postgresql database?
If there are no matching functions in both databases, consider creating your own functions which will "simulate" the originals.
For example, for Oracle's SYSDATE:
create or replace function f_sysdate return date is
begin
return sysdate;
end;
I don't know PostgreSQL, but - you'd do the same in that database. Function's name must be the same: F_SYSDATE.
Then, in JasperReports, instead of calling "originals", you'd call your own functions, e.g.
select ename, job, sal,
f_sysdate --> this
from emp
where deptno = 10
Doing so, report would work in both databases. True, you'd have to put some initial effort, but - it might pay off in the future.

Connect by level in Postgres on a sequence

I need to convert a query from Oracle to Postgres which uses connect by level on a sequence in Oracle.
I know that connect by level is not available in Postgres. I couldn't find an alternate for this using recursive cte.
In Oracle if I run this query.
create sequence ID_SEQ;
select ID_SEQ.nextval from DUAL connect by level <= 3;
I will get the following result
1
2
3
I need the same in Postgres. Please share some solutions if anyone has any idea.
Thanks in advance
Gokul.
The direct translation of that query is to use generate_series() and nextval()
select nextval('id_seq')
from generate_series(1,3);
This will advance the sequence three times.
If however the goal is to set a specific value for an existing sequence (which requires such a hack in Oracle), just use setval():
select setval('id_seq', 3);

Oracle Database change notification

I am new to DCN, can I use it to detect updates on a column in my table along with inserts in that table ?
I am referring to this
Yes, you can - Change Notifications made for that. You need to register СN listener with query to watch (it can a whole table select * from your_table or part of it select column1 from your_table where column2='xxx') and callback function . You should understand that it is async mechanism changes will not detect immediately, but after some time.
Your documentation's link shows way how to implement it using JDBC.
Read it if you want to use Oracle PL/SQL for that.

Is it necessary to use GROUP BY in Oracle?

Is it necessary to use GROUP BY while you use an aggregate function with column in Oracle?
In MySQL, if I don't use it's working fine, but in Oracle, it gives me an error.
It's necessary if you select at least one column without an aggregate function.
So, this will work:
select sum(col_1), avg(col_2) from table_1;
while this wont:
select sum(col_1), avg(col_2), col_3 from table_1;
You should always use GROUP BY when using aggregate functions. Not using GROUP BY is a non-standard SQL extension allowed by MySQL.
RANT
IMHO, this extension is brain-dead, outright dangerous and should never be used at all because MySQL returns values for a random row for the non-aggregated columns.
END_OF_RANT

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".

Resources