How to get long running report current status? - oracle

While running a long running report in Oracle Application Server 10g, the status of the report is exist in OAS admin console something like "25 of 3225 Pages completed".
How can I got this value from the OAS to be able to display it to the user in oracle forms.

Not certain but it's possible it might be stored in v$session_longops. See here for examples.
Some oracle code writes into V$session_longops but you can also encode into your own applications using some provided PLSQL functions.
If OAS or the report itself is writing something into here, you can get that information from an oracle form to display to the user when the report is run.
While the above code is running, the contents of the v$session_longops view can be queried as follows.
COLUMN opname FORMAT A20
COLUMN target_desc FORMAT A20
COLUMN units FORMAT A10
SELECT
opname,
target_desc,
sofar,
totalwork,
time_remaining,
units
FROM
v$session_longops
The type of output expected from this v$session_longops query is listed below.
OPNAME TARGET_DESC SOFAR TOTALWORK UNITS
-------------------- -------------------- ---------- ---------- ----
BATCH_LOAD BATCH_LOAD_TABLE 3 10 rows

Related

Oracle SQL Developer script output not displaying readable format

I have queries that provide the output, but the output is really weird looking. It doesn't scroll over to look at the output, and the columns are really wide for things that are less than 20 characters. How do I get it to look normal? This is using Oracle SQL Developer. I searched online, but this doesn't seem to be what I need to do: format output archive. Although, I don't see how to get to the preference screen they are referring to either.
This is a portion of the output:
RAK SHEL SLT
---------- ---------- ------------------------------ PRT BRDBND_
---------------------------------------- ---------- DSLAM
-------------------------------------------------- VEND
-------------------------------------------------------------------------------- MODE
-------------------------------------------------------------------------------- PORT_ADDR CARRIER_ID
----------------- ----------------------------------------------------- CIRC_DE SERVICE SHELF_PT_NUM CARD_PART_NUM
---------- ---------- ------------------------- ------------------------- CARD_PT_DESC
-----------------------------------
3317 270812 1179G1 1170F1
As you can see, hopefully, it has really wide columns for the output, and column headers aren't at the top of the output window, it's in the output window. None of the output is more than 20 characters wide. I'm not sure why it's displaying that way.
Update: Plus, it's printing the column headers in the output window over and over again.
Try adding this line at the beginning of your script. It appears that your SQL Developer settings are what is making this output unreadable.
NOTE: I am using SQL Developer version 18.1.0.095
Edit: Added command to suppress reprinting of headers (pagesize) to 80 lines.
set sqlformat ansiconsole;
set pagesize 80;

How do you create an Oracle Automatic Workload Repository (AWR) report?

How do you create an Oracle Automatic Workload Repository (AWR) report?
To generate AWR report follow below steps :
Take begin snap id
set serveroutput on;
DECLARE
v_snap_id number ;
begin
v_snap_id := DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT;
dbms_output.put_line(v_snap_id);
end;
/
Run your batch or the program you want to monitor.
Take end snap id
set serveroutput on;
DECLARE
v_snap_id number ;
begin
v_snap_id := DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT;
dbms_output.put_line(v_snap_id);
end;
/
Go to oracle directory. e.g. in my case
cd C:\oraclexe\app\oracle\product\11.2.0\server\rdbms\admin
go to sqlplus promt
sqlplus dbusername/dbpassword#host:port/dbenv
run #awrrpt command
It will ask for format of the report, default is html.
provide no of days, if you dont remember your snap id
enter begin snap
enter end snap
Give report name and press enter
Your report will be generated in "admin" e.g. in my case
C:\oraclexe\app\oracle\product\11.2.0\server\rdbms\admin
sqlplus into to Oracle as the DBA users. Run the report sql. Answer the questions prompted by the report to narrow down the time period
sqlplus / as sysdba
#$ORACLE_HOME/rdbms/admin/awrrpt.sql
The script will ask you some questions so you get a report for the time period you are interested in.
You can use dbms_workload_repository package without the need to log into the server itself.
For a text report, use e.g.:
select output
from table(dbms_workload_repository.awr_report_text(1557521192, 1, 5390, 5392);
Or to get a HTML report, use awr_report_text() instead.
The first paramter is the DBID which can be obtained using:
select dbid from v$database
The second one is the instance number. Only relevant for a RAC environment.
And the last two parameters are the IDs of the start and end snapshot. The available snapshots can be obtained using:
select snap_id,
begin_interval_time
end_interval_time
from dba_hist_snapshot
order by begin_interval_time desc;
Especially for the HTML return - which returns a CLOB - you must configure your SQL client to properly display the output. In SQL*Plus you would use set long
conn / as sysdba
SQL> #$ORACLE_HOME/rdbms/admin/awrrpt.sql
Specify the Report Type
AWR reports can be generated in the following formats. Please enter the
name of the format at the prompt. Default value is 'html'.
'html' HTML format (default)
'text' Text format
'active-html' Includes Performance Hub active report
Enter value for report_type:
old 1: select 'Type Specified: ',lower(nvl('&&report_type','html')) report_type from dual
new 1: select 'Type Specified: ',lower(nvl('','html')) report_type from dual
Type Specified: html
old 1: select '&&report_type' report_type_def from dual
new 1: select 'html' report_type_def from dual
old 1: select '&&view_loc' view_loc_def from dual
new 1: select 'AWR_PDB' view_loc_def from dual
Current Instance
2. you can schedule report by email alert also.

Oracle - Log the executed query

I have to debug stored procedure which contains a few SQL queries. One of them contains an error. So, I need to execute this SQL query with parameters in other window. I found next query that would help me:
select v.SQL_TEXT
from v$sql v
Unfortunately, this field restricted by 1Kb. In my case I have quite big SQL query and Oracle truncates it. How to log the executed query? I use PL/SQL Developer 10 and Oracle 9i
Unfortunately, this field restricted by 1Kb
If you need the full SQL, then use the SQL_FULLTEXT which is a CLOB datatype instead of SQL_TEXT whcih is limited to first 1000 characters.
From documentation,
Column Datatype Description
------ -------------- ---------------------------------------
SQL_TEXT VARCHAR2(1000) First thousand characters of the SQL
text for the current cursor
SQL_FULLTEXT CLOB Full text for the SQL statement exposed
as a CLOB column. The full text of a SQL
statement can be retrieved using this
column instead of joining with the
V$SQL_TEXT dynamic performance view.
So, use:
SELECT SQL_FULLTEXT FROM v$sql;
By the way, seems like you are actually looking for tracing your session to get the complete details of the procedure and the SQL statements involved. I would suggest to trace the session with level 4 i.e. with the addition of bind variable values.
See How to generate trace file – SQL Trace and TKPROF in Oracle

What does "rows processed" in Oracle AWR report mean?

I have an application which uses Oracle Database. I have several sql updates and selects in the application.
I gathered an AWR report on Oracle Database to diagnose some performance charasteristics of my application.
When I analyze the report by checking the "SQL ordered by Executions" statistics, I found out that one of my update query run 8985 times and row number processed by this query is 8,985. But, I have a select query and it run 8,985 times too but row number processed by this select statement is 8936.
My select query is right after the update query so it is expected that both queries' executed time is equal. What I wonder is, why my select query processed less row than its executed time value.
Thanks
conn / as sysdba
SQL> #$ORACLE_HOME/rdbms/admin/awrrpt.sql
Specify the Report Type
AWR reports can be generated in the following formats. Please enter the
name of the format at the prompt. Default value is 'html'.
'html' HTML format (default)
'text' Text format
'active-html' Includes Performance Hub active report

Oracle Total Recall and Views

I'm creating a fairly in-depth temporal database prototype in which we are using Oracle's Total Recall to manage transaction times.
My test dataset has about 150k current rows along with 170k retired rows loaded into a FLASHBACK ARCHIVE enabled table. The augmented SQL queries (like the first one below) are executing correctly providing the appropriate data results.
select *
from CUT_BLOCK_COMBO AS OF TIMESTAMP FROM_TZ(TO_TIMESTAMP('2007-08-28 00:00:00','YYYY-MM-DD HH24:MI:SS'), 'UTC')
WHERE CB_SKEY = 4141;
This select statement returns the following data:
CB_SKEY HVA_SKEY FOREST_FILE_ID CUTTING_PERMIT_ID TIMBER_MARK CUT_BLOCK_ID
----------- ----------- -------------- ----------------- ----------- ------------
4141 53094 A80053 80053 29025
However once I wrap the table up into a view, I can no longer query the data with the 'AS OF TIMESTAMP' clause.
create or replace view CUT_BLOCK_COMBO_VW as select * from CUT_BLOCK_COMBO;
select *
from CUT_BLOCK_COMBO_VW AS OF TIMESTAMP FROM_TZ(TO_TIMESTAMP('2007-08-28 00:00:00','YYYY-MM-DD HH24:MI:SS'), 'UTC')
WHERE CB_SKEY = 4141;
The select statement from the view returns the following error: ORA-01466: unable to read data - table definition has changed
Any ideas what I missed when creating the view definition? I couldn't find anything in the docs (Oracle Total Recall 11G R2)
Does it work as an in-line view?
I would suspect that the view would have to have existed as-of the timestamp. Possibly the code is looking for the create date or last DDL time on the object against which you are using AS OF.
Just a theory, but you could test it pretty easily I think, and possibly prove the theory by tracing the execution.
If that's the case then I can't think of a safe workaround I'm afraid.

Resources