Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 636139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:28:57+00:00 2026-05-13T20:28:57+00:00

I’m trying to implement a front end for a reporting solution which is security

  • 0

I’m trying to implement a front end for a reporting solution which is security dependent. The user has 12 levels of nested criteria to select from, the value of each affects all of the values below.

So the criteria selection on the page (each is a dropdown) looks something like this:

Criteria 1
Criteria 2
…
Criteria 12

There is a Security table that holds the values that are available to each user which has the following structure:

EmployeeID | Criteria_1_valid_Value | C2_valid_Value | ... | C12_valid_Value
x0001 | c1 | c2 | ... | c12

and each Employee will have one or (many) more rows in this table. Think of it as a flattened tree, with Criteria1 as the root node.

Based on keys, changing Criteria 1 will affect the values that are visible in Criteria 2 through 12. In the same way, changing the value in Criteria 2 affects the values available in Criteria 3 through Criteria 12. At each level, there is an option to select ‘All Values,’ which is represented by a space internally, for lookups. So I need a representation in the lookup table/view which takes into account that there may be a space at one or many levels.

Where I’m struggling is with finding a way to build the lookup view/table for each Criteria field using sql without having to resort to hardcoding.

For example, to build the lookup for criteria 2 the sql might look like this:

select EmployeeID, Criteria1, Criteria2
from Security
Union
select EmployeeID, ' ', Criteria2
from Security
Union
select EmployeeID, Criteria1, ' '
from Security
UNION
select EmployeeID, ' ', ' '
from Security

And so on. Unfortunately, of course, with 12 levels, the last works out to 2^12 unions, which frankly smells.

I’ve tried building a table for each level in batch, committing after each, then using the previous table joined to the Security table to build the next with a single UNION in each, but I can’t seem to get the joins to work properly with the spaces.

I don’t know if I’m overthinking this or completely missing something, but I feel like there has to be a simpler solution.

EDIT: This is on Oracle and I’m working with an ERP product as the underlying technology.

EDIT2: Thanks for the input everyone. I got the joins eorking correctly using joins like in the example proc from @Alex Poole below:

and (v_Criteria_1 = ' ' or Criteria_1_valid_Value = v_Criteria_1)

I was missing the v_Criteria_1 = ' ' or.

So I’ve got the tables loaded correctly (enough) now. This is turning into a tuning/optimization exercise. I’m going to look at the proc from @Alex Poole and the artithmetic approach of @JD_55 which I think might be very quick.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T20:28:58+00:00Added an answer on May 13, 2026 at 8:28 pm

    So in the end it did come down to a performance issue. I created a table that held the binary representation of 2^10 integers in reverse (litte-endian, if you will).

    DECBIN:

    decimal   binary
    0         0000000000
    1         1000000000
    2         0100000000
    ...
    1023      1111111111
    

    I then cartesian join this to the security table and decode each bit to get the correct value.

    So the sql looks something like this:

        SELECT DISTINCT
           t.employeeID,
           DECODE (SUBSTR (x.binary,  1, 1), 0, ' ', t.c1)  AS crit1,
           DECODE (SUBSTR (x.binary,  2, 1), 0, ' ', t.c2)  AS crit2,
           DECODE (SUBSTR (x.binary,  3, 1), 0, ' ', t.c3)  AS crit3,
           DECODE (SUBSTR (x.binary,  4, 1), 0, ' ', t.c4)  AS crit4,
           DECODE (SUBSTR (x.binary,  5, 1), 0, ' ', t.c5)  AS crit5,
           DECODE (SUBSTR (x.binary,  6, 1), 0, ' ', t.c6)  AS crit6,
           DECODE (SUBSTR (x.binary,  7, 1), 0, ' ', t.c7)  AS crit7,
           DECODE (SUBSTR (x.binary,  8, 1), 0, ' ', t.c8)  AS crit8,
           DECODE (SUBSTR (x.binary,  9, 1), 0, ' ', t.c9)  AS crit9,
           DECODE (SUBSTR (x.binary, 10, 1), 0, ' ', t.c10) AS crit10,
           DECODE (SUBSTR (x.binary, 10, 1), 0, 'Choose All',t.c11) AS crit10Descr
      FROM Security t, DECBIN x
     WHERE TO_NUMBER (x.decimal) BETWEEN 0 AND POWER (2, 10) - 1
    

    This is faster by a factor of 10. Thanks @JD_55 for getting me tho think about the problem in a new way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 372k
  • Answers 372k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Passing this kind of values in a form isn't probably… May 14, 2026 at 7:26 pm
  • Editorial Team
    Editorial Team added an answer I am not sure if i fully understand your question,… May 14, 2026 at 7:26 pm
  • Editorial Team
    Editorial Team added an answer Yes, basically the idea is that your viewModel should only… May 14, 2026 at 7:26 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.