Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Analytic / Model requirement

Jonathan LewisJun 22 2015 — edited Aug 15 2015

This is a puzzle I've set myself following a discussion about making choices between SQL and PL/SQL - so it's not urgent, not important, and not serious.

If I query dba_extents for a given table (e.g. sys.source$) the extent information looks like this:

select file_id, block_id, blocks

from dba_extents

where owner = 'SYS'

and segment_name = 'SOURCE$'

order by file_id, block_id

;

   FILE_ID   BLOCK_IDBLOCKS

---------- ---------- ----------

1504     8
8168     8
8176     8
8192     8
8288     8
8440     8
1 10072     8

...

1 77568   128
1 77696   128
1 77824   128
1 78080   128
1 89984   128

...

1 90752  1024

80 rows selected.

I have a piece of code which reads the exent list, joins it to a list of numbers to enumerate every block in each extent, sorts the blocks by file_id and block_id, applies an ntile(12) to result set, then picks the first and last block in each tile to produce an output which is essentially 12 rows of (first_file_id, first_block_id, last_file_id, last_block_id) - which I can convert to a covering set of rowid ranges for the table.  (This is essentially what dbms_parallel_execute does when you create rowid chunks - except it uses PL/SQL to do it).

My SQL does exactly the job needed, but is significantly slower than the PL/SQL equivalent - we're only talking a few seconds across the board for very large objects, so the difference is irrelevant for real production purposes - largely, I think, because I expand the size of the initial result set from the number of extents to the number of blocks then shrink it back down again while the PL/SQL can simply walk through the extent definitions doing simple arithmetic.

I'm sure there's a MODEL clause way of avoiding the explosion, and I'd love to see it if someone has the time, but I keep thinking I'm close to an analytic solution but can't quite get there. So if anyone can come up with a solution that would be even better than a model solution - failing that, can someone prove it can't be done efficiently in simple analytic SQL.

UPDATE:  I forgot to state explicitly that the point of doing the block explosion and ntile() was that it was a simple strategy for getting the same number (+/-1) of block in every rowid range.

Regards

Jonathan Lewis

Message was edited by: Jonathan Lewis

This post has been answered by Stew Ashton on Jun 24 2015
Jump to Answer

Comments

Cvele_new_account

try to set Disabled property for that fourth SOC, to be false _only if first three SOC attributes are set to non-null values...

OR, make 4.th SOC ;disabled property to be false only if 3.-th SOC value are set, then the same for 3. SOC (depends on 2. SOC), then the same for 2. SOC, etc... got a point?

Jose Aróstegui

Excellent idea!

Can you help me please a bit to build the expression?

I don't know how to reference the fields as they are inside a Query Panel based on a View Critera.


BR

Ashish Awasthi

This 4th Lov is dependent on all 3 lovs?

If you are using view cirteria then uncheck "Ignore Null Values" Check box in criteria to not show any data in case of no value is selected in other 3 lovs

Ashish

Jose Aróstegui

Thanks a lot for your help Ashish.

This 4th Lov is dependent on all 3 lovs?

2nd Lov depends on 1st

3rd Lov depends on 2nd

4th Lov depends on 3rd

If you are using view cirteria then uncheck "Ignore Null Values" Check box in ...

Ignore null values is not editable:

screen3.png

I've tried your solution Igonre null values in viewCriteria -Jdeveloper 12c (Not a bug but a change) – Ashish Awasthi's Blog (Jdev/ADF) but It didn't activate the checkbox either.

Regards,

Jose.

Ashish Awasthi
Answer

Hi Jose

It'll not activate checkbox , you just need to add GenerateIsNullClauseForBindVars="false" under viecriteriItem tag like this and then check

<ViewCriteriaItem

    Name="DepartmentId"

    ViewAttribute="DepartmentId"

    Operator="="

    Conjunction="AND"

    Value=":BindDeptId"

    IsBindVarValue="true"

    Required="Optional"

    **GenerateIsNullClauseForBindVars="false"**/>

After this 4th lov will not show any data untill 3rd one is selected

SnapShot.jpg

Ashish

Marked as Answer by Jose Aróstegui · Sep 27 2020
Jose Aróstegui

It works fine. I was confused and was setting the value to true:

screen4.png

Thanks a lot!

Ashish Awasthi

Jose that post was not about this problem , It was about chnaging it's value only

Anyway you solved it  

1 - 7
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Sep 12 2015
Added on Jun 22 2015
54 comments
13,281 views