Quantcast
Channel: ODTUG Aggregator
Viewing all 2258 articles
Browse latest View live

Give Back at Kscope17 Community Service Day

$
0
0
Once again, our Kscope17 attendees will have the opportunity to give back to the host community by volunteering on the Saturday before the official start of the conference. Community Service Day is Saturday, June 24, 2017.

Where, Oh Where Has My Little Tweet Gone?

$
0
0
Recently, as part of the Oracle ACE renewal process, I was tasked with gathering statistics around my tweets. How many tweets were about Oracle? How many tweets about Cloud? How many tweets about Cloud? (not a typo) Now, I knew of the advanced search capabilities accessed here:

https://twitter.com/search-advanced




What I was not aware of was just how powerful the simple Search field is on the Twitter header bar. Log into twitter.com and in the upper right area of the screen, you see something like this.





You can get super creative identifying specific hashtags, users, accounts, and date ranges. Let's look at some examples...

Say I want to see all my tweets since October 1, 2016. All you do is enter into the search field:

     from:monty_latiolais since:2016-10-01

Pretty cool, eh?

Here are some additional searches you can easily perform right from the basic Search field.

Display all my tweets between a certain date range

     from:monty_latiolais since:2016-10-01 until:2016-10-15


Display all my tweets to another account (example: odtug)

     from:monty_latiolais @odtug


Display all my tweets to multiple accounts (example: odtug or insum_solutions)

     from:monty_latiolais @odtug OR @insum_solutions


Display all my tweets that include hashtag #kscope16

     #kscope16 from:monty_latiolais


Display all my tweets that include hashtag #kscope16 or hashtag #kscope17

     #kscope16 OR #kscope17 from:monty_latiolais


Display all my tweets that include the word 'chicago'

     chicago from:monty_latiolais


Finally, display all my tweets that include the word 'chicago', but not the word '5k', within a date range, that includes hashtag #oracle

     chicago -5k #oracle from:monty_latiolais since:2014-07-01 until:2016-11-22




...our journey continues



Wrestling with session state

$
0
0
Today I was asked to implement change detection in an Apex page. This page used a custom PL/SQL process instead of the standard Apex transaction processing. In this setup users can overwrite each others transaction. This can be fixed by calculating a checksum over the queried items and comparing that to a checksum on the same items before applying the changes. If the checksums are equal, no one else has changed these items, otherwise the current user should be warned.

I decided to create a checksum item P200_CHECKSUM at the top of the page. The page contained a dynamic form that was generated in a PL/SQL region. In order to preserve performance I added the checksum calculation to the PL/SQL region. The resulting checksum was written to :P200_CHECKSUM in session state. With PL/SQL code at the beginning of the save process the checksum was checked.

But it did not work! The checksum was calculated and I could see the value with Show session. But debugging showed that the checksum used in the save process was empty. It took me a while to figure out what was happening.

It was all about rendering order:
- at first the P200_CHECKSUM item was rendered with value null
- then the checksum was calculated and put into session state

At submit the value of P200_CHECKSUM in session state was updated with the value from the page (which was null). This is why the value of P200_CHECKSUM was empty in the save process.

Once I understood this the solution was easy: just put the P200_CHECKSUM item in a region that is rendered after the calculation.

An alternative solution is to use a PL/SQL Dynamic Action with the P200_CHECKSUM in the Page items to return. The PL/SQL code can be null;. The DA fills the value of the page item P200_CHECKSUM with the value in session state. Drawbacks of this solution are extra network traffic and a slight delay in the setting of the value.

Experiment

The above led me to set up an experiment on session state and items rendered. The session state is set at several process points, with items showing the result on the page. Session state is set by either using bind variable notation or with apex_util.set_session_state.
The image below comprises the result after the page is run.



Several conclusions can be drawn:
- there is no difference between using bind variables and set_session_state
- from the normal Apex process points only the value set After Region is not rendered
- as expected from my experience the item set in the PL/SQL procedure is only rendered after the procedure has run
- the session state set in a display item is also available in previous items. The debug listing shows that the query for populating the display item is executed before the regions.

Happy apexing!


Wrestling with session state

$
0
0
Today I was asked to implement change detection in an Apex page. This page used a custom PL/SQL process instead of the standard Apex transaction processing. In this setup users can overwrite each others transaction. This can be fixed by calculating a checksum over the queried items and comparing that to a checksum on the same items before applying the changes. If the checksums are equal, no one else has changed these items, otherwise the current user should be warned.

I decided to create a checksum item P200_CHECKSUM at the top of the page. The page contained a dynamic form that was generated in a PL/SQL region. In order to preserve performance I added the checksum calculation to the PL/SQL region. The resulting checksum was written to :P200_CHECKSUM in session state. With PL/SQL code at the beginning of the save process the checksum was checked.

But it did not work! The checksum was calculated and I could see the value with Show session. But debugging showed that the checksum used in the save process was empty. It took me a while to figure out what was happening.

It was all about rendering order:
– at first the P200_CHECKSUM item was rendered with value null
– then the checksum was calculated and put into session state

At submit the value of P200_CHECKSUM in session state was updated with the value from the page (which was null).
This is why the value of P200_CHECKSUM was empty in the save process.

Once I understood this the solution was easy: just put the P200_CHECKSUM item in a region that is rendered after the calculation.

An alternative solution is to use a PL/SQL Dynamic Action with the P200_CHECKSUM in the Page items to return. The PL/SQL code can be null;. The DA fills the value of the page item P200_CHECKSUM with the value in session state. Drawbacks of this solution are extra network traffic and a slight delay in the setting of the value.

Experiment

The above led me to set up an experiment on session state and items rendered. The session state is set at several process points, with items showing the result on the page. Session state is set by either using bind variable notation or with apex_util.set_session_state.
The image below comprises the result after the page is run.

Several conclusions can be drawn:
– there is no difference between using bind variables and set_session_state
– from the normal Apex process points only the value set After Region is not rendered
– as expected from my experience the item set in the PL/SQL procedure is only rendered after the procedure has run
– the session state set in a display item is also available in previous items. The debug listing shows that the query for populating the display item is executed before the regions.

Happy apexing!

Source Article from http://dickdral.blogspot.com/2016/11/wrestling-with-session-state.html

Setting item session state using AJAX in APEX 5

$
0
0
You probably know about the old way how to do this with htmldb_Get JS object:

var get =new htmldb_Get(null, $v('pFlowId'), null, 0);
  get.add('F_APP_ITEM', vNewItemValue);
gReturn = get.get();

You can find more about "the old way"here.

But If you've read APEX 5 Release Notes carefully you know that htmldb_Get object is deprecated and it's moved to legacy.js - and you don't what to use legacy JS in your new, modern and shiny APEX 5 applications. You should use apex.server.process or apex.server.plugin for plugins.

So, how can you do it in APEX 5?
It's easy if you want to set current page item values to session state. For this you have a parameter pageItems which can be of type jQuery selector, jQuery or DOM object or array of item names that identifies the page items:

apex.server.process ('MY_PROCESS', 
{
pageItems:'#P1_DEPTNO,#P1_EMPNO'
},
{
success:function(pData) { ... do something here ... }
}
);

But if you want to do some calculations before request or if you want to set application item value to session state you have to dig a bit deeper into the documentation where you can find that with pData parameter of AJAX requests you can set additional parameters that the wwv_flow.show procedure provides.

If you need to set session state of only one item (page or application) you can use parameters p_arg_name and p_arg_value:

apex.server.process ('MY_PROCESS', 
{
p_arg_name:'F_APP_ITEM',
p_arg_value: vNewAppItemValue
},
{
success:function(pData) { ... do something here ... }
}
);

If you need to set session state of more than one item (page or application) you have to use parameters p_arg_names and p_arg_values where you have to pass JS array as parameter:

apex.server.process ('MY_PROCESS', 
{
p_arg_names: ['F_APP_ITEM','P1_DEPTNO'],
p_arg_values: [vNewAppItemValue, vNewItemValue]
},
{
success:function(pData) { ... do something here ... }
}
);

Enjoy!


Tested on APEX 5.0.4.00.12

Performance aspects of APEX reports

Oracle APEX Printing Options

$
0
0

Oracle APEX Printing Options

Since it arrived on the scene way back in 2004, Oracle Application Express (APEX) has been criticized for the lack of print capabilities. While there is no good viable built-in printing solution, the APEX community has stepped up and now there are many options using different technologies and pricing models. Today, you can decide between BI Publisher, JasperReports, PL-jrxml2pdf, PL/PDF, ORDS and APEX Office Print, to name a few. The choice is yours.

When deciding on a printing solution you should consider things like “is a license required”, “how are layouts handled”, “what output formats are supported”, and “overall ease of use”.

Let’s briefly look at these options one by one.


Oracle BI Publisher Oracle Bi Publisher Logo

For many years, I used Oracle Reports to handle my APEX reporting needs. Long marketed as “any data, any format, anywhere”, Oracle, however, has made no bones about Oracle Reports not being a strategic option going forward. That way forward is Oracle BI Publisher. It is in every way Oracle’s flagship reporting tool, however, it comes with a hefty price tag.

Oracle has made it easy for business users to maintain a variety of graphs and reports. While developers would still need to expose necessary data points, the presentation layer can be  created using a MS Office add-on. Business users can then markup an Office document and reference these fields as variables.

Pros:

  • Oracle’s strategic direction
  • Templates can be maintained by end users using MS Office
  • Plenty of examples used with APEX
  • Interactive dashboards in addition to printing

Cons:

  • High cost of licensing when compared to other options
  • Office plugins may be an obstacle for some end users

Architectural Diagram:

Bi Publisher Architectural Diagram

From the field:

“BI Publisher is the preferred Oracle solution for pixel-perfect reporting. Also used for Mobile Application Designer and for direct SQL reporting in OBIEE, BI Publisher is a strategic reporting solution across multiple product lines. When it comes to printing in APEX, I’d use BI Publisher, because I know it’s capabilities, and I know it has legs.”

Stewart Bryson, Red Pill

 


JasperReportsJasper Reports Logo

JasperReports provide you very powerful reporting capabilities. You can produce pixel-perfect documents that can be viewed, printed or exported in a variety of document formats including HTML, PDF, Excel, OpenOffice and Word.JasperReports are 100% Java and 100% free of charge.

Using JasperReports is quite straightforward. A third-party graphical design tool called iReport is commonly used to aid in report design. The resulting report is saved in the form of a JRXML file which is a specialized XML format. The compiled version of the JRXML report file has a .JASPER extension and is submitted to the JasperReports server for execution.

Pros:
  • Free. No license required
Cons:
  • Requires some server setup
Architectural Diagram:

Jasper Architectural Diagram

 


PL-jrxml2pdf

PL-jrxml2pdf is a PL/SQL-program which takes a report-definition in jrxml-format and generated a PDF-result from it. It’s pure PL/SQL, so there’s no need for any middleware. 

The process is very straightforward. First, design your reports using iReports which results in an JRXML file. then use PL-jrxml2pdf as runtime-engine to generate PDF from PL/SQL.

The software comes with an Oracle APEX-application which installs all required objects and samples. Also the APEX-application allows you
– to manage all PL-jrxml2pdf-objects
– to run reports
– to view logs written when running a report

Pros:

  • Free. No license required
Cons:
  • Output limited to PDF

PL/PDFplpdf

PL/PDF is a collection of PL/SQL packages to create PDF/XLSX/DOCX documents directly from your PL/SQL program without having to install third party drivers or software. Originally, there was no real GUI for PL/PDF and layouts were administered via a series of API calls. Recently, PL/PDF has come out with the PL/PDF Reporter which allows templates to be created using Microsoft Word.

It’s capable of generating PDF, DocX and XLSX files as well as processing XLSX sheets into your Oracle database.

Pros:
100% PL/SQL
Installs into same DB as APEX

Cons:
Maintenance of long report layouts can be tedious

From the field:

“PL/PDF is a great choice when you’re faced with complex business rules. For example, you need to create a report based on a subset of 5 templates, and depending on which products are included in a template, you may have to attach additional documents or even send out notifications. Since the core is PL/SQL, it’s trivial to handle situations like this with PL/PDF, and I typically keep it at the top of my list of recommended tools.”

Scott Spendolini, Sumneva


Oracle REST Data Services (ORDS)ORDS Logo

Oracle Application Express in conjunction with the Oracle Rest Data Services (ORDS) allows you to configure a classic report region, interactive reports and report queries to print by exporting it to an Adobe portable document format (PDF), Microsoft Word rich text format (RTF), Microsoft Excel format (XLS), or Extensible Markup Language (XML). By taking advantage of region report printing, your application users can view and print reports that have a predefined orientation, page size, column headings, and page header and footer.

Pros:
Free
No need to configure external printing engine

Cons:
Complex layouts require XSLT editors such as Altova Stylevision or Stylus Studio

Architectural Diagram:

ORDS Architectural Diagram

From the field:

“FOP is built into ORDS (previously known as APEX Listener), meaning you get out-of-the-box PDF printing with APEX with no additional configuration required. When compared to third-party solutions, the built-in printing options provide you with full access to your current session state and application data – no separate database connection or authentication needed.”

Marc Sewtz, Oracle Corporation

 


APEX Office Print (AOP)AOP Logo

This is the newest kid on the block and making quite a splash. Part of the reason is it comes from the mind of Dimitri Gielis, part of the reason is it’s that good. It is the only PrAAS option available. PrAAS is my own acronym that stands for PRinting As A Service. AOP can also be installed on-premise.

Like many of the printing tools, APEX Office Print segregates the data preparation from the data presentation process. The data preparation is a query that aggregates and organizes the data in JSON format.There is HUGE power with the JSON data structures. You can accommodate multiple detail data sets or “loops” within your report.

One of the most amazing tools is AOP’s ability to “print” an APEX interactive report. In your MS Word or MS Excel template, you can put the phrase {&interactive}. The actions taken in your interactive report will be shown in your report. Did you use sorting? Hide / Show columns? Aggregate and have control breaks? Well, these will all appear in your report.

Your reports can be PDF, Word, Excel or PowerPoint

Pros:

  • Ease of installation and setup
  • Templates can be created using Word, Excel or Powerpoint and without the need of plugins
  • Can be called via the provided APEX Plugin or PL/SQL API
  • Works with any technology that can call a REST API. It doesn’t require a database of any kind to work.
  • Assist template creation with auto creation of initial template based on data provided

Cons:

  • Minimum APEX version 4.2
  • License required

Architectural Diagram:

AOP Architectural Diagram

From the field:

“APEX Office Print is the only solution integrated with APEX e.g. print of Interactive Report.
Very simple to use! Very simple to setup!”

Dimitri Gielis, Apex R&D

 


Summary

BI PublisherJasperReportsJRXML2PDFPL/PDFORDSAOP
LicenseYesNoNoYesYesYes
TemplateRTFJRXMLJRXMLPL/SQLXSL-FODOCX
XSLX
PPT
OutputANYANYPDFPDF
DOCX
XSLX
PDF
WORD
XSLX
PDF
DOCX
RTF
XSLX
PPT
Ease of Use* ** ** * **** * *

 


The post Oracle APEX Printing Options appeared first on Insum.

Ordering & Formatting Date Columns in APEX

$
0
0
Quite often I'll find I'd like to display a date with the time in a column within an APEX report, but you end up wondering how to control the wrap.

This is one problem that probably has a half dozen solutions, but I think this is the cleanest. And blogging about it helps me remember next time.

Depending on your screen size, you might be faced with something that takes up too much space per row.

not a good wrap

One solution is to turn that column into a formatted character string
,to_char(created_date,'DD-MON-YYYY"<br>"HH24:MI:SS') created_date
Note the HTML break tag surrounded by double quotes, this will put the time on the next line.

Combine this with styling on the column to stop wrapping.
Column setting CSS Style: white-space:nowrap
And you'll get a neater output.

If column is varchar, won't order nice

But there's a problem. And it's a deal breaker if you want to allow the user to order the column.
Your output will be ordered Apr, Aug, Dec, Feb, Jan... sense a trend? Alphabetical, not chronological.
Applying formatting within SQL is something you generally want to avoid.

Instead, just use the funky date format mask and apply it in a declarative manner within the column attributes, along with the CSS Style. This will allow the report to honour the appropriate ordering on the date columns, whatever format mask you require.

Declarative column attributes, using DD-MON-YYYY "<br>"HH24:MI:SS

Either way you need to set "Escape special characters" to No. I think your individual date values will be safe from cross site scripting.

These settings, along with the other Column Formatting options are used frequently in my applications, particularly HTML Expression. Just remember, if you use style frequently, define a class in your page/application/theme CSS definition and use that instead.
.date_fmt {white-space:nowrap;}

#letswreckthistogether


Interactive Report Alternating Rows

$
0
0

For classic reports there is a region attribute template option to have the rows have alternating row color.


That template option is not part of the interactive report template options.


We can achieve the same effect in an interactive using once again some CSS.

.customAlternatingRow.t-IRR-region .a-IRR-table tbody tr:nth-child(odd) td {
background-color: yellow;
}

.customAlternatingRow.t-IRR-region .a-IRR-table tbody tr:nth-child(even) td {
background-color: yellowgreen;
}

The only thing left to do is to add the "customAlternatingRow" class to your region (under Appearance, CSS Classes).

It will then look like this:

The classic report is only using  #fcfcfc (very light gray) for the odd rows and nothing for the even rows.

.customAlternatingRow.t-IRR-region .a-IRR-table tbody tr:nth-child(odd) td {
background-color: #fcfcfc;
}

Which would look like this:

Browser Support of the :nth-child() Selector (from w3schools)

SelectorChromeIEFirefoxSafariOpera
:nth-child()4.09.03.53.29.6

Right Side Column Page and Validation Error Message Region

$
0
0
If you ever used the "Right Side Column" page template, you might have noticed that the validation error message region is displayed under the right side region's expand/collapse trigger button.


As you can see above, the expand/collapse trigger button is on top of the close notification "X" button.

There are two ways to go in order to fix that, both using CSS only.

The first method is to add some right margin to the notification region.

.js-rightExpanded .t-Body-content .t-Body-alert,
.js-rightCollapsed .t-Body-content .t-Body-alert {
margin-right: 40px; /* Width of the right side region's trigger button */
}

It will then look like this:

The second method is to reposition the notification region on top of the right side region's trigger button.

.js-rightExpanded .t-Body-content .t-Body-alert,
.js-rightCollapsed .t-Body-content .t-Body-alert {
position: relative; /* Need to position the div for the z-index to work */
z-index: 500; /* z-index of right side column is 490 */
}

It will then look like this:

APEX 5 DA when cancelling modal dialog

$
0
0

I needed to have a dynamic action that fires when a modal dialog is cancelled or the escape key is pressed. To do this in APEX 5, on the parent page, you can create a dynamic action based on a custom event called dialogclose.

Parent page:
Custom Dynamic Action

When:
Event: Custom
Custom Event: dialogclose
Selection Type: JavaScript Expression
JavaScript Expression: document

The True/False actions can be set as usual, such as refreshing a report or setting some value.

 

 


OTN Appreciation Day: The Java VM in the Oracle Database

OTN Appreciation Day : Oracle Database Cloud Service

$
0
0
Looking at my cup , had the caption "If we don't take care of the customer... somebody else will" this morning made me realize the enormous effort that Oracle has putting into it's products to make it a topnotch brand. Omg! so much to choose from and talk about.Today been OTN Appreciation Day ,I will limit it to the Oracle Database Cloud Service

It is simply Database Development and Administration computed on the internet.Where in the past , you run applications developed  and administrated the database(APEX, Rest Services,PLSQL ,Java/ADF.s,etc) on some physical computer or server in your company building or at home but Oracle Database Cloud Service is just like your on premise instance just on the internet, giving you the same features, same software and same options.

You can get started and explore the endless features that it comes with here.
Also go check out what others are thankful for here.


Exadata migration

$
0
0
Had a wonderful Sangam16 conference in India, and received much applaud for the two presentations delivered,  Oracle 12c multitenancy and Exadata migration best practices.

After a very short trip to India, life started to be business as usual again, and become busy. Was fully occupied with multiple assignments: Oracle EBS database health check assessment at a client for 2 days, GI/RDBMS/PSU deployments on Oracle Sun Super Cluster M7, Exadata configuration preparation and 9 databases migration to Exadata during the week-end.

Over the last week-end, we (me and my colleague) were pretty busy with 9 databases migration to Exadata. There were a few challenges , and learned a few new things too. I would like to discuss couple of scenarios that were interesting:

One of the databases had corrupted blocks, and the expdp was keep failing with ORA-01555: snapshot too old: rollback segment number  with name "" too small. Our initial thoughts were tuning undo_retention, increasing the undo tablespace, setting an event, etc. Unfortunately, none of the workarounds helped in the situation. We then cameacross a MOS note which explains that an ORA-01555 with "", no rollback segment name is probably due to corrupted blocks. After applying the solution explained in the note, we managed to export/import the database successfully. My colleague has blogged about the scenario at his blog: http://bit.ly/2fBOxm7

Another database is running on Windows x86 64-bit, and its full of LOBs, hence, the datapumps (expdp) took significant time, as NFS filesystem used to store the  dump file. We then thought of doing direct RMAN restore from source to target, as the database on Windows x86 64bit and Linux x86 64-bit are the same (Litten) Endian formats. As per one of the MOS notes, we can also do the Data Guard setup, and do RMAN restore. However, RMAN recovery would fail with ORA-600, as cross platform redo conversion won't be possible. We are now thinking of taking a cold backup (consistent) and do a complete restore with reset logs option.

Stayed tuned for more updates on this.



Tablespaces verkleinern (TEMP, USER_TS, ORA-03297)

$
0
0

Info
Die Select-Statements in diesem Blogpost habe ich von anderen Webseiten kopiert. Daher ist dieser Beitrag eher als Zusammenfassung unterschiedlicher Lösungsversuche zu sehen und dient mir als schnelle Hilfe bei der Verkleinerung eines zu großen Tablespaces. Schaut euch die Quellen an, die sehr viel detaillierter auf die jeweiligen Probleme eingehen.

Wer kennt nicht die Situation? Der DBA ruft an und meint der TEMP Tablespace verbraucht mehrere hundert Gigabyte an Speicher.

Was ist in solch einer Situation zu tun?
In dem Moment wo ein TEMP Tablespace überproportional ansteigt, muss eine Session diesen Anstieg verursachen. Mit dem folgenden Select erfahren Sie welche Session wie viel Speicher im TEMP-Tablespace verbraucht.

-- Source: http://stackoverflow.com/questions/174727/discover-what-process-query-is-using-oracle-temp-tablespace
select b.tablespace
, b.segfile#
, b.segblk#
, round ( ( ( b.blocks * p.value ) / 1024 / 1024 ), 2 ) size_mb
, a.sid
, a.serial#
, a.sql_id
, a.username
, a.osuser
, a.program
, a.status
from v$session a
, v$sort_usage b
, v$process c
, v$parameter p
where p.name = 'db_block_size'
and a.saddr = b.session_addr
and a.paddr = c.addr
order by b.tablespace
, b.segfile#
, b.segblk#
, b.blocks;

Über die SQL_ID können Sie wenn vorhanden auch auf das Verursacher-Select zugreifen:
-- Source: http://cheatsheet4oracledba.blogspot.de/2014/01/how-to-find-top-temp-using-oracle.html
select sql_text
from v$sql
where sql_id='b6kta08q9jj3f';

Über den SQL Developer > Tools > Monitor Sessions können Sie die betroffene SID killen.

Anschließend wird der Verbrauch des TEMP-Tablespace zwar wieder zurückgefahren, aber die Größe bleibt bestehen.

Prüfen Sie daher zunächst die aktuelle verwendete Größe im TEMP-Tablespace:
-- Source: https://alexzeng.wordpress.com/2012/06/13/how-to-find-the-sql-that-using-lots-of-temp-tablespace-in-oracle/
select b.total_mb,
b.total_mb - round(a.used_blocks*8/1024) current_free_mb,
round(used_blocks*8/1024) current_used_mb,
round(max_used_blocks*8/1024) max_used_mb
from v$sort_segment a,
(select round(sum(bytes)/1024/1024) total_mb from dba_temp_files ) b;

-- Oder:
select * from dba_temp_free_space;

Wenn der Wert (current_used_mb) entsprechend klein ist, dann können Sie den TEMP-Tablespace verkleinern, andernfalls haben Sie nicht die richtige Session gekillt.

TEMP-Tablespace verkleinern:
select file_name,bytes,blocks from dba_temp_files;
-- .../tempfile/temp.911 564863696896 68953088

alter tablespace temp shrink space;

select file_name,bytes,blocks from dba_temp_files;
-- ../tempfile/temp.911 289513472 35341


Es kann aber auch vorkommen das eine normaler Tablespace zu groß wurde und dadurch viel mehr Platz verbraucht als es aktuell verwendet.
Um darüber einen Überblick zu erhalten, führen Sie folgendes Select aus:
 -- Source: Nicht mehr bekannt :(
select
mb.*
,nvl(round(100 * freemb / sizemb,1),0) free_prozent
from
(select
b.tablespace_name
,round(tbs_size,2) as sizemb
,a.free_space freemb
from
(select
tablespace_name
,round(sum(bytes)/1024/1024 ,2) as free_space
from dba_free_space group by tablespace_name
) a
,(select
tablespace_name,
sum(bytes)/1024/1024 as tbs_size
from dba_data_files group by tablespace_name
union
select
tablespace_name,
sum(bytes)/1024/1024 tbs_size
from dba_temp_files
group by tablespace_name
) b
where a.tablespace_name(+)=b.tablespace_name
) mb
order by free_prozent;

Bei einer solchen Situation muss anstelle des Tablespaces die Datendatei verkleinert werden.
Nun benötigen Sie dafür noch den richtigen Dateinamen, um die korrekte Datei zu verkleinern:
SELECT 
name,
bytes/1024/1024 AS size_mb
FROM v$datafile
;

Statement zum verkleinern der Datendatei:
ALTER DATABASE DATAFILE '.../DATAFILE/my_schema.033.123331' RESIZE 3G

Die Verkleinerung kann aber in einem ORA-03297 Fehler enden.

ALTER DATABASE DATAFILE '.../DATAFILE/my_schema.033.123331' RESIZE 3G
Error report -
SQL Error: ORA-03297: file contains used data beyond requested RESIZE value

Jetzt bleiben Ihnen 3 Schritte um mit geringem Aufwand diese Datei doch noch zu verkleinern:

1. Fragmentierung bereinigen
Die Datendatei wurde fragmentiert und eine Tabelle liegt am Ende der Datei und verhindert dadurch die Verkleinerung.

Beispiel:
Die Datendatei ist 90 GB groß und tatsächlich werden nur 2 GB verwendet.
Eine Tabelle liegt von der Verteilung her zwischen 82-83 GB. Heißt, ich könnte die Datendatei nur auf 84G verkleinern. Also müssen Sie in solch einem Fall das Objekt ausfindig machen und löschen. Sinnvollerweise kopiere ich vorher die Tabelle in einen anderen Tablespace, um diese anschließend wieder herstellen zu können. :)

Um die Blockverteilung analysieren zu können, muss vorher die richtige File-ID ausgelesen werden:
select 
s.tablespace_name, s.owner, s.segment_name, s.segment_type,
sum(s.bytes) size_in_bytes,
round(sum(s.bytes) / 1024 / 1024, 2) size_in_m,
sum(round(sum(s.bytes) / 1024 / 1024, 2)) over() as size_in_m_gesamt,
f.file_id,
f.file_name
from sys.dba_segments s, sys.dba_data_files f
where f.tablespace_name = s.tablespace_name
and f.file_id = s.header_file
and s.tablespace_name in ('NTDC03')
group by s.tablespace_name, s.owner, s.segment_name, s.segment_type, f.file_id, f.file_name
order by s.tablespace_name, s.owner, s.segment_name;

Das folgende Select zeigt die Blockverteilung mit den verwendeten DB-Objekten innerhalb der Datendatei:
 Source: http://www.orait.de/db_fehler/ora-03297_file-contains-used-data-beyond.html
select
file_id,
block_id,
blocks*8192/1024/1024 as mb,
owner||'.'||segment_name as object_name,
block_id*8192/1024/1024 as position_mb
from sys.dba_extents
where file_id = 206
union
select
file_id,
block_id,
blocks*8192/1024/1024 as mb,
'Free' as object_name,
block_id*8192/1024/1024 as position_mb
from sys.dba_free_space
where file_id = 206
order by 1,2,3;


Wenn Sie die betroffenen Tabellen gelöscht haben, dann klappt auch die Verkleinerung wieder:  
ALTER DATABASE DATAFILE '.../DATAFILE/my_schema.033.123331' RESIZE 3G 
Database datafile '.../DATAFILE/my_schema.033.123331' altered.

2. Recycle Bin löschen
purge recyclebin;

3. Coalesce Tablespace
alter tablespace fred coalesce;

Answer with SQL: How many weekdays a year?

$
0
0
I'm a big fan of generating data with dual, using a perk of the connect by syntax.

I think Tom Kyte was the originator of this technique. It's not necessarily the fastest method, but it's super convenient - no table required.

Today I wanted to know how many weekdays a year, so I defined 365 rows on the fly using sysdate to turn these into each day of the year. Then I ran a simple select over this to aggregate my result
with years as (
select to_char(trunc(sysdate,'yy')+rownum-1,'dy') dy
from dual
connect by level <= 365
)
select count(*)
,sum(case when dy in ('sat','sun') then 1 end) weekends
from years
You can see this demonstrated at livesql.oracle.com
https://livesql.oracle.com/apex/livesql/file/content_D6ZWKMK4O2IVMWGOAXIDEP61M.html
Never heard of it? I recommend you have a play. I've only dabbled myself, but if you don't have an environment to experiment with, this is free!



Upcoming ODTUG Webinars

$
0
0
Below is the list of upcoming webinars. If there is a topic you would like covered that is not on our current list, or if you would like to present a webinar, please email alicia@odtug.com. Did you miss a webinar? Our Webinar File Library lists all of our webinars and can be filtered by subtopic...

Promote #KscopeGivesBack on Giving Tuesday

$
0
0
The ODTUG Twitter profile will be posting a number of tweets promoting Community Service Day throughout the day today, 11/29/16. We'd love to see as many posts and retweets as possible promoting the day using the #KscopeGivesBack hashtag!

OBIEE and Oracle APEX: “Discovering” Interactive Reports

$
0
0

OBIEE and Oracle APEX: “Discovering” Interactive Reports

Oracle Business Intelligence Discoverer is a powerful tool designed to assist you in querying, reporting and analyzing your data. However, Oracle has announced that there will be no new features or enhancements added beyond version 11.1.1.7.0, which will enter the “Sustained Support” phase of its life in June of 2017. Oracle recommends that Discoverer customers migrate to BI Foundation Suite, and that EBS customers move to Oracle BI Applications. There is certainly nothing wrong with following these recommendations, as long as you don’t consider additional licensing fees and the acquisition of a new skillset as anything wrong.

Migrating from Discoverer to “something else” is a scary proposition, because there again are the costs involved in acquiring a new product and a new skillset, and the possibility of complications in integrating with Oracle.

What if I told you that you already own a product that, while not an exact replacement of Discoverer, can accomplish many of the tasks that you were using Discoverer to do, and does so with a user-friendly intuitive interface? That product is Oracle Application Express (APEX), and it is included as a no-cost add-on to the Oracle Database.

This blog posts looks at five common tasks that should be familiar with Discoverer users and explains how those same tasks are performed using Oracle APEX Interactive Reports. While the following tasks are accomplished in Discoverer using a variety of interfaces, all of the features we will be exploring can be accessed from an Interactive Report by selecting “Actions | Format” and then the specific feature.

oracle apex interactive reports

Computation

A standard practice of relational database design is to not store everything. If you can calculate a value and you don’t always need the calculated value, you just save what is necessary to get the value when you need it. Including these calculated values in a report typically requires the query that retrieves the data to include these formulas in order to display the calculated columns.

Discoverer users can add computed columns by selecting Tools | Calculations.

oracle apex calculation

Resulting in the following…

oracle interactive reports calculation

APEX Interactive Reports allows you to add calculated columns to your report by selecting Actions | Format | Compute.

oracle apex interactive reports compute

The new column, ‘Year_Sal’, has been highlighted for clarity.
oracle apex interactive reports compute

Aggregation

When reporting against numeric data, it is often desirable to include aggregations such as the total or average amounts.

Discoverer allows for the definition of aggregate columns by selecting Tools | Totals.

oracle apex interactive reports total

Line 15 displays the resulting aggregation.

interactive reports

Not surprisingly, APEX Interactive Reports makes including these aggregations a very simple matter indeed. All you need to do is select the column and aggregation type, and the additional information is included in your report.

disc_ir_008

interactive reports 2

Control Break

Often when viewing a report, the amount of information can be overwhelming, even if all of it is necessary. In cases such as this it is often useful to subdivide your report into multiple reports based on a one (or more) aspects of the data, thus removing repeated data elements.  

Using Discoverer, this is accomplished by selecting Tools | Sort then identifying the field or fields in which the data is to be grouped. Then under Group specify “Group Sort”

oracle apex interactive reports sort table

I’ve moved Deptno to column 1 for demonstration purposes.

oracle apex interactive reports deptno

APEX Interactive Reports allows you to easily create a “Control Break”. You simply need to select one or more columns to be used to subdivide your data, and apply the change to view your newly formatted report.

oracle apex interactive reports dname

Notice, the data is sorted on Dname.

oracle apex interactive reports dname 2

Pivot

Pivot tables are a very effective way of displaying normalized, relational table data in a more readable format. Historically, the biggest problem with pivot tables is that they were hard to create.

Within the Discoverer work area, you can create pivot tables by dragging a worksheet item heading from a “row” position to a “column” position.

disc_ir_014

Discoverer then redraws the worksheet with the new configuration.

oracle apex interactive reports display

APEX Interactive Reports has taken the drudgery out of creating pivot tables. You simply select the desired row and column configuration of your pivot table, as well as any functions that you want to apply to which columns, and APEX does the rest.

oracle apex interactive reports pivot tables

oracle apex interactive reports pivot tables 2

Export

The features we mentioned above are only a few of those provided by APEX Interactive Reports that allow you to modify the default design of a report. However, without the ability to share the resulting report, the perfection of its presentation is meaningless.

Oracle Discoverer does allow exporting of a single worksheet or workbook as XLS, HTML, TXT, CSV, PRN, DIF, SLK, and WKS.

oracle apex interactive reports export

With Interactive Reports, the Download feature allows you to output your report as a CSV file, an HTML file, an Excel worksheet, a PDF document, or an editable RTF document.

oracle apex interactive reports download

Conclusion

Discoverer users shouldn’t worry that moving to Oracle Application Express (APEX) will result in decreased functionality. Quite the contrary!  Oracle APEX is a soft place to land because as this blog demonstrated, Interactive Reports can meet or exceed existing Discoverer functionality in the areas of Computations, Aggregations, Control Breaks, Pivots and Exports.

If you have a complex Discoverer example and question whether APEX is up to the task, please contact me for a free consultation.

Contact Us

The post OBIEE and Oracle APEX: “Discovering” Interactive Reports appeared first on Insum.

Stop typing and generate you substitution code

$
0
0
Some years ago I attended a presentation of John Scott in which he demonstrated the use of substitution for producing a string from a number of variables.

Up to that moment I used concatenation for generating strings from variables:

l_html &nbsp;:= '<input id="'||l_id||'" onclick="test('''||l_value||''')" type="text" />';  

Even a relative simple expression like this is hard to read. Moreover it is not easy to see whether the quotes are placed at the right position and quantity.

So John's solution to this is to start with a string with delimited placeholders and replacing the placeholders with their value one by one. So the code gets:

l_html := q'!<input id="#ID#" onclick="test('#VALUE#')" type="text" />!';  
l_html := replace(l_html,'#ID#',l_id);
l_html := replace(l_html,'#VALUE#',l_value);

This code is much more readable and the html can be checked easily.
I have been using this design pattern a lot since then.

But the typing annoys me. Typically something to automate! So this morning, when I was getting ready to type a list of replace statements for the 1001st time I decided to create a small tool to generate these lines.



Paste the string with placeholders into the form and change the other parameters to your preferences. Press generate and you can copy the resulting code into your PL/SQL.
The generation presumes that the names of the variables containing the values to be replaced are equal to the placeholder names. Doing this also improves the readability of the code.

The utility can be used online at http://www.speech2form.com/ords/f?p=141:600

Happy apexing!
Viewing all 2258 articles
Browse latest View live