Complex transformations in SELECT

Hi everyone,
I have a pretty complex situation where I have to apply transformations on data in a SQL SELECT Statement. The thing is that I have absolultely no idea how to handle this.
Let's imagine I have an hierarchy table, like an organizational hierarchy.
CREATE TABLE organisations
   organisation_id number(10) PRIMARY KEY,
   parent_organisation_id number(10),
   name_en varchar2(255),
   name_nl varchar2(255),
   CONSTRAINT fk_org_to_par_org
      FOREIGN KEY (parent_organisation_id)
       REFERENCES organisations(organisation_id)
INSERT INTO organisations VALUES (1, null, 'Top organization 01', 'Top organizatie 01');
INSERT INTO organisations VALUES (11,   1, 'Organization 011', 'Organizatie 011');
INSERT INTO organisations VALUES (12,   1, 'Organization 012', 'Organizatie 012');
INSERT INTO organisations VALUES (2, null, 'Top organization 02', 'Top organizatie 02');
INSERT INTO organisations VALUES (21,   2, 'Organization 021', 'Organizatie 021');
INSERT INTO organisations VALUES (22,   2, 'Organization 022', 'Organizatie 022');
INSERT INTO organisations VALUES (3, null, 'Top organization 03', 'Top organizatie 03');
INSERT INTO organisations VALUES (31,   3, 'Organization 031', 'Organizatie 031');
INSERT INTO organisations VALUES (32,   3, 'Organization 032', 'Organizatie 032');
INSERT INTO organisations VALUES (321, 32, 'Organization 321', 'Organization 321');
INSERT INTO organisations VALUES (322, 32, 'Organization 322', 'Organization 322');And I have to apply some transformations in the SELECT. These transformations are store in a table. I have a few different transformations. I just put 3 here as examples:
CREATE TABLE transformations
  transform_id number(10),
  transform_type CHAR(1),
  organ_id  number(10),
  organ_name varchar2(255),
  parent_organ_id number(10),
  replace_name varchar2(255),
  with_children char(1)
INSERT INTO transformations(transform_id, transform_type, organ_name, parent_organ_id, organ_id)
     VALUES (1, 'C', 'Created NODE', 1, -9);
INSERT INTO transformations(transform_id, transform_type, organ_name, replace_name)
     VALUES (2, 'R', 'Organization 021', 'Organization 021 renamed');
INSERT INTO transformations(transform_id, transform_type, organ_name, replace_name, with_children)
     VALUES (3, 'R', 'Organization 032', 'Organization 032 Renamed', '1');The first transformation is to create a node under an existing one. The second transformation example is to rename a node. The pattern is actually a regular expression and it will use regexp_replace (to be able to add in the begining, change, add in the end...). The 3rd example is a rename too but all the children of a node should also be renamed with the same pattern.
I need a result like this one: (I indented to read more easilly)
1, ,Top Organisation 01, Top organizatie 01    
  -9, 1, Created Node, Created Node     
  11, 1, Organization 011, Organizatie 011
2, ,Top Organisation 02, Top organizatie 02    
  21, 2, Organization 021 renamed, Organization 021 renamed     
  22, 2, Organization 022, Organizatie 022
3, ,Top Organization 03, Top organizatie 03    
  31, 3, Organization 031, Organization 031    
  32, 3, Organization 032 Renamed, Organization 032 Renamed
    321, 32, Organization 032 Renamed, Organization 032 Renamed
    322, 32, Organization 032 Renamed, Organization 032 Renamed I was thinking if it was possible to apply these modifications on a SELECT clause without creating another table and refreshing it by parsing the initial table? Any suggestions?
Thanks,

Hi Frank, 
I have been thinking for days on this problem... That's probably why I can't explain it correctly. SO let me try again. Let's restart evrything and recreate the ORGANISATIONS table.
set define off;
DROP TABLE ORGANISATIONS;
DROP TABLE TRANSFORMATIONS;
CREATE TABLE organisations 
   organ_id number(10) PRIMARY KEY, 
   parent_organ_id NUMBER(10), 
   organ_name varchar2(255), 
   CONSTRAINT fk_org_to_par_org 
      FOREIGN KEY (parent_organ_id) 
       REFERENCES organisations(organ_id)
INSERT INTO organisations(organ_id, parent_organ_id, organ_name) 
     VALUES (11, NULL, 'Sales');
INSERT INTO organisations(organ_id, parent_organ_id, organ_name) 
     VALUES (23, NULL, 'R&D');
INSERT INTO organisations(organ_id, parent_organ_id, organ_name) 
     VALUES (71, NULL, 'Logistics');
INSERT INTO organisations(organ_id, parent_organ_id, organ_name) 
     VALUES (87, 71, 'Transport');Once you executed the previous statements, you have the following result:
SELECT organ_id, parent_organ_id, CAST(LPAD(' ', LEVEL * 2) || organ_name as VARCHAR2(25)) AS a
  FROM organisations
 START WITH parent_organ_id IS NULL
CONNECT BY PRIOR organ_id = parent_organ_id;
ORGAN_ID               PARENT_ORGAN_ID        A                         
11                                              Sales                   
23                                              R&D                     
71                                              Logistics               
87                     71                         Transport             The organisation has 3 root department: Sales, R&D and logistics. The logistics department has a child department called transport.
Now, the previous tree comes from a remote database but that's not the point. It can not be used as provided. I have to apply some modification to that tree before I can use it. That's why I creat the TRANSFORMATIONS table. 
CREATE TABLE transformations
  transform_id number(10), 
  transform_type CHAR(1), 
  organ_id  number(10), 
  organ_name varchar2(255), 
  parent_organ_id number(10),
  replace_name varchar2(255)
);Now, every record inserted in that table is a transformation to apply to the original tree. One of the transformation I need to apply is to create organisations. 
For example:
INSERT INTO transformations(transform_id, transform_type, organ_id, organ_name, 
                            parent_organ_id)
      VALUES(  35, 'C', -19, 'Local sales', 11);The previous transformation means: Create a new organisation named 'Local Sales' under the Sales organization. Let's review the different values in the INSERT statement. The transform_ID is a generated ID. We don't really care about it.The transform_type 'C' means create an organization (node). The -19 is the ID that that new organization should have. 'Local Sales' is the name of that new organization and 11 is his parent id. That's with this parent-id that I know where to put the new node in the tree.
After applying this transformtation, the result should be:
ORGAN_ID               PARENT_ORGAN_ID        A                         
11                                              Sales                   
-19                    11                         Local sales 
23                                              R&D                     
71                                              Logistics               
87                     71                         Transport             Of course, I can have other CREATE transformations:
INSERT INTO transformations(transform_id, transform_type, organ_id, organ_name, 
                            parent_organ_id)
      VALUES(  64, 'C', -23, 'Foreign sales', 11);
INSERT INTO transformations(transform_id, transform_type, organ_id, organ_name, 
                            parent_organ_id)
      VALUES(  66, 'C', -26, 'South America', -23);
INSERT INTO transformations(transform_id, transform_type, organ_id, organ_name, 
                            parent_organ_id)
      VALUES(  97, 'C', -13, 'IT', null);After applying these transformations, the result should be :
ORGAN_ID               PARENT_ORGAN_ID        A                         
11                                              Sales                   
-19                    11                         Local sales 
-23                    11                         Foreign sales 
-26                    -23                          South America 
23                                              R&D                     
71                                              Logistics               
87                     71                         Transport             
-13                                             ITI hope this is clear now? I wanted to know if it's possible to apply such transformations directly in the SELECT statement without having to code a PL/SQL package that does it for me?
Now the problem is that I can have other type of transformations. For example, some nodes should be renamed. 
For example, if I insert this transformation:
INSERT INTO transformations(transform_id, transform_type, organ_id, replace_name)
      VALUES(  60, 'R', 11, 'Sales department');Instead of returning the name 'Sales' for the organization with ID = 11, it should return 'Sales department'. The 'R' transformation type means rename and the org_id is the organization to rename and the new name is supplied using replace_name.
The most difficult transformation is probably the next one. It defines nodes to retrieve by organization. For example, let's add the following data:
INSERT INTO organisations(organ_id, parent_organ_id, organ_name) 
     VALUES (50, NULL, 'Security');
INSERT INTO organisations(organ_id, parent_organ_id, organ_name) 
     VALUES (51, 50, 'Building');
INSERT INTO organisations(organ_id, parent_organ_id, organ_name) 
     VALUES (80, 51, 'Parkings');
INSERT INTO organisations(organ_id, parent_organ_id, organ_name) 
     VALUES (81, 80, 'Parking 1');
INSERT INTO organisations(organ_id, parent_organ_id, organ_name) 
     VALUES (82, 81, 'Parking 1 - Level 0');
INSERT INTO organisations(organ_id, parent_organ_id, organ_name) 
     VALUES (52, 50, 'Software');
INSERT INTO organisations(organ_id, parent_organ_id, organ_name) 
     VALUES (52, 50, 'Other kind of security');AS you can see in the following result, the Security organization has 4 levels below.
SELECT organ_id, parent_organ_id, LEVEL, CAST(LPAD(' ', LEVEL * 2) || organ_name as VARCHAR2(30)) AS a
  FROM organisations
 START WITH parent_organ_id IS NULL
CONNECT BY PRIOR organ_id = parent_organ_id;
ORGAN_ID               PARENT_ORGAN_ID        LEVEL                  A                              
11                                            1                        Sales                        
23                                            1                        R&D                          
50                                            1                        Security                     
51                     50                     2                          Building                   
80                     51                     3                            Parkings                 
81                     80                     4                              Parking 1              
82                     81                     5                                Parking 1 - Level 0  
71                                            1                        Logistics                    
87                     71                     2                          Transport                  
 9 rows selected 
 I also should be able to define with a transformation the number of level to retrieve for a specific node. 
ALTER TABLE transformations 
  ADD max_children number(10) default 4;
INSERT INTO transformations(transform_id, transform_type, organ_id, max_children)
      VALUES(  20, 'L', 50, 2);In the previous transformation, I specify a 2 level for the organization 50. In this case, the final result should only return 2 level under the organization 50. So instead of having 5 levels as in the previous result, I should have
ORGAN_ID               PARENT_ORGAN_ID        LEVEL                  A                              
11                                            1                        Sales                        
23                                            1                        R&D                          
50                                            1                        Security                     
51                     50                     2                          Building                   
80                     51                     3                            Parkings                 
71                                            1                        Logistics                    
87                     71                     2                          Transport                  As you can see, there are a lot of different type of transformations that should be done and I don't think SQL is intented for such things?
Thank you again for your help Frank, I really appreciate

Similar Messages

  • Using Transform or Selection tools makes my non-background layers or whole document invisible.

    I recently started having this problem in Photoshop CS6 where using the transform or selection tools makes all the layers other than my background layer disappear so I can't see what I'm selection or transforming. This happens randomly out of nowhere. I can be using those tools all day with no problem, and then out of nowhere it starts making things invisible. There doesn't seem to be any other programs running that would cause it (not that that should be an issue, my computer could easily run all my Adobe programs at once if I wanted it to), and the only thing that seems to fix it so far is restarting Photoshop. But that gets old really fast when I have to do it over and over again. I tried calling Adobe, but somehow they're always closed, even during their supposed hours of operation.

    You can also try to disable the GPU accleration (hardware acceleration) completely. Usually it is the drivers to blame, but on some PC's I have noticed that disabling it completely provides better performance and a better experience than having it enabled. In my case, I lose some features that I do not use so it is not an issue for me.

  • Using Transform or Selection tools makes my non-background layers invisible.

    I recently started having this problem in Photoshop CS6 where using the transform or selection tools makes all the layers other than my background layer disappear so I can't see what I'm selection or transforming. This happens randomly out of nowhere. I can be using those tools all day with no problem, and then out of nowhere it starts making things invisible. There doesn't seem to be any other programs running that would cause it (not that that should be an issue, my computer could easily run all my Adobe programs at once if I wanted it to), and the only thing that seems to fix it so far is restarting Photoshop. But that gets old really fast when I have to do it over and over again. I tried calling Adobe, but somehow they're always closed, even during their supposed hours of operation.

    Hi there,
    I'm sorry you're having problems with your software. The first step is to be sure you have all applicable updates. Secondly, you may need to reset your preferences.
    This link has a number of steps that may help you deal with your issue:
    http://forums.adobe.com/thread/375776
    I hope that following the instructions solve your problem, but if not, please don't hesitate to check in.

  • Complex transformation inserting xml data to oracle database.

    Hi,
    I Have one small Problem While loading xml data to a oracle database.
    In the XSD i have the Columns Like this.
    <Data>
    <Type_Trs>
    <T1>
    <T2>
    </Data>
    My Database contains only two columns
    For Example:
    Type_Trs
    Corr_Data.
    Now My problem is Based on Type_Trs Value i need to take values of T1 and T2 should be loaded in Corr_Data column.
    How to write Xsl transformation for this using <xsl:choose>.
    For Clearing the Question I am giving the Example.
    Case : 1
    <Data>
    <type_Trs>BO</Type_Trs>
    <T1>1</T1>
    <T2>2</T2>
    </Data>
    In the Example my type_trs is value 'BO', so the Data in table should be
    Type_Trs Corr_Data
    ======= =======
    BO 1
    Case : 2
    <Data>
    <type_Trs>CP</Type_Trs>
    <T1>1</T1>
    <T2>2</T2>
    </Data>
    In the Example my type_trs is value 'CP', so the Data in table should be
    Type_Trs Corr_Data
    ======= =======
    CP 2
    For doing this How can i write my XSL transformation based on the condition?
    Thanks in advances
    Regards
    GSR

    Why do you need a XSL transformation for this? Can you not get the results based on this select:
    SQL> SELECT DISTINCT EXTRACTVALUE (t2.COLUMN_VALUE, 'Type_Trs') type_trs,
                    CASE EXTRACTVALUE (t2.COLUMN_VALUE, 'Type_Trs')
                       WHEN 'BO'
                          THEN EXTRACTVALUE (t3.COLUMN_VALUE, 'T1')
                       WHEN 'CP'
                          THEN EXTRACTVALUE (t4.COLUMN_VALUE, 'T2')
                    END corr_data
               FROM TABLE
                       (XMLSEQUENCE
                           (EXTRACT
                               (XMLTYPE
                                   ('<Data>
                          <Type_Trs>BO</Type_Trs>
                          <T1>1</T1>
                          <T2>2</T2>
                          <Type_Trs>CP</Type_Trs>
                          <T1>1</T1>
                          <T2>2</T2>
                        </Data>'
                                '/Data'
                       ) t1,
                    TABLE (XMLSEQUENCE (EXTRACT (t1.COLUMN_VALUE,
                                                 '/Data/Type_Trs')
                          ) t2,
                    TABLE (XMLSEQUENCE (EXTRACT (t1.COLUMN_VALUE, '/Data/T1'))) t3,
                    TABLE (XMLSEQUENCE (EXTRACT (t1.COLUMN_VALUE, '/Data/T2'))) t4
    TYPE_TRS   CORR_DATA
    CP         2        
    BO         1        

  • Complex Restrictions in Select-options

    Hi Team,
    I've coded SELECT-OPTIONS in my web dynpro(ABAP) and want to disable the complex selection button/link (displayed just before the actual field). This link takes the user to either "Exclude" the selection or other options like "GE", "BT" etc. I actually want that user should only select ONE value with sign="I" and Option='EQ'. Is there a way to manage this? Please help.
    Thanks for your time.
    P.S: Points will be awarded for solutions

    Hi Sanjay.
    You can switch of intervall and complex restrictions using the 
    parameters I_USE_COMPLEX_RESTRICTION and I_NO_INTERVALS
    of the method ADD_SELECTION_FIELD:
    wd_this->mr_selop->add_selection_field(
                             i_id = lv_fieldname
                             i_no_intervals = abap_true
                             i_use_complex_restrictions = abap_false
    Hope this helps.
    Cheers,
    Sascha

  • Transforming A Selection Using A Path As A Guide (In CS3)

    Sometimes I like to draw a path first to be my guide when performing a transformation. But, silly-billy old me, I often press command-T which then attempts to transform the path, not the selection.
    So I end up pressing:
    command-T, command-Z, command-H, command-T, command-H !
    On my good days I use:
    command-H, command-T, command-H
    Is there a better way?
    Thanks
    David

    As far as I know, that is the way.

  • Understanding complex query with selections(customer exit variables)

    Hi experts,
    I am trying to understand one query having  a combination of selections and BEx variables in it.
    In Characteristic Restrictions panel of Query Designer:
    we have some CHARs restricted by means of authorisation variables
    In Default Values panel:
    some other CHARs without any filters
    In free CHARS panel
    some characteristics
    In Rows panel:
    some more chars that were placed in Default values panel
    In Columns panel:
    Formula YTD on selection YTD
    Formula Monthly on selection Monthly
    Selection on YTD characteristic(hidden)
    Selection on Monthly characteristic(hidden)
    Selection XX(in definition,I saw selection on YTD Keyfigure and a characteristic variable VAR1(i-step=1) filled with customer exit..this variable picks up right version of Master Data...our system has many versions of master data,one for each year)
    Selection YY(in definition,I saw selection on Monthly key figure and the same characteristic variable VAR1 we used in Selection XX)
    When I execute this..I see one variable popup which asks for values for year and version of master data...I enter master data version for that year and the year....I see the result...
    Now I tried to experiment to learn...I deleted Selection XX and Selection YY and tried to execute....a variable popup asking for year...I enter year and tried to execute..it throws message---'Value for variable VAR2 cannot be determined'......
    I couldnot understand this error because VAR2 is a customer exit characteristic variable defined in CMOD...ITS NEVER USED IN THIS QUERY...but defined in CMOD to pick up correct version of Master data..its defined in such a way that it picks value depending upon VAR1 varaible....both variables function is same...its just that  VAR1 works on i_step=1 and VAR2 works on i_step=2 plus dependent on VAR1....
    Can anyone understand why I am seeing error about VAR2 when its never used in Query....??
    Thanks for your inputs....

    Hi Vikram,
    I am unable to find VAR2 anywhere in query designer....Can it be like that its hidden?
    Thanks and Rgds,
    SChand

  • Loading Data into Table with Complex Transformations

    Hello Guys
    I am trying to load data into one of the Dimension table and it has quite a few Transformations and i created 6 temp tables
    1. It has 7 Columns , Gets 935 rows based on where condition
    2. It has 10 Columns , Gets 935 rows with but it has nulls in it i.e for column 1 there are 500 fields and columns 2 there are 300 etc ...
    3 , 4 , 5 , 6 all the same as the 2 table
    and at the end when i am trying to join all the temp tables with the Product_id into the target , which is in each temp table ...
    I am Getting Error Saying Not Obeying Primary key Constraints i.e unique values are not been inserting into the Product_id Column of Target Table and the Job is running for Hours
    and the main Problem comes at , some of the Columns have the same Product_id
    Please help me
    I have been Trying for 1 week and i am in Full pressure
    Thanks
    Sriks
    Edited by: Sriks on Oct 16, 2008 6:43 PM

    Hi,
    If you are creating a warehouse and product_key is ur PK then it should come only once and so u might have to think ur logic in getting the data. To get over the isue u can disable the constraint and load with out the cosntraint, but i would have u look at the logic and make sure u have only 1 product_key in the table.
    Regards
    Bharath

  • These documents are too complex for the selected mode. Please select scanned documents and try again

    Getting this error message all of a sudden when i try to compare two documents in Acrobat 9 Pro. I work in Indesign with an annual report. Each time i make a new pdf i compare it with the previous version and it has been working fine until now. I have mounted high-res pictures into the Indesign document since it's getting close to print date. And it's after that it has stopped working. I don't know if it's because the file is so large (15mb).
    It's really urgent, can someone please help?
    Thanks
    Tommie

    Hello Tommie,
    I have been informed that you are uploading the files for us to review. Please contact me directly about this issue [email protected]
    What kind of changes have you made to the documents? If you can provide a detailed description of what  you noticed that has changed, that would be very helpful. I am sure we will be able to resolve this
    Scott

  • Another hierarchical query

    Hi,
    Frank, can you help me one last time? Please?? I'm still working on this hierarchical queries and I think you're the only one who can help.
    I need to do a complex SELECT between two table. Your help in this previous post (Complex transformations in SELECT was very helpful.
    I learned a lot and could implement almost all the transformations that I have to but I have a really weird one... I have to be able to limit the number of descendants for a given node.
    Let's take this DEPARTMENT table, it's a simple hierachical table. Ids are convinient but in reality id are completely random:
    SET DEFINE OFF;
    DROP TABLE DEPARTMENTS;
    CREATE TABLE DEPARTMENTS
      dpt_id NUMBER(10),
      parent_id NUMBER(10),
      dpt_name VARCHAR2(100)
    INSERT INTO DEPARTMENTS VALUES(1, null, 'Sales');
    INSERT INTO DEPARTMENTS VALUES(2, null, 'Insurance');
    INSERT INTO DEPARTMENTS VALUES(3, null, 'Accounting');
    INSERT INTO DEPARTMENTS VALUES(4, null, 'R & D');
    INSERT INTO DEPARTMENTS VALUES(5, null, 'IT');
    INSERT INTO DEPARTMENTS VALUES(10, 1, 'Local Sales');
    INSERT INTO DEPARTMENTS VALUES(11, 1, 'European Sales');
    INSERT INTO DEPARTMENTS VALUES(12, 1, 'Asian Sales');
    INSERT INTO DEPARTMENTS VALUES(13, 1, 'South American Sales');
    INSERT INTO DEPARTMENTS VALUES(110, 11, 'Germany');
    INSERT INTO DEPARTMENTS VALUES(111, 11, 'France');
    INSERT INTO DEPARTMENTS VALUES(112, 11, 'Belgium');
    INSERT INTO DEPARTMENTS VALUES(113, 11, 'Luxembourg');
    INSERT INTO DEPARTMENTS VALUES(114, 11, 'Spain');
    INSERT INTO DEPARTMENTS VALUES(1101, 110, 'Berlin');
    INSERT INTO DEPARTMENTS VALUES(1111, 111, 'Paris');
    INSERT INTO DEPARTMENTS VALUES(1121, 112, 'Brussels');
    INSERT INTO DEPARTMENTS VALUES(1141, 114, 'Madrid');
    INSERT INTO DEPARTMENTS VALUES(1142, 114, 'Barcelona');
    INSERT INTO DEPARTMENTS VALUES(1143, 114, 'Malaga');
    INSERT INTO DEPARTMENTS VALUES(121, 12, 'China');
    INSERT INTO DEPARTMENTS VALUES(20, 2, 'Car Insurance');
    INSERT INTO DEPARTMENTS VALUES(21, 2, 'Home Insurance');
    INSERT INTO DEPARTMENTS VALUES(22, 2, 'Family Insurance');
    INSERT INTO DEPARTMENTS VALUES(200, 20, 'Bus');
    INSERT INTO DEPARTMENTS VALUES(201, 20, 'Family car');
    INSERT INTO DEPARTMENTS VALUES(2011, 201, 'Sub category for family car');
    INSERT INTO DEPARTMENTS VALUES(202, 20, 'Sport car');And I also have another table with gives for a given node the number of allowed descendants for a given node.
    CREATE TABLE LIMITATIONS
      dpt_id NUMBER(10),
      lvl_cnt NUMBER(10) -- max descendants
    INSERT INTO LIMITATIONS VALUES(1, 4);
    INSERT INTO LIMITATIONS VALUES(11, 1);
    INSERT INTO LIMITATIONS VALUES(2, 2);
    INSERT INTO LIMITATIONS VALUES(20, 2);For example, the first record inserted in the limitation table means that for the department with id 4 we take 4 descedants. The weird thing is that the node 11 is a decendant of the node 11. And that one override his parent value. At that level, we override the value and we accept one decending level.
    THis first example remove the Berlin record in the result.
    THe second pair of insert is to have the second scenario that I have to handle. Instead of overriding a parent limitation by decreasing it, I have to also support increasing values. A decendant node may
    have a bigger value than a parent one.
    This second example keeps the department with dpt_id = 2011. Even if I take only 2 descendant for the department with id = 2.
    "LEVEL"                       "DPT_ID"                      "PARENT_ID"                   "LPAD('',LEVEL)||DPT_NAME"   
    "1"                           "1"                           ""                            " Sales"                     
    "2"                           "10"                          "1"                           "  Local Sales"              
    "2"                           "11"                          "1"                           "  European Sales"           
    "3"                           "110"                         "11"                          "   Germany"                 
    "3"                           "111"                         "11"                          "   France"                  
    "4"                           "1111"                        "111"                         "    Paris"                  
    "3"                           "112"                         "11"                          "   Belgium"                 
    "4"                           "1121"                        "112"                         "    Brussels"               
    "3"                           "113"                         "11"                          "   Luxembourg"              
    "3"                           "114"                         "11"                          "   Spain"                   
    "4"                           "1141"                        "114"                         "    Madrid"                 
    "4"                           "1142"                        "114"                         "    Barcelona"              
    "4"                           "1143"                        "114"                         "    Malaga"                 
    "2"                           "12"                          "1"                           "  Asian Sales"              
    "3"                           "121"                         "12"                          "   China"                   
    "2"                           "13"                          "1"                           "  South American Sales"     
    "1"                           "2"                           ""                            " Insurance"                 
    "2"                           "20"                          "2"                           "  Car Insurance"            
    "3"                           "200"                         "20"                          "   Bus"                     
    "3"                           "201"                         "20"                          "   Family car"              
    "4"                           "2011"                        "201"                         "    Sub category for family car"
    "3"                           "202"                         "20"                          "   Sport car"               
    "2"                           "21"                          "2"                           "  Home Insurance"           
    "2"                           "22"                          "2"                           "  Family Insurance"         
    "1"                           "3"                           ""                            " Accounting"                
    "1"                           "4"                           ""                            " R & D"                     
    "1"                           "5"                           ""                            " IT"                         Any suggestion on how I can proceed? I'm still using Oracle 10g Release 2
    Thanks in advance,

    You are completely right. My examples are not very correct and easy to understand. I've been working on these tables for too long...
    But let me first tell you about the origin of the problem. The main organisation tree I work on has like 60000 nodes. That's a lot of nodes and creating an insert statement for each node is not relevant. I just try to keep the problem simple so everyone can understand it.
    My problem is that I have to limit the nodes I import. The way I limit them is by using another table, the LIMITATIONS table. That table contains 2 columns. THe first one is the department id and the second one is the number of descending levels to retrieve.
    To explain it the best way, I'll try to do it step by step:
    Here is my initial set of data.
    TRUNCATE table departments;
    alter table limitations rename column lvl_cnt to descendant_cnt;
    INSERT INTO departments values(1, null, 'name 1');
    INSERT INTO departments values(10, 1, 'name 10');
    INSERT INTO departments values(100, 10, 'name 100');
    INSERT INTO departments values(1000, 100, 'name 1000');
    INSERT INTO departments values(10000, 1000, 'name 10000');
    INSERT INTO departments values(100000, 10000, 'name 100000');
    INSERT INTO departments values(10000000, 1000000, 'name 10000000');
    TRUNCATE table limitations;
    INSERT INTO LIMITATIONS VALUES(1, 4);The following request returns 6 rows:
    SELECT LEVEL,
           a.dpt_id,
           a.parent_id,
           LPAD(' ', LEVEL) || a.dpt_name,
           b.descendant_cnt
      FROM departments a
      LEFT JOIN limitations b ON (a.dpt_id = b.dpt_id)
      START WITH a.parent_id IS NULL
    CONNECT BY PRIOR a.dpt_id = a.parent_id;But I have to write a SELECT statement that limits this result to 4 records. Why? Because in my limitations table, I have the record that says for department with id = 1, limit to 4 descending levels. The result should be :
    "LEVEL"                       "DPT_ID"                      "PARENT_ID"                   "LPAD('',LEVEL)||A.DPT_NAME"  "DESCENDANT_CNT"
    "1"                           "1"                           ""                            " name 1"                     "4"
    "2"                           "10"                          "1"                           "  name 10"                   ""
    "3"                           "100"                         "10"                          "   name 100"                 ""
    "4"                           "1000"                        "100"                         "    name 1000"               ""I don't really need the level info or the descendant_cnt attribute. I just need it to be limited. Now imagine that I add these records in the departments table.
    INSERT INTO departments values(11, 1, 'name 11');
    INSERT INTO departments values(110, 11, 'name 110');
    INSERT INTO departments values(1110, 110, 'name 1110');
    INSERT INTO departments values(11110, 1110, 'name 11110');
    INSERT INTO departments values(111110, 11110, 'name 111110');
    INSERT INTO departments values(1111110, 111110, 'name 1111110');The final result should be the following one. Because the limitation is on levels and not counting nodes.
    "LEVEL"                       "DPT_ID"                      "PARENT_ID"                   "LPAD('',LEVEL)||A.DPT_NAME"  "DESCENDANT_CNT"             
    "1"                           "1"                           ""                            " name 1"                     "4"                          
    "2"                           "10"                          "1"                           "  name 10"                   ""                           
    "3"                           "100"                         "10"                          "   name 100"                 ""                           
    "4"                           "1000"                        "100"                         "    name 1000"               ""                           
    "2"                           "11"                          "1"                           "  name 11"                   ""                           
    "3"                           "110"                         "11"                          "   name 110"                 ""                           
    "4"                           "1110"                        "110"                         "    name 1110"               ""                            If I change the limitation and ask something impossible, like this:
    TRUNCATE table limitations;
    INSERT INTO LIMITATIONS VALUES(1, 100);I should return the whole tree, without adding new nodes or something...
    Now it gets more complicated. As I said before, I have a huge organisational tree and I need to be able to retrieve a given number of levels at a specific node. Let's have another example:
    TRUNCATE table limitations;
    INSERT INTO LIMITATIONS VALUES(1, 2);
    INSERT INTO LIMITATIONS VALUES(10, 2);If I put this limitations on my tree, I ask to have a 2 descending levels from the department with id = 1 and I override that limitation on the department id = 10. That means that I want 2 descending levels starting from the node with department id = 1 but when it comes to node 10, I need two additional levels.
    "LEVEL"                       "DPT_ID"                      "PARENT_ID"                   "LPAD('',LEVEL)||A.DPT_NAME"  "DESCENDANT_CNT"             
    "1"                           "1"                           ""                            " name 1"                     "2"                          
    "2"                           "10"                          "1"                           "  name 10"                   ""                           
    "3"                           "100"                         "10"                          "   name 100"                 ""                           
    "4"                           "1000"                        "100"                         "    name 1000"               ""                           
    "2"                           "11"                          "1"                           "  name 11"                   ""                            But look at node with dpt_id = 11. It does not have any descending levels because the limitation comes from a parent node (in this case, it's because the limitation on the department dpt_id =1 that should retrieve only 2 descending levels).
    Now, I can also have the other schenario that instead of increasing a parent limit, I decrese it. For example, imagine the following case:
    TRUNCATE table limitations;
    INSERT INTO LIMITATIONS VALUES(1, 7);
    INSERT INTO LIMITATIONS VALUES(10, 2);The previous limitations means I want 7 descending levels from dpt_id = 1 but when it comes to dpt_id = 10, I just want to restrict it to 2 descending levels more... Not untill the 7 descending levels are retrieved.
    "LEVEL"                       "DPT_ID"                      "PARENT_ID"                   "LPAD('',LEVEL)||A.DPT_NAME"  "DESCENDANT_CNT"             
    "1"                           "1"                           ""                            " name 1"                     "7"                          
    "2"                           "10"                          "1"                           "  name 10"                   "2"                          
    "3"                           "100"                         "10"                          "   name 100"                 ""                           
    "4"                           "1000"                        "100"                         "    name 1000"               ""                           
    "2"                           "11"                          "1"                           "  name 11"                   ""                           
    "3"                           "110"                         "11"                          "   name 110"                 ""                           
    "4"                           "1110"                        "110"                         "    name 1110"               ""                           
    "5"                           "11110"                       "1110"                        "     name 11110"             ""                           
    "6"                           "111110"                      "11110"                       "      name 111110"           ""                           
    "7"                           "1111110"                     "111110"                      "       name 1111110"         ""                            When I speak about level, I mean Oracle level. Root level is 1.
    I think if I can handle these 2 case scenario, I can handle all the limitation I have to apply my original set. Is it more clear now??
    Thank you again Frank

  • How to keep transform constant ratio selected and show instantly properties

      When pasting an object as layer to base image, I keep select tool Show transform Controls selected. Pasted object has rectangles as expected but select tool doesn't display it's properties ribbon next to it, until I select object corner. Only then I can set keep ratio selection. 1.When opening new image, I have to set constant ratio each time again. How to set constant ratio constantly on? 2. Even if the ribbon always visible setting would be of a great help.
    Thank you!
    CS5, XP Pro

    I don't think there's any way to get that setting to stick, unfortunately.  Note that whenever  you start Edit - Free Transform the H & W aren't locked together either.
    You could try to get in the habit of holding the shift key down when sizing, to keep H & W resizing locked together.
    -Noel

  • Photoshop CS4 transform selection bug?

    Hello. 
    First off a minor rant about these forums.  I already had a Adobe ID which doubles for a forum login ONLY ON FORMER MACROMEDIA FORUMS!  I have to have a completely different login for original Adobe software forums. Jeez WTF? 
    Ok so if I make a selection in Photoshop CS4 Extended, then go to transform selection and transform the selection, the resulting selection has a 1-2 pixel semi transparent edge.  I have double checked my settings so make sure there is no feathering applied.  It only happens when I use select>transform selection.  It is driving me nuts as I use this method for making pricise selections in my regular workflow.  I find it easier to make a close selection then resize with transform.  But now when I go to paste it into a new layer/document there's now a "feathered" edge for lack of a better term.  So now I have to either use add/subtract from the selection or make a precise selection in the option bar.
    has anyone else noticed this in their PS CS4?  I never noticed it in CS3.  I'm contemplating going back to CS3 as the "tabbed" interface is balls as is app frame.  And yes I know I can turn it off which I have, but still have to deal with inadvertent document tabbing when moving windows around.
    Thanks.

    >the ATI 9600 which is another beast
    My bad. :(
    > I always hate trashing the preference file as I end up having to spend time getting everything back the way I like it.
    Kevin, you won't lose your workspaces, just the settings from the Preferences menu item and your Color Settings. But, here's a tip: next time you have to re-set them, just record yourself in an action as you're doing it. Next time all you have to do is run the action. :)
    Oh, and you don't have to trash any file(s) manually. Just hold down Command Option Shift as you launch Photoshop.

  • Cannot Define New Pattern from Transformed Selection

    I am having some trouble making a new pattern from a selection in Photoshop CS6. If I simply use the rectangular selection tool over an area that I would like to make a new pattern from, I can go to Edit > Define Pattern to make a new pattern from my selection. However, if I transform the selection or create a selection using ctrl-click on a layer, the option Edit > Define Pattern is unavailable. I haven't been able to find anything online that explains why this would happen, so I've decided to try my luck here. Any insight will be appreciated! Thank you!

    conroy2009: I used the rectangular selection tool and the option was there; when using the Transform Selection (feathering is not an option for that as far as I know) command and after positioning it correctly and accepting the new selection, the Define Pattern is not an option. I don't believe feathering is involved. However, perhaps the Transform Selection does anti-alias for some reason... which kind of irritates me. I just want to be able to make a more specific selection without using the pen tool for a simple rectangle. Strange that it would also apply an effect. :/ So, do other people just use the rectangular selection tool and get the exact position correct on the first shot?

  • How to display Selection screen on Web for RSCRM_BAPI

    HI,
    For a customer we want to create the possibility to extract data from BI2004s to other systems, therefore we want to use RSCRM_BAPI.
    Thing is that we want to provide the possibility for them to enter selectioncriteria, but we don't want them to log on using the Gui.
    We want to use the VC to create an interface cockpit.
    question is how we can allow users to use selectioncriteria but:
    variants can not be used
    TVARV can not be used
    is there any way to capture the selection screen and to display it on the web/VC?
    Anyone ever did this?
    Tnx
    rogier

    Gili.
    thank you for your quick reply,.
    Reason why we are looking into the RSCRM_BAPI is due to the layout
    requirements of the extract. the recieving systems requires specific layouts. If we do this with the infospoke we will have to use a BADI to perfom complex transformations which will need additional knowlegde (of BADI's) of the support organisation whereas with RSCRM_BAPI they can adjust the query.
    and as far as i know you can not define the variable input via the web for open hub.
    Grtz
    rogier

  • Advanced Masking/Selection Capabilities

    How to select a part of an image for masking based on either color saturation or  hue or a certain color (not RGB value but rather a color group), so that I can  transform the selection to the Alpha channel.
    For example, if I have a  photo of a red car on a multi-color, complex background where there are NO other  red colors exist on the picture, other than the body of the car, then such  selection (that I need help with) suppose to select all shades of red on the  photo, which is only the body of the car.
    I guess you know what I'm  trying to do, right? I need to create a PNG file where certain part of an image  (like a body of that car) would be gray-scale alpha channel, so that by placing  the image file on colored background - that would simply paint the car into  another color.
    See an example on this page: http://www.netchain.com/test/Png.asp

    Thank you very much for such a thorough respond. Since it seems like you know your way around Photoshop, I thought I would ask  you another question, if you don't mind of course.
    The reason I was looking for the answer for my previous question, was because I  wanted to transform that
    selection into gray-scale alpha channel, so that if  I save the file as PNG maintaining gray-scale transparency
    in the  alpha-channel, and if I place that PNG file on colored background on the web,  then the part of the
    image in alpha-channel suppose to get colored  accordingly to the background color.
    I was wondering if you can help me  with that, since I'm a bit confused about the Alpha-channel. I think I  can
    apply the alpha-channel to the selection, but it doesn't get saved in PNG  file, probably because I am missing
    something
    You can see the example  of the image that I want to make (made by someone else) on this test page:
    http://netchain.com/test/Png.asp
    As  you can see on that page, the sweater on the picture has alpha-channel, so it  assumes the color of the
    background of each block.
    Thank you very much  in advance, and God bless you.
    Sana

Maybe you are looking for

  • ITunes quits when I try to watch downloaded TV shows

    My iTunes quits each time I try to play any episode of the TV shows I've downloaded. I've rebuilt disk permissions, restarted my computer, deleted the shows and re-downloaded them - done the basic tricks that usually solve the issues my computer is c

  • Puzzled by "negative files" in v1.1 "Export as Catalog"

    I've been exploring the new features in v.1.1, and have found something I'm puzzled by. When I go to File/Export as Catalog, there is an option called "Export negative files", which will include duplicates of the original image files in the exported

  • Copy from PDF paste to Notes iOS 4 iPhone 3GS

    The bluetooth keyboard works so good on the iphone I thought I wouuld line u a bunch of work for the flight to Halifax from Vancouver. But alsa I cannot copy from a pdf "Snow leopard server manual" to my Notes program. How do you copy from a pdf and

  • Dynamic Reports. Runtime parameter passing to Report Query.

    Hi everyone, I have developed a report using apex shared components (report query and report layout) along with BI Publisher for report printing in pdf format. the Report template is built using Template Builder for Word. I have configured my Apex4.1

  • Table for Pur Grp and Plant

    Hi Guys Is there any table where we can see the Plant number with Purchase Group. I tried MARC but its associated with Material and iam getting huge number of results. Thanks ronnie