Problem with hierarchical queries

Hi,
I implemented (thx to jarola) sucessfully a report using a hierarchical view.
It is nearly the same as in Tyler Muths blog: -http://tylermuth.wordpress.com/2009/02/26/hierarchical-query-to-unordered-list/-
-select (level*20)-20 the_level ,(level*10)-10 the_level2, machine_no
- parent_id, item_id,description
-from machine_list
-where machine_no = 101
-and project_id = 122
- connect by prior item_id = parent_id
- start with parent_id is null
This works good, as long as there is just one project/machine in the table.
If I have 2 machines in the table, it does not work in the report anymore, all entries are shown, although I check for the right machine_number and project_number in the query :-(
Any suggestions?
BR
Lena

Hi Joel
Just for reference, to write the code tags in posts without a space, you can use noformat tags on either side like this (let's see if I can manage this!)...
<pre>{noformat }{noformat }</pre>
Edited by: Munky on Apr 27, 2011 10:03 AM
Edited by: Munky on Apr 27, 2011 10:03 AM
Edited by: Munky on Apr 27, 2011 10:03 AM
Edited by: Munky on Apr 27, 2011 10:04 AM
Edited by: Munky on Apr 27, 2011 10:04 AM
Edited by: Munky on Apr 27, 2011 10:05 AM - sod it! had to add spaces to the noformat tags!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Problem with Hierarchical query

    Gurus,
    I have a problem with hierarchical query, which I am pasting below.
    select sys_connect_by_path (Fname,'/')"PATH",Fname,id,level
    ,(SELECT COUNT(ID)-1 FROM (SELECT CONNECT_BY_ROOT LNAME LNAME,ID FROM CMT_PERSON
    START WITH ID = 'emplo000000000126009'
    CONNECT BY PRIOR ID=MANAGER_ID)
    GROUP BY FNAME)"COUNT"
    from CMT_PERSON
    WHERE
    LEVEL <= 4
    ----And ID='emplo000000000001877'
    CONNECT BY PRIOR id=manager_id
    ----AND NOT LEVEL > 3
    START WITH ID='emplo000000000126009'
    As per the result, count is getting repeated for all the levels. That is, count is coming 16100 for every level, Can you please help where exactly I am going wrong
    Regards

    You do not say anything about what count you want to get?
    A wild guess could be:
    select
       sys_connect_by_path (p1.fname, '/') "PATH",
       p1.fname,
       p1.id,
       level,
       (select count (id) - 1
        from
           (select connect_by_root p2.lname lname, p2.id
            from cmt_person p2
            start with p2.id = p1.id
            connect by prior p2.id = p2.manager_id)
        ) "COUNT"
    from cmt_person p1
    where level <= 4
    connect by prior p1.id = p1.manager_id
    start with p1.id = 'emplo000000000126009';Since your inner query simply starts with the hardcoded employee id, naturally it will give you the same count.
    My guess is your inner query should start with the person id from the outer query?
    If that is not the case - please state in plain english what you are trying to accomplish ;-)
    (Oh, and please paste code within tags so we can read it more easily...)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • CONNECT BY, Performance problems with hierarchical SQL

    Hello,
    I have a performance problem with the following SQL:
    table name: testtable
    columns: colA, colB, colC, colD, colE, colF
    Following hierarchical SQL:
    SELECT colA||colB||colC AS A1, colD||colE||colF AS B1, colA, colB, colC, level
    FROM testable
    CONNECT BY PRIOR A1 = B1
    START WITH A1 = 'aaa||bbbb||cccc'
    With big tables the performance of this construct is very bad. I can't use functional based indexes to create an Index on "colA||colB||colC" and "colD||colE||colF"
    Has anyone an idea how I can get a real better performance for this hierarchical construct, if I have to combine multiple colums? Or is there any better way (with an PL/SQL or view trigger) solve something like this ??
    Thanks in advance for your investigation :)
    Carmen

    Why not
    CONNECT BY PRIOR colA = colD
    and PRIOR colB = colE
    and ...
    ? It is not the same thing, but I suspect my version is correct:-)

  • Problem with Join Queries using PHP and an Orcale Database

    Ok, I am trying to build a simple php querying tool for my oracle database and for the most part it is working however I am having a problem getting data from my join queries. If I run the following query :
    QUERY:
    SELECT lastfirst,EnteredBy,Debit FROM students sts JOIN GLDetail gl ON gl.studentid=sts.id
    RESULT SET:
    Lastfirst     EnteredBy     Debit
    caiu, test      204     1
    But when I run the query correctly I get no results
    QUERY:
    SELECT sts.lastfirst,gl.EnteredBy,gl.Debit FROM students sts JOIN GLDetail gl ON gl.studentid=sts.id
    RESULT SET:
    sts.lastfirst     gl.EnteredBy     gl.Debit
    and if I run the query combining the two above methods and adding a field (schoolid) that has the same name on both table I get the following result sets
    QUERY:
    SELECT lastfirst,EnteredBy,Debit,sts.schoolid FROM students sts JOIN GLDetail gl ON gl.studentid=sts.id
    RESULT SET:
    lastfirst     EnteredBy     Debit     sts.schoolid
    caiu, test      204     1     
    QUERY:
    SELECT lastfirst,EnteredBy,Debit,schoolid FROM students sts JOIN GLDetail gl ON gl.studentid=sts.id
    RESULT SET:
    NONE
    Therefore, I have to have something written incorrectly in my php code and I just can not figure it out. My entire code is pasted below please provide me with an assistance you might have to offer. I have change the odbc_connec line so I could post it to this forum. In addition, I had to phrase out the column headers there for when you write the column headers you have to use ~ instead of , as the separator and then I turn back into the correct format for sql.
    //These scripts just open help windows if somone clicks on the icon
    <script>
    function submit()
    {document.sqlform.submit();}
    </script>
    <script>
    function colwin(){
    window.open("colnames.php",null,"height=300,width=400,scrollbars=1");}
    </script>
    <script>
    function tabwin(){
    window.open("tablenames.php",null,"height=300,width=400,scrollbars=1");}
    </script>
    <script>
    function help(){
    window.open("http://www.w3schools.com/sql/default.asp",null,"height=500,width=700,scrollbars=1");}
    </script>
    <form method="post" action="<?php echo $PHP_SELF;?>" name="sqlform">
    <?php
    //Cookie to check for authorization to the site
    if($_COOKIE['cookie']=="CheckCookieForAuth")
    //These get the values of the textareas after the form has been submitted
    $sqlSELECT = $_POST["SELECT"];
    $sqlFROM = $_POST["FROM"];
    $sqlJOIN = $_POST["JOIN"];
    $sqlWHERE = $_POST["WHERE"];
    $sqlOTHER = $_POST["OTHER"];
    $sqlSELECTTYPE = $_POST["SELECTTYPE"];
    //This is the variable used to parse out my headers the user entered
    $sqlColNames = split('~',$sqlSELECT);
    //This converts the ~ separator to , so I can actually use it as part of my sql string
    $search = array('~');
    $replace = array(',');
    $mystring = $sqlSELECT;
    $sqlString = str_replace($search, $replace, $mystring);
    //These are the textareas and the drop down options that the end users has to create queries
    echo "<table border=0>";
    echo "<tr><td valign='top'>";
    echo "<B>SELECT TYPE</B> <BR><SELECT NAME=SELECTTYPE>
    <OPTION VALUE='SELECT' SELECTED>SELECT</OPTION>
    <OPTION VALUE='SELECT DISTINCT'>SELECT DISTINCT</OPTION>
    <OPTION VALUE='INSERT'>INSERT</OPTION>
    <OPTION VALUE='UPDATE'>UPDATE</OPTION>
    <OPTION VALUE='DELETE'>DELETE</OPTION>
    </SELECT>";
    echo "</td><td>";
    echo "<textarea rows=2 cols=75 name=SELECT wrap=physical>$sqlSELECT</textarea>";
    echo "</td><td valign='top'>";
    echo "<img src='images/sqlC.jpg' width='25' height='25' onclick='colwin()'>";
    echo "</td></tr>";
    echo "<tr><td valign='top'>";
    echo "<b>FROM</b>";
    echo "</td><td>";
    echo "<textarea rows=2 cols=75 name=FROM wrap=physical>$sqlFROM</textarea>";
    echo "</td><td valign='top'>";
    echo "<img src='images/sqlT.jpg' width='25' height='25' border=0 onclick='tabwin()'>";
    echo "</td></tr>";
    echo "<tr><td valign='top'>";
    echo "<b>JOIN</b>";
    echo "</td><td>";
    echo "<textarea rows=2 cols=75 name=JOIN wrap=physical>$sqlJOIN</textarea>";
    echo "</td></tr>";
    echo "<tr><td valign='top'>";
    echo "<b>WHERE</b>";
    echo "</td><td>";
    echo "<textarea rows=2 cols=75 name=WHERE wrap=physical>$sqlWHERE</textarea>";
    echo "</td></tr>";
    //This is where the end user would enter group by, having, order by, etc..
    echo "<tr><td valign='top'>";
    echo "<b>OTHER</b>";
    echo "</td><td>";
    echo "<textarea rows=2 cols=75 name=OTHER wrap=physical>$sqlOTHER</textarea>";
    echo "</td></tr>";
    This is a run query icon and a help icon
    echo "<tr><td colspan=2 align=right>";
    echo "<img src='images/RunQuery.jpg' width='30' height='28' onclick='submit()'> <img src='images/qm.jpg' border=0 width='25' height='25' onclick='help()'>";
    echo "</td></tr></table>";
    echo "<br>";
    echo "<br>";
    //This is where I connect to my remote oracle database
         $conn=odbc_connect('ODBC_ConnectionName','USERNAME','PASSWORD');
    //This is the sql string created by the end users
         $sql="$sqlSELECTTYPE $sqlString FROM $sqlFROM $sqlJOIN $sqlWHERE $sqlOTHER";
    //This executes the connection string and the sql string
         $rs=odbc_exec($conn,$sql);
    //This will display the query or a message if the query is empty
         if($rs!=NULL){
         echo "<table border=1>";
         echo "<tr>";
    //This loops through the string array the end user enter the field name text area to get column headers
         for($i=0; $i<count($sqlColNames); $i++)
         echo "<td>";
         print_r($sqlColNames[$i]);
         echo "</td>";
         echo "</tr><tr>";
    //This actually fetchs the rows from the statement and then display the data based on the column names the end user speificed
         while (odbc_fetch_row($rs))
              for($i=0; $i<count($sqlColNames); $i++)
                   $results=odbc_result($rs,$sqlColNames[$i]);
                   echo "<td>$results</td>";
              echo "</tr>";
         odbc_close($conn);
         echo "</table>";}else{echo "Results will be displayed here";}
    echo "<br><br>";
    echo $sql;
    else
    echo "Not logged in";
    ?>
    </form>

    This looks more like a SQL question than a PHP issue. There are a couple of JOIN examples at http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_10002.htm#i2066611 that might you work through the problem.

  • Problems with BCS Queries Inconsistent Data

    Hi BI Experts,
    We recently had our BCS upgrade from 4.0 to 6.0 and BW upgrade from 3.5 to 7.0
    We have created some consolidated queries and we didnt change them to 7.0 they are still in 3.5 version. The problem is that we are getting some inconsistent data every time we ran those queries.
    The BWP is yet to under go upgrade process so we checked  the data in BWP (3.5) production and BWD (7.0) this tells us that the data in the tables are right.
    I ran the query in RSRT and gives inconsistent data.
    We are on the support pack 10 for BCS and
    support pack 14 for BI 7.0.

    Sorry guys....
    I want to correct one statement up there ...when I run my queries with through RSRT i dont get any inconsistent data ..the data comes exactly the way we want ...the problem is only through the BEx.
    Is it a upgrade bug or the support pack issue ..???
    Your suggestions will be appreciated with lots of points
    Thanks

  • Problem with sub queries

    Hi
    I have 3 tables like,
    LIST (ID NUMBER, NAME)
    LIST_VERSION (ID NUMBER, VER NUMBER, STATE_CODE number)
    STATE_CODES (CODE NUMBER, DESC VARCHAR2)
    LIST to LIST_VERSION is one to many relation. I have a query like this,
    SELECT LV.* from LIST_VERSION WHERE
    LV.VER = (SELECT MAX(LV1.VER) FROM LIST_VERSION LV1 WHERE
    LV1.ID = LV.ID)
    OR LV.VER = (SELECT MAX(LV2.VER) FROM LIST_VERSION LV2 WHERE
    LV2.ID = LV.ID and LV2.STATE_CODE=1)
    LIST to LIST_VERSION and LIST_VERSION to STATE_CODES table is defined
    in toplink mapping. To translate this into expression I have tried several possible combinations with out any luck. I was able to get the individual queries (the ones in OR) work, but not together. Here is what I did for individual queries
    ExpressionBuilder bldr = new ExpressionBuilder(ListVersion.class);
    ExpressionBuilder sub1 = new ExpressionBuilder ();
    ExpressionBuilder sub2 = new ExpressionBuilder ();
    ReportQuery subQ1 = new ReportQuery (ListVersion.class, sub1);
    ReportQuery subQ2 = new ReportQuery (ListVersion.class, sub2);
    subQ1.addMaximum ("listVer");
    subQ1.setSelectionCriteria (sub1.get ("list").get ("id").equal (bldr.get ("list").get("id")));
    subQ2.addMaximum ("listVer");
    subQ2.setSelectionCriteria (sub2.get ("list").get ("id").equal (bldr.get ("list").get("list")).and (sub2.get ("stateCode").get ("code").equal (1)));
    Expression exp1 = bldr.get("listVer").equal(subQ1);
    Expression exp2 = bldr.get("listVer").equal(subQ2);
    Each of the above expressions work fine independenty. However if I try to do some thing like,
    exp1.or(exp2) I get very strange SQL generated and get SQL exceptions in code. The SQL it generates is
    SELECT t0.ID, t0.VER, t0.STATE_CODE FROM LIST_VERSION t0 WHERE ((t0.VER = (SELECT MAX(t1.VER) FROM LIST t3, LIST t2, LIST_VERSION t1 WHERE ((t2.ID = t3.ID) AND ((t3.ID = t0.ID) AND (t2.ID = t1.ID))))) OR (t0.VER = (SELECT MAX(t4.VER) FROM LIST t5, LIST_VERSION t4, STATE_CODES t6 WHERE (((t5.ID = t3.ID) AND (t6.STATE_CODE = ?)) AND ((t6.STATE_CODE = t4.CODE) AND (t5.ID = t4.ID))))))
    The problem occurs because the t3.ID in the second sub query is not correct. it should be t0.ID, but I can't figureout why this is happening. Any help or suggessions to achieve my objective?
    Thanks
    Bhaskar

    Looking at your query that works at the bottom, I do not see any reason that you would need to include the Assignment table in the From list. Just use the same where clause in the form:
      Where project.resources_maximum
        > (Select Count(assignment.employee_ID)
           From assignment
           Where assignment.project_ID = project.project_ID
           group by assignment.project_ID  )

  • Authorization Problem with Hierarchical Filter

    Hi Gurus!
    In our BW system I created a query that includes hierarchy-enabled characteristic
    (0costcenter). 0costcenter has a hierarchy node variable to restrict
    user's  data by using authorization.
    Then I created an authorization object from t-code RSECADMIN, in this auth.
    object,  restricted 0costcenter from hierarchy authorization tab , and
    selected 6 nodes (the nodes have no sub-nodes).
    In our web template ( WAD 7.0 ) I used hierarchical filter to see the 6 nodes in our report. It works fine when I first open the template in our Enterprise Portal that we see in the variable screen,0costcenter's variable captures the nodes that I restricted in our authorization object.
    In the portal the hierarchical filter displays only selected nodes but this filter shows the hierarchy's root (name of the hierarchy) and when we choose the root the analysis displays all the values, the authorization do not work here.
    From RSECADMIN, In the hierarchy authorization tab, I tried all the type of hierarchies but all of them gave the same result.
    When i execute the report in BEx Analyzer, the authorization works fine, I think the problem is about hierarchical filter but i cannot find any solution...
    Can you give me an idea plz..
    Thank you!

    Hi,
    I think this is caused by program error.
    Take a look:
    [1075125|https://websmp230.sap-ag.de/sap(bD1kZSZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=1075125] - Unauthorized data displayed when structure element expanded
    [917565|https://websmp230.sap-ag.de/sap(bD1kZSZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=917565] - Query displays unauthorized data
    [981828|https://websmp230.sap-ag.de/sap(bD1kZSZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=981828] - No authorization for assigned inactive hierarchy
    [654947|https://websmp230.sap-ag.de/sap(bD1kZSZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=654947] - Hierarchy authorizations with compound characteristics
    Only available in German:
    [1158432|https://websmp230.sap-ag.de/sap(bD1kZSZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=1158432] - Zu viele Werte berechtigt bei Hierachie mit Intervallen
    Hope this helps.
    Regards
    Andreas

  • Problems with hierarchies.

    Hi everybody:
    I've made, from OWB, the store table with several dimensions: State, County, City... Each dimension has its own numeric ID and a string with its name. I've also made the geographic hierarchy with the identificators State.ID -> County.ID -> City.ID... The problems comes when I'm working with Discoverer, since I can only see the numeric identificators. I would also like to see the strings with the name.
    Can I suggest that I want to see an attribute of the dimension and not the numeric ID when I make a drill-down or a roll-up in the Discoverer Desktop? Do I have to modify the hierarchies in the Discoverer Administrator and make them with the strings instead of make them with the numeric ID?
    Thanks in advance.

    Normally this problem is caused is by two things:
    1. The authorizations for the BW update User or the Source system extraction User is not correct.
    Please make sure that your OLTP and BW system Have the following profiles in transaction SU01:
    in your OLTP client the user ALEREMOTE should have following profiles: SAP_ALL and S_BI_WX_RFC AND it should be a dialog user.
    In the BW client the user should have the profiles: SAP_ALL, S_BI_WHM_RFC and S_RS_ALL.
    2. The connections between the BW client and the R/3 client are not configured correctly. Please check SM59

  • Problems with dynasight queries (Essbase goes fast)

    Hi, we use dynasight tool to retrieve the data. The time of queries shown in app. window are fast, but we think dynaserver has problems, maybe in sharing the cache memory although this is up to 2 GB and essbase doesn't take more than 600 MbThanks a lot

    Hello,in principle, the performance of dynaSight should be more or less identical to the performance you get from an equivalent query from within the Excel Add-In for example. Therefore, the performance problem is very likely due to the specific design of the dynaSight documents/screens.Please check the following:- hierarchy objects configuration:is 'request other levels when expanded' used for the vertical and horizontal hierarchy objects? Depending on the use and type of query this feature may speed up performance significantly.- are you using individual selections?If yes: are you using more than 99 members in an individual member selection (this is the limit on the Essbase Side: if you exceed that limit, dynaSight will query the complete hierarchy and filter out the selected members)- optimize the screens by for example consolidating multiple queries / database calls into one query / database call.=> these are just a few suggestions to look into. In general, I would strongly suggest to contact [email protected] and provide them with some application components and trace and log files so the design issues can be analysed and identified more specifically.Best RegardsAndreas [email protected] of Competence Center

  • Problem with some queries after migration from MS Access

    Hi everyone!
    We've just finished a migration from a MS Access database and we notice some errors when running some queries like :
    Query1:
    SELECT A.field1, A.field2, B.field1 as FieldTmp
    FROM A,B
    where (B.field1 <=10);
    Query2:
    SELECT Query1.field1, Query1.field2, Query1.FieldTmp
    FROM Query1 LEFT JOIN Table3
    ON (Table3.field1 = Query1.Field2) AND
    (Table3.field5 = Query1.FieldTmp)
    WHERE ((Table3.field5) Is Null)
    ORDER BY Query1.field1, Query1.FieldTmp;
    The Query1 runs as expected, but when I try to run the Query2 I got a ORA-00904 error message. If I remove the (Table3.field5 = Query1.FieldTmp) statement or modify to compare with another field (as instance, field2) everything goes fine.
    If I modify the first query to a make-table query, the Query2 request runs as desired too.
    Is there anything that we can do to keep the queries statement as it is when using the MS Access DB?
    Thanks in advance,
    Elaine Viel Denadai

    Hi Turloch! Thanks for your help!
    Those SQL Statements were extracted from the MS Access application that we will continue to use to access the data , now on an Oracle Database.
    I don't know what I can do to make this kind of statements works as it is on Access database. The first query, that I called Query1 works fine on Oracle, I just mentioned it because the 2nd Query , named Query2, use it.
    I'm not able to understand why when I change the 1st. query to a "make-table" query the Query2 works as desired, but if I keep the Query1 and Query2 as it is on the MS Access Application I got the ODBC error message and the ORA-00904 error message , related (I think!) to the FieldTmp field used on the LEFT JOIN statement (AND).
    As I told before, if I change the AND clause to compare to another field, as instance, field1 :
    FROM Query1 LEFT JOIN Table3
    ON (Table3.field1=Query1.Field2) AND
    (Table3.field5 = Query1.Field1)
    it works.
    Please, is there anything that I can do to keep the MS Access Application unchanged?
    Oracle = 8.1.6
    Oracle ODBC Driver = 8.1.6.4
    Oracle Migration Workbench = 1.3.1
    Thanks in advance,
    Elaine Viel Denadai

  • Problem with select queries

    Dear Friends,
    I have written the below select queries to get the shipment details for a given date range.
    select vbeln lddat
      into table itab
      from likp
      where lddat in l_r_date2 .
      if not it_ldt[] is initial.
        select fknum fkpos rebel
        into table jtab
        from vfkn
        for all entries in itab
        where
        rebel = itab-vbeln.
      endif.
    First query is giving 82000 entries and second query is giving approx 60000 from the table VFKN( total entries in this table are 8 lakhs).
    Here the problem is second select query(for all entries select query) is taking a time of 3 to 4 hours.
    So please suggest me how can i reduce the time.
    Thanks and Regards

    Hi,
    Use FREE or PACKAGE size.
    Some steps that might make FOR ALL ENTRIES more efficient:
    Removing duplicates from the driver table Sorting the driver table
    If possible, convert the data in the driver table to ranges so a BETWEEN statement is used instead of and OR statement:
    FOR ALL ENTRIES IN i_tab
                      WHERE mykey >= i_tab-low and
                 mykey <= i_tab-high.
    Regards
    Krishna

  • Problem with Hierarchies in BPS- Web-Based Planning Applications

    Im trying to use a Web-Based Planning Application in BPS. The Datacolumns consist of a charecterisitc with a hierarchy. this hierarchy is time dependend. The timeframe is set correctly but i still receive an the following error message in my web browser:
    "Hierarchy 'Hierarchy_name' is not valid for date 26.06.2004"
    Does this error message look familiar to anybody? In the moment I have no clue what went wrong

    Hello Tobias,
    I assume you are talking about error message UPC 413 (it always helps to mention the message class and number). Please check table RSHIEDIR. The hierarchy you are using is not valid for the key date you specified (RSHIEDIR-DATEFROM > KEYDATE or RSHIEDIR-DATETO < KEYDATE). If you do not enter a key date in the planning area, the system will always use the system date. So either use a different hierarchy or maintain it differently to be valid on keydate (26.6.2004).
    Regards,
    Marc
    SAP NetWeaver RIG, US BI

  • PROBLEM WITH HIERARCHICAL QUERY - PLEASE HELP

    I have got three tables :
    CREATE TABLE FIRM
    (FID INTEGER NOT NULL PRIMARY KEY,
    FNAME VARCHAR(40),
    FTYPE VARCHAR(3),
    MASTERID INTEGER );
    CREATE TABLE FACULTY
    (FAID INTEGER NOT NULL PRIMARY KEY,
    FANAME VARCHAR(40),
    FATYPE VARCHAR(3),
    MASTERID INTEGER );
    CREATE TABLE EMPLOYEE
         (EID INTEGER NOT NULL PRIMARY KEY,
    ENAME VARCHAR(20),
    ESURNAME VARCHAR(20),
         EJOB VARCHAR(3),
         MASTERID INTEGER );
    This is a hierarchical tree(or is ment to be, I,m complete rookie ) . Firm can be the root or can be slave to another firm. Faculty can be slave to firm, or to another faculty. Employee can be slave to faculty or to another employee(e.g. boss). This connections are specified by MASTERIDs.
    I need to write a procedure, which parameter would be node ID. It is meant to create a VIEW from this node as if it was a root (view of a subtree).
    I tried CONNECT BY clause but it works only on one table at a time and I have here three tables.
    I completely don,t know how to write it. Please help.

    create view hierarchy as
    select id, master_id, name from table1
    union all
    select id, master_id, name from table2
    union all
    select id, master_id, name from table3
    Then do your connect by query against hierarchy.
    It will not work in 8i (connect by on views not allowed), so you will need to materialize the view.
    Kirill

  • Problems with User Queries

    Hi everybody,
    i recieved an error while try to run a user query in Business One which works fine in SQL Studio.
    DECLARE @PROJECT as nvarchar(128)
    SET @PROJECT = '[%0]'
    select query2.docnum, query2.DocStatus, query2.CardCode, query2.CardName, query2.DocDate, query2.DocDueDate, query2.DocTotal, query2.DocTotalSy, query2.CurSource, query1.[Total Sum]
    from
    (select sum(DocTotal) as 'Total Sum' from OPOR where project = @PROJECT ) as query1,
    (select bx.DocNum, bx.DocStatus, bx.CardCode, bx.CardName, bx.DocDate, bx.DocDueDate, bx.DocTotal, bx.DocTotalSy, bx.CurSource from OPOR bx where bx.Project = @PROJECT) as query2
    The Query runs fine if i presect the Projectnumber like SET @PROJECT = '12345678'. But not if the user can choose the project number.
    I tried a lot of variations of that code. But nothing i won't work. Have anybody an Idea what's the problem is?
    Thanks and best Regards,
    Sebastian

    Try this:
    DECLARE @PROJECT as nvarchar(128)
    SET @PROJECT /* select 1 from opor t where t.project */='[%0]'
    select query2.docnum, query2.DocStatus, query2.CardCode, query2.CardName,
    query2.DocDate, query2.DocDueDate, query2.DocTotal, query2.DocTotalSy, query2.CurSource, query1.[Total Sum]
    from
    (select sum(DocTotal) as 'Total Sum' from OPOR where project = @PROJECT ) as query1,
    (select bx.DocNum, bx.DocStatus, bx.CardCode, bx.CardName, bx.DocDate, bx.DocDueDate, bx.DocTotal, bx.DocTotalSy, bx.CurSource from OPOR bx where bx.Project = @PROJECT) as query2

  • Problem with Hierarchical trees (get_tree_node_property)

    Hi All,
    Hope someone can solve this. I am working with developer 6.0 .
    When I try to use get_tree_node_property I get a compile error 201 get_tree_node_property must be declared
    trigger text :
    declare
    test_node Ftree.Node;
    label varchar2(30);
    begin
    test_node:=:SYSTEM.TRIGGER_NODE;
    label := get_tree_node_property('nav_display', test_node,ftree.NODE_icon);
    end;
    it's same with ftree.node_label property
    thanks
    null

    try qualifying the get_tree_node_property with ftree.get_tree_node_property.
    Here is a example
    DECLARE
    htree ITEM;
    node_value VARCHAR2(100);
    BEGIN
    -- Find the tree itself.
    htree := Find_Item('tree_block.htree3');
    -- Find the value of the node clicked on.
    node_value := Ftree.Get_Tree_Node_Property(htree, :SYSTEM.TRIGGER_NODE, Ftree.NODE_VALUE);
    END;

Maybe you are looking for

  • Spotlight does not stop indexing

    I need help: Just started the brand new MacPro 2x 2.66. The long desired spotlight (I run osx 1.3.9 before) does not work. Spotlight never stop to index. It runs and runs. If I add the hard drive to privacy in the system preferences it stops, but as

  • Issue With Shutdown and Reboot

    So I just got home from work and went to watch something on the frontend in the lounge room but the frontend reported it wasn't there. I then noticed that some other shows I know have recorded are shown as not being there either. A check shows all sh

  • Need to have iPad Safari browser support

    OK I know this is hard to do, but I have a site that is redering badly only on the iPad Safari Browser.  It works perfectly in all other browsers on all other platforms.  Any way to get this support?

  • Convert from feet to inches?

    Can numbers convert imported data from feet notation (i.e. 3' 6 1/2") to decimal inches (i.e. 42.5)? I'd like to be able to import rough opening dimensions from my internal CAD (Vectorworks 2008) spreadsheet to generate cut lists with numbers. I can

  • PLS-00801: internal error [76091]

    While creating g SDO_GEOMETRY object and asigning an extralarge value I get the following error: ORA-06550: line 0, column 0: PLS-00801: internal error [76091] snipp__________ DECLARE GEOM MDSYS.SDO_GEOMETRY; BEGIN GEOM := mdsys.sdo_geometry(3,null,n