Query where clause of different table without data

Hello

Oracle 11g.

I have a 'Points' table that stores information point.
In carts, users can record information on these points.
Then, the user can some carts he wants to apply to display data in a report.

Here is a minimal example (I hope I didn't too many mistakes):
create table points (
     pt_id integer,
     pt_type varchar2(1),
     pt_accl varchar2(15),
     pt_class varchar2(10),
     pt_status varchar2(1),
     constraint pk_pt_id primary key(pt_id),
     constraint ck_pt_type check(pt_type in ('B','P', 'S', 'T')),
     constraint ck_pt_status check(pt_status in ('A','E'))
);

create table carts(
     cart_id integer,
     cart_name varchar2(30),
     cart_current varchar2(1),
     constraint pk_cart_id primary key(cart_id),
     constraint ck_cart_current check(cart_current in ('Y','N')) 
);

create table user_selected_types(
     ust_id integer,
     ust_cart_id integer,
     ust_type varchar2(1),
     constraint pk_ust_id primary key(ust_id),
     constraint fk_ust_cart_id foreign key(ust_cart_id) references carts(cart_id)
);

create table user_selected_accls(
     usa_id integer,
     usa_cart_id integer,
     usa_accl varchar2(15),
     constraint pk_usa_id primary key(usa_id),
     constraint fk_usa_cart_id foreign key(usa_cart_id) references carts(cart_id)
);

create table user_selected_classes(
     usc_id integer,
     usc_cart_id integer,
     usc_class varchar2(10),
     constraint pk_usc_id primary key(usc_id),
     constraint fk_usc_cart_id foreign key(usc_cart_id) references carts(cart_id)
);

create table user_selected_status(
     uss_id integer,
     uss_cart_id integer,
     uss_status varchar2(1),
     constraint pk_uss_id primary key(uss_id),
     constraint fk_uss_cart_id foreign key(uss_cart_id) references carts(cart_id)
);

insert into carts values (1, 'cart_1', 'N');
insert into carts values (2, 'cart_2', 'Y');
insert into carts values (3, 'cart_3', 'Y');

insert into points values (1, 'B', 'AAA', 'AAKCM', 'A');
insert into points values (2, 'B', 'BIONH1', 'AAKCM', 'A');
insert into points values (3, 'B', 'BIONH1', 'AAKCM', 'E');
insert into points values (4, 'B', 'CTF1', 'RF45Q33', 'E');
insert into points values (5, 'T', 'L4C', 'H4V1', 'A');
insert into points values (6, 'T', 'L4C', 'H4V1', 'E');
insert into points values (7, 'S', 'BIONH1', 'RX4', 'A');
insert into points values (8, 'S', 'L4D', 'L2585', 'A');
insert into points values (9, 'S', 'L4D', 'L2585', 'E');
insert into points values (10, 'S', 'CTF1', 'CCMBQX', 'A');
insert into points values (11, 'S', 'CTF1', 'CCMBQX', 'E');
insert into points values (12, 'S', 'CTF2', 'CCMBQX', 'A');
insert into points values (13, 'S', 'CTF2', 'CCMBQX', 'E');
insert into points values (14, 'P', 'H4', 'L44W', 'A');
insert into points values (15, 'P', 'H4', 'L44W', 'E');
insert into points values (16, 'P', null, 'RK', 'E');

insert into user_selected_types values (1, 1, 'B');
insert into user_selected_types values (2, 1, 'S');
insert into user_selected_types values (3, 3, 'T'); 

insert into user_selected_accls values (1, 1, 'BIONH1');
insert into user_selected_accls values (2, 2, 'CTF1');
insert into user_selected_accls values (3, 2, 'CTF2');
insert into user_selected_accls values (4, 3, 'L4C');

insert into user_selected_classes values (1, 1, 'AAKCM');

insert into user_selected_status values (1, 3, 'A');
If a user may for example have the following carts (according to the example above):
cart_1
Types : 'B', 'S'
Accls : 'BIONH1'
Classes : 'AAKCM'
Status : [All]

cart_2
Types : [All]
Accls : 'CTF1', 'CTF2'
Classes : [All]
Status : [All]

cart_3
Types : 'T'
Accls : 'L4C'
Classes : [All]
Status : 'A'
When no value is selected for an item, it must return all values.

For now, I have the following query:
with t as (select cart_id d from carts where cart_current = 'Y')
select
     *
from
     points
where
     ...
     and (
          pt_type in (select ust_type from user_selected_types where ust_cart_id in (select d from T))
          or not exists (select 1 from user_selected_types where ust_cart_id in (select d from T)))
     and (
          nvl(pt_accl, '' - (null)'') in (select nvl(usa_accl, '' - (null)'') from user_selected_accls where usa_cart_id in (select d from T))
          or not exists (select 1 from user_selected_accls where usa_cart_id in (select d from T)))
     and (
          pt_class in (select usc_class from user_selected_classes where usc_cart_id in (select d from t))
          or not exists (select 1 from user_selected_classes where usc_cart_id in (select d from T)))
     and (
          pt_status in (select uss_status from user_selected_status where uss_cart_id in (select d from T))
          or not exists (select 1 from user_selected_status where uss_cart_id in (select d from T)))
It works, but the data or mixed...
If the user apply cart_2 and cart_3, I don't want to for example points to accl "L4C" with status "E", forthcoming.
I just want to return the union all selected each carts.

Of course I can loop over Cart ID, PL_SQL, and build the query dynamically, as:
for cur_c in (select cart_id d from carts where cart_current = 'Y') loop
     l_query := l_query || 'select ... from ... where ...' || ' union all ';
end loop;
l_query := substr(l_query,1,length(l_query)-11);
But imagine the user ask 500 wagons..., I've reached the limit of varchar2.
I can't use a CLOB that I use Oracle APEX to view the report, and he expects the query a varchar2.

I don't want to use a temporary table, as it is too slow for the application (I've tested).

You have a solution?

Thank you.

Yann.

Thanks for create/insert statements - makes it much easier to help :D

Here's one way:

SQL> select
  2  c.cart_id,
  3  p.pt_id,
  4  p.pt_type,
  5  p.pt_accl,
  6  p.pt_class,
  7  p.pt_status
  8  from carts c
  9  cross join points p
 10  where c.cart_current = 'Y'
 11  and ( not exists(select null from user_selected_types ust where ust.ust_cart_id = c.cart_id)
 12     or p.pt_type in (select ust.ust_type from user_selected_types ust where ust.ust_cart_id = c.cart_id)
 13      )
 14  and ( not exists(select null from user_selected_accls usa where usa.usa_cart_id = c.cart_id)
 15     or p.pt_accl in (select usa.usa_accl from user_selected_accls usa where usa.usa_cart_id = c.cart_id)
 16      )
 17  and ( not exists(select null from user_selected_classes usc where usc.usc_cart_id = c.cart_id)
 18     or p.pt_class in (select usc.usc_class from user_selected_classes usc where usc.usc_cart_id = c.cart_id)
 19      )
 20  and ( not exists(select null from user_selected_status uss where uss.uss_cart_id = c.cart_id)
 21     or p.pt_status in (select uss.uss_status from user_selected_status uss where uss.uss_cart_id = c.cart_id)
 22      )
 23  order by
 24  c.cart_id,
 25  p.pt_id
 26  ;

   CART_ID      PT_ID P PT_ACCL         PT_CLASS   P
---------- ---------- - --------------- ---------- -
         2          4 B CTF1            RF45Q33    E
         2         10 S CTF1            CCMBQX     A
         2         11 S CTF1            CCMBQX     E
         2         12 S CTF2            CCMBQX     A
         2         13 S CTF2            CCMBQX     E
         3          5 T L4C             H4V1       A

6 rows selected.

The cross join creates all the possible combinations of carriage/point. Then they are checked for 4 columns according to your rules. I think that the result is correct, if I read your question right?

If it's the most effective depends a lot on your actual data. Are the usual cases each cart sets a very small subset of points, or each cart will usually define a substantial part of the points. Carts of how are your tables? How many tables of user_selected_? How is the distribution? How many points? Indexes are available?

If the data are such that it can "pay" to build all of the possible production and "weed" down, then the foregoing can be very effective. If the data is such that the result is usually very small subset then the effectiveness may depend on the index are available.

Test and see if it works for you ;-)
If it takes hours, so if please give some information on the quantity and distribution of the data and the expected quantity and size carts etc. Then we could think in a different way...

Tags: Database

Similar Questions

  • a slightly different similar query where clause

    Hi all, I am facing a problem with my request.
    I have a query that looks like this

    with names like
    (select name, lastname, id
    FROM table1
    where id = 1
    and type = "enu".
    and asset = 'other '.
    and cashid = 2
    and $vdate = system_date
    )
    Select * from names
    (< joins with other tables)

    the thing is that enu value is past as parameter of the procedure. This is only of value if away from the front end.
    further, I have to spend 2 different values now ("cae", "peq")
    However, for these two values, of what I need not use the active column in where clause and the cashid will have to be change to cashid in (3.4)

    I was thinking a dynamic query construction and function of the value pass, I'll build the query. I am looking for another way to implement these changes with minimal impact on the code. Anyone know how to go around this case?

    with these two new values for the query are very similar with the exception of the active column that is more use and cashid will include an IN clause. only a value will be in the procedure, either enu, cae, peq. for enu, the query must be as above, but for the other two active column values are not in the query and cashid must be cashid in (3.4). How to take care of these scenarios
    with names as
    (select name, lastname, id
       from table1
      where id = 1
        and (
        (type = 'enu' and asset = 'others' and cashid =2)
        or
        (type in ('cae','peq') and cashid in (3,4))
        )
        and vdate = system_date
    )
    select * from names
    
    

    Max

  • Move the schema objects to a different database without data

    Hi all

    I have to migrate schema objects in one database to another without data. Help, please.

    Kind regards

    Cherkaoui

    Hello

    Please read the doc, there is option

    CONTENT = {ALL |} DATA_ONLY | METADATA_ONLY}

    ALL loads all data and metadata contained in the source. It is the default value.

    DATA_ONLY only loads the data in row of table in the existing tables; No database object is created.

    METADATA_ONLY only loads the database object definitions; No data line of the table is loaded.

    so in your case, you can use CONTENT = METADATA_ONLY

    HTH

  • Best place to initialize the View object query where clause or params

    Where is the best place to initialize the View object 'where' clause before the page is initially rendered? Or how should it be done?
    Specifically, I can't set these values in the entity or view objects because I need information from the user or information Session
    the user has entered before you navigate to the page. I want to prepare the View object so that the results of the query appears something reasonable
    the first time before using chooses search.

    Note: The view object must exist and I need to access managed beans to define the query.

    Is there an event hook (java code) that can be called before the page is rendered?
    Also, there are hooks that can be called when the user navigates to another tab or page?

    Published by: Greateful Sep 6, 2012 19:48

    Hello

    Check out this blog: https://blogs.oracle.com/aramamoo/entry/an_epic_question_how_to

    Arun-

  • How can I export the schema with all objects and a few tables without data

    Hi all

    Verion 10g EA.
    I export the schema with all objects but I need ignored some of the data in the table.

    There is a table 4 people gave huge, we need not to export data from tables but structure must export.


    Thank you
    Nr

    You can do this with a single command.  Run your export as usual and add the query parameters for 4 tables you want all the lines:

    expdp... query = schema1.table1: "where rownum = 0" query = schema2.table2: 'where rownum = 0'...

    It is best to place the query parameters in a parameter file if you don't have to worry about escaping special characters of the OS.

    Dean

  • selection of values to query where clause

    Hi guys, it of maybe a silly question but do not know if I approach the solution in the correct engineering.

    At the top of my form, I framed that the user fills out the different values. These values are then used to refine the query results in the block below. I know that I can go in the datablock being interrogated and set the where the clause equal to the value of the text boxes above, but I don't feel it is the right place to do it.

    If I do like this when the above text box is empty, it returns no results when infact I want to ask all if the values are left white. So should I put it in motion pre? If so how should we do?

    Any help would be greatly appreciated.

    Thank you.

    In the trigger of the QUERY before block you, just put the value in the corresponding element

      :block.name := :ctrl.selection ;
    

    François

  • left outer join and the where clause for the table to the right

    I want to join two tables a and b, where a is a must and b is a result set in option. When I use a left outer join to a to b, I want to achieve:

    1. Select a single column, two columns of b (not the join columns)
    2 - even if theres no friendly on the join column does not return data from one.
    3. If there is a match applies when the criteria on column b (table in option)

    so, how can I avoid no_data_found in this case? When I apply where criteria for b, so it does not return the data from one, which is a must.

    Sounds like a regular outer join to me...

    select a.col1, b.col2, b.col2
    from   tableA a
           left outer join tableB b
           on (a.id = b.id and b.colX = 'X')
    
  • How can get the structure of the table without data

    Hai All


    I have two tables namely T1, T2 and these have some fields and I need to create a new table and the table two and only the header fields that I need but not the data.

    Thanks and greetings

    srikkanth. M

    Hello

    Something like that

    SQL> create table emp_bkp as
      2  select * from emp where 1=2;
    
    Table created.
    
    SQL>  select * from emp_bkp;
    
    no rows selected
    
    or
    
    SQL> drop table emp_bkp;
    
    Table dropped.
    
    SQL> create table emp_bkp
      2  as
      3  select e.empno,e.ename,e.deptno,d.dname,e.sal
      4  from emp e,dept d
      5  where e.deptno = d.deptno
      6  and
      7  1=2;
    
    Table created.
    
    SQL> select * from emp_bkp;
    
    no rows selected
    
    SQL> desc emp_bkp
     Name                                      Null?    Type
     ----------------------------------------- -------- --------------------------
     EMPNO                                              NUMBER(4)
     ENAME                                              VARCHAR2(10)
     DEPTNO                                             NUMBER(2)
     DNAME                                              VARCHAR2(14)
     SAL                                                NUMBER(7,2)
    

    Twinkle

  • Question about the order of evaluation of the clause WHERE CLAUSE when the Oracle OF the syntax used to join tables

    Hello

    Oracle version: 11.1.0.7.0 - 64 bit

    I read the documentation online at joins. The page is avialable here: joins at

    My question is about the join order of evaluation of the conditions in clause and the conditions of those

    are not the join conditions and are placed in the WHERE clause.

    Consider the following pseudocode

    SELECT

    T1. Col1,

    T2.Col1

    Of

    Table1 t1 LEFT OUTER JOIN table2 t2

    WE

    (condition_expression1)

    WHERE

    (condition_expression2)

    Is it correct to say that if there is no column on the status of join (condition_expression1) in condition_expression2, then condition_expression2 is executed before condition_expression1? In other words, oracle always trying to filter based on the WHERE clause individually each table as much as possible before joining them based on the conditions on the article?

    Thanks in advance,

    Hello

    dariyoosh wrote:

    Hello

    Oracle version: 11.1.0.7.0 - 64 bit

    I read the documentation online at joins. The page is avialable here: joins at

    My question is about the join order of evaluation of the conditions in clause and the conditions of those

    are not the join conditions and are placed in the WHERE clause.

    Consider the following pseudocode

    SELECT

    T1. Col1,

    T2.Col1

    Of

    Table1 t1 LEFT OUTER JOIN table2 t2

    WE

    (condition_expression1)

    WHERE

    (condition_expression2)

    Is it correct to say that if there is no column on the status of join (condition_expression1) in condition_expression2, then condition_expression2 is executed before condition_expression1? In other words, oracle always trying to filter based on the WHERE clause individually each table as much as possible before joining them based on the conditions on the article? ...

    The reverse is actually closer to the truth, but we can't really make general statements like that.

    SQL is not a language of the proceedings.  Looking at the code SQL, we could say that the code does, but we cannot say much about how that code it.  In other words, SQL is a language that describes the results you get, not the way to get them.

    The optimizer will do everything what he thinks is faster if it does not change the results.  If any order in which they are applied (in outer joins or CONNECT BY queries, for example), then think of the join is done first, and the value of the WHERE clause is applied to the result of the join.

    Here is a query looks very much like you posted:

    SELECT d.deptno

    e.ename, e.sal

    OF scott.dept d

    LEFT OUTER JOIN scott.emp e ON e.deptno = d.deptno

    WHERE e.sal > = 3000

    ORDER BY d.deptno

    ;

    Output:

    DEPTNO ENAME SAL

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

    10 KING 5000

    20 FORD 3000

    20 3000 SCOTT

    The scott.dept table contains deptnos 30 and 40; Why are they not in the result set?  The query behaves as if the outer join is made first (production 15 rows), then the WHERE clause has been applied.  All lines with deptno = 30 had sals down han 3000 and all single line with deptno = 40 was NULL in the sal column, then these lines are excluded (as well as other lines of deptnos 10 and 20), and only 3 lines above are left.

  • Complex Inner Join and outer subquery where clause to join internal?

    The DDL for this post was too big and I had to put on my site:
    http://www.harbortownsolutions.com/DDLForDORTable.txt

    My goal is to create a report of sales data for 116 stores containing daily sales and count of comments in recent years. My challenge is that I am pulling data from the same table, but with different dates to get data from last year and the week in data from date of last year.


    The dates used for reports are:

    SalesDate = 06/04/2009
    SalesDateForLastYear = 2008-06-05
    SalesDateBeginningOfWeek = 01/06/2009
    SalesDateBginningOFWeekLastYear = 2008-06-02

    PSEUDOQUERYS:
    ---======= DOLLAR VARIANCE = You Said you have $100 worth of meat(inventory) but you only have $50 worth of meat
    SELECT 
        BUSI_DATE as BusinessDate, 
        ORACLE_KEY as StoreID,
        FIELD1  as Sales,
        FIELD2  as GuestCount,
        FIELD3  as DollarVariance,
        FIELD4  as Cars
    FROM MYDAILYTOTALS
    WHERE Busi_date = SalesDate
       AND ORACLE_KEY IN (SELECT StoreID From MyStores); 
    -======= ONLY Guest count and Sales are needed in comparisons against last year    
    ---======    Last YEar dates = corresponding dates for this year ie Tuesday of this 
    week matched to Tuesday of last year (except for leap year)
    SELECT 
        ORACLE_KEY as StoreID
        FIELD1  as SalesLastYear
        FIELD2  as GuestCountLastYear   
    FROM MYDAILYTOTALS
    WHERE Busi_date = SalesDateForLastYear 
       AND ORACLE_KEY IN (SELECT StoreID From MyStores);
           
    
    SELECT 
        ORACLE_KEY as StoreID
        SUM(FIELD1)  as WeekToDateSales
        SUM(FIELD2)  as WeekToDateGuestCount  
    FROM MYDAILYTOTALS
    WHERE Busi_date BETWEEN SalesDateBeginningOfWeek and SalesDate
       AND ORACLE_KEY IN (SELECT StoreID From MyStores) 
    GROUP BY ORACLE_KEY 
       --=======  
    SELECT 
        ORACLE_KEY as StoreID
        SUM(FIELD1)  as WeekToDateSalesLastYear
        SUM(FIELD2)  as WeekToDateGuestCountLastYear  
    FROM MYDAILYTOTALS
    WHERE Busi_date BETWEEN SalesDateBeginningOfWeekLastYear and SalesDateLastYear
       AND ORACLE_KEY IN (SELECT StoreID From MyStores) 
    GROUP BY ORACLE_KEY   
    Question: Since they all use the same store of nbrs, I specify on each request? Can't I just specify only once on outer query Where clause?

    Also, how would fit the following of HOEK script:
    See how I put 1 field based on another field value

    He reads a record for each store of 116 stores in the database. There are 2 situations that have been addressed by Hoeks code:
    For each of the 116 stores in the store table, there must be 1 and only
    registration of 1 stock to match the record of MyStoreTotals. However, sometimes there is no record of inventory.
    and sometimes there will be 2 (in a case where a manager of database updates)
    After daily treatment) files. If so, the record with Is_posted = 1
    is the one that should be included in the query. The following text accomplishes this:
    -chr (39) is the single quote
     Select StoreId, 
             DollarVariance 
      from   (select store.storeid, 
                       case
                              when inv.storeid is null then 'None'
                              when inv.is_posted = 0 then 'NP'
                              else chr(39)||inv.total_dol_var||chr(39)
                        end as DollarVariance, 
                        row_number() over (partition by store.storeid order by inv.is_posted desc) rn  
                   from  myInven inv 
                   right outer join mystores  store
                                  on store.storeid = inv.fk_str_main_id
                                  and inv.busi_date = to_date(SalesDate, 'dd-mon-yyyy'))
          where rn = 1;      
    Can I put this request on the place where clause of the outer to query I put on a JOIN clause?

    So I guess that's why you used the MAX.

    That is right.
    I used CASES to identify and complete the necessary columns since the first set of results (WITH).
    So then I more or less "swivels somehow" lines of this result set to the columns, each store will appear once the most.

  • Passing the value of the where clause with the page

    Dear friends,

    I have a requirement like when I select a selection list value I should pass this value to sql query where clause without submitting the page

    ex I have a select like: P1_Dept guess I selects the value 10 in this

    then I have a query select * from emp where deptno =: P1_Dept.

    DB. ORACLE 11G

    APEX 4.1.1.00.23

    is this possible? can someone help me please in this topic

    Thanks and greetings

    Vballeda

    Suppose we have the selection list with the name P1_DEPT and query for report

    select * from emp where deptno = :P1_DEPT
    

    We create dynamic Action on the evolution of the P1_DEPT point. We will need two real actions:

    1-> set value action

    Set the Type - > body of the PL/SQL function

    The function of body - > return 1;

    Page item to submit-> P1_DEPT

    Change to delete-> Yes event

    Selecttion Type-> trigger element

    2. action-> Refresh

    Selecttion Type-> region

    Region-> your region of report

  • A CASE statement with additional where clause

    Hi all

    I need assistance in which this obligation clause

    Table:-balance_table

    Columns:-balance_type, balance_amount, balance_month, budget_name

    balance_type column had given 'Real' OR 'Budget '.

    Now I am trying to extract data such as: if: entered_month is Mar-2009 then before and including Mar-2009 will show real balance sheet Date and after Mar-2009 will show budget data.

    It works fine, I need to add a condition more restrict the budget name, there are several budget_name in the table for balance_type = 'Budget '.



    SELECT SUM (balance_amount), balance_type, balance_month
    OF balance_table
    WHERE balance_type =
    (CASE
    WHEN balance_month < =: entered_month
    THEN 'real '.
    ANOTHER 'Budget '.
    END
    )
    AND budget_name = 'BUDGET1.
    Balance_type GROUP, balance_month

    Stated above is erroneous because ' AND budget_name = ' BUDGET1 "clause restricts the set of data."

    Please help in contrcuting where clause 1) to sort the data according to Budget/actual and 2) for specific budgets, so budget_type = Budget

    Thank you
    Bobin

    That should do it.

    SELECT SUM (balance_amount),
           balance_type,
           balance_month
    FROM balance_table
    WHERE (balance_type = 'Actual'
           and balance_month <= :entered_month
          )
    or (balance_type = 'Budget'
        and balance_month > :entered_month
        and budget_name = :entered_budget_name
       )
    GROUP BY balance_type,
             balance_month
    ORDER BY 2
    

    See you soon
    Sarma.

  • How to change where clause in VO interview at the bean

    Hi experts

    I need to change vo object query where clause execution... is - it possible?

    If so please suggest me.

    as mentioned by Timo, it is quite possible

    See this link-

    Change in the WHERE clause or query on VO when running in Oracle ADF | Techartifact

    Dynamically change the query in the view object in Oracle ADF | Techartifact

  • How can I filter a table of data control without entering the query

    I have a table from a WSDL-based web service data control.

    I want to filter the table without input query in the filter text box. Without text filter box, each could filter the table with a query hardcoded internally.
    For example, when the user menu button click and then it filters the table where type = '1' and B menu button filters the table by type = '2' and C menu button filters the table by type =' "."

    How can I filter the table without entering the query?

    Could someone point me to a solution please.

    Thank you.
    11.1.5 jdev

    Published by: 893364 on October 26, 2011 12:15

    Published by: 893364 on October 26, 2011 12:21

    Hello

    When you have created the table, have you tried selecting the option "filter". Select the table, and access the property of m.. In the toolbar of the Properties Inspector, there is an icon to change the configuration. His fields of filter adding filter for the user to search in.

    Option 2: Data from the Web Service are actually held in iterators. If you want to filter the Web service request, I wouldn't use the WS domain controller but a proxy of JAX - WS in a POJO to recover data from the WS. Then the data control created from the POJO. You might have a method exposed on the POJO which allows you to filter the data internally that is held

    Frank

  • where clause to query the hierarchy in the tree Apex area does not

    Hi all

    I am building a tree Menu in Apex 5.0.3 (Oracle 11 g XE), when using when the clause, it does show all the data, but without him, showing all the data.

    I'm trying to populate Tree Menu with data specific to a user successfully logged on.

    (A) table created as HR2. TREE_MENU

    menu_name varchar2 (50).

    number of menu_parent

    number of menu_child

    menu_id varchar2 (12),

    menu_path varchar2 (100),

    number of user_no

    (B) SQL statement for the tree in the Apex region

    Select case when connect_by_isleaf = 1 then 0

    When level = 1 then 1

    else                           -1

    end the status,

    level,

    'Menu_name' as the title,

    NULL as an icon,

    "MENU_CHILD" as a value.

    NULL as ToolTip,

    NULL as link

    to HR2. "" TREE_MENU ".

    -WHERE USER_NO =: P_USERNO

    Start with 'MENU_CHILD' is null

    connect prior "MENU_PARENT" = "MENU_CHILD."

    brothers and sisters of order by 'MENU_ID '.

    Note: also used static value where clause but is not workd.

    that the mistake of me or something else? When using the wizard, she asks (possibly) where clause, this means that when the clause can be used in the SQL statement.

    Help, please.

    Kind regards.

    If you want to prune your tree to show only the elements of the No. 7 usermenu, copy the following code helps you

    select case when connect_by_isleaf = 1 then 0
                when level = 1             then 1
                else                           -1
           end as status,
           level,
           "MENU_NAME" as title,
           null as icon,
           "MENU_CHILD" as value,
           null as tooltip,
           null as link
    from HR2."TREE_MENU"
    start with "MENU_CHILD" is null
    connect by
        prior "MENU_PARENT" = "MENU_CHILD"
        and "USER_NO" = 7
    order siblings by "MENU_ID"
    

    Concerning

    Mahmoud

Maybe you are looking for