Building the tree balanced with SQL hierarchical queries

Hi all

I have the following hierarchical data with different levels of subtree:

A0
-A001
-A00101
A1
-A101
A2
-A201
-A20101
-A201010001

A0 subtree has 3 levels, A1 subtree has 2 levels and subtree of the A3 is level 4. I want to generate a tree balanced on the data with all levels of the subtree equal to the maximum number of levels available in the whole tree which, in this particular case, is 4.

I don't know that it is possible with SQL. Script to generate the above mentioned are as below:

CREATE TABLE codes_tree
(node_id VARCHAR2 (10))
parent_node_id VARCHAR2 (10)
);
INSERT INTO codes_tree VALUES ('A0', NULL);
INSERT INTO codes_tree VALUES ('A001', 'A0');
INSERT INTO codes_tree VALUES ('A00101', 'A001');
---
INSERT INTO codes_tree VALUES ('A1', NULL);
INSERT INTO codes_tree VALUES ('A101', 'A1');
---
INSERT INTO codes_tree VALUES ('A2', NULL);
INSERT INTO codes_tree VALUES ('A201', 'A2');
INSERT INTO codes_tree VALUES ('A20101', 'A201');
INSERT INTO codes_tree VALUES ('A201010001', 'A20101');

Any help will be much appreciated.

Thank you... Best regards

Published by: naive2Oracle on May 12, 2011 19:40

Published by: naive2Oracle on May 12, 2011 19:41

Hello

Of course, you can do it in SQL.
One way is to take the normal output of hierarchical and manipulate the result set so that the leaves are repeated as often as necessary to make all branches of the same length. I have Oracle 10.2 available right now, so here's a solution that will work in Oracle 10 (and more):

WITH     original_hierarchy     AS
(
     SELECT     node_id
     ,     LEVEL               AS lvl
     ,     CONNECT_BY_ISLEAF     AS isleaf
     ,     ROWNUM               AS rnum
     FROM     codes_tree
     START WITH     parent_node_id     IS NULL
     CONNECT BY     parent_node_id     = PRIOR node_id
)
,     got_max_lvl     AS
(
     SELECT     o.*
     ,     MAX (lvl) OVER ()     AS max_lvl
     FROM     original_hierarchy     o
)
SELECT       LPAD ( ' '
            , 3 * ( ( d.lvl
                 + NVL (c.rnum, 1)
                 - 1
                 )
               - 1
               )
            ) || CASE
               WHEN c.rnum > 1
               THEN '*' || d.node_id || '*'
               ELSE        d.node_id
              END          AS display_id
FROM            got_max_lvl     d
LEFT OUTER JOIN       got_max_lvl     c  ON     d.isleaf     = 1
                       AND     c.rnum          <= 1 + d.max_lvl - d.lvl
ORDER BY  d.rnum
,       c.rnum
;

With the help of Oracle 11.2, it would be preferable to generate original_hierarchy as above, but to manipulate using a WITH recursive clause.
Analytical functions often interfere with CONNECT BY, so I used a separate subquery to get max_lvl, do CONNECT BY in a sub-querry and analytic function in a separate subquery. I don't know what is needed on all versions.

Output of your sample data:

DISPLAY_ID
-------------------------------
A0
   A001
      A00101
         *A00101*
A1
   A101
      *A101*
         *A101*
A2
   A201
      A20101
         A201010001

Below is a generic version of the same query, which I used to test this on scott.emp:

DEFINE     table_name     = scott.emp
DEFINE     id_col          = empno
DEFINE     parent_id_col     = mgr
DEFINE     display_col     = ename

WITH     original_hierarchy     AS
(
     SELECT     &display_col          AS display_txt
     ,     LEVEL               AS lvl
     ,     CONNECT_BY_ISLEAF     AS isleaf
     ,     ROWNUM               AS rnum
     FROM     &table_name
     START WITH     &parent_id_col     IS NULL
     CONNECT BY     &parent_id_col     = PRIOR &id_col
)
,     got_max_lvl     AS
(
     SELECT     o.*
     ,     MAX (lvl) OVER ()     AS max_lvl
     FROM     original_hierarchy     o
)
SELECT       LPAD ( ' '
            , 3 * ( ( d.lvl
                 + NVL (c.rnum, 1)
                 - 1
                 )
               - 1
               )
            ) || CASE
               WHEN c.rnum > 1
               THEN '*' || d.display_txt || '*'
               ELSE        d.display_txt
              END          AS display_id
FROM            got_max_lvl     d
LEFT OUTER JOIN       got_max_lvl     c  ON     d.isleaf     = 1
                       AND     c.rnum          <= 1 + d.max_lvl - d.lvl
ORDER BY  d.rnum
,       c.rnum
;

Output:

DISPLAY_ID
-----------------------------
KING
   JONES
      SCOTT
         ADAMS
      FORD
         SMITH
   BLAKE
      ALLEN
         *ALLEN*
      WARD
         *WARD*
      MARTIN
         *MARTIN*
      TURNER
         *TURNER*
      JAMES
         *JAMES*
   CLARK
      MILLER
         *MILLER*

Published by: Frank Kulash, May 13, 2011 06:38
Adding the generic version

Tags: Database

Similar Questions

  • How to order a tree balanced with SQL hierarchical queries

    by searching the forum I found this

    Re: Generate tree balanced with SQL hierarchical queries

    is there a way I can order this tree in alphabetical order so that the result looks like

    LEVEL INDENTED_ENAME
    ---------- --------------------
    1 KING BED
    2 BLAKE
    3 ALLEN
    3 JAMES
    MARTIN 3
    3 TURNER
    WARD 3
    2 CLARK
    3 MILLER
    2 JONES
    3 FORD
    4 SMITH
    3 SCOTT
    4 ADAMS

    -the original query-

    SELECT THE LEVEL
    , LPAD (' ', 3 * LEVEL) | Ename AS indented_ename
    FROM scott.emp
    START WITH mgr IS NULL
    CONNECT BY PRIOR empno = mgr
    ;

    LEVEL INDENTED_ENAME
    ---------- --------------------
    1 KING BED
    2 JONES
    3 SCOTT
    4 ADAMS
    3 FORD
    4 SMITH
    2 BLAKE
    3 ALLEN
    WARD 3
    MARTIN 3
    3 TURNER
    3 JAMES
    2 CLARK
    3 MILLER

    Hello

    Bodin wrote:
    Hi Frank, I can order it selectively depending on the level, which means that only siblings stopped at third level, but rest of the brothers and sisters remain Nations United ordered

    It's actually quite difficult. You can "ORDER of brothers and SŒURS BY CASE... ', like this:

    SELECT  LEVEL
    ,      LPAD (' ', 3 * LEVEL) || ename     AS indented_ename
    FROM      scott.emp
    START WITH        mgr     IS NULL
    CONNECT BY         mgr      = PRIOR empno
    ORDER SIBLINGS BY  CASE
                   WHEN  job = 'MANAGER'  THEN  ename
                                              ELSE  NULL
                 END
    ;
    

    In this case to get desired results in table scott.emp, as the lines are LEVEL = 2 if and only if use = "MANAGER".
    But if you reference LEVEL in the CASE expression (for example, if you replace ' job = 'MANAGER' ' with "2 LEVEL =" above "), then you will get the error" ORA-00976: LEVEL, PRIOR or ROWNUM not allowed here. "
    The best way I can think to do exactly what you asked is to do 2 CONNECT BY queries; one just to get the LEVEL and the other for the brothers and SŒURS ORDER BY:
    {code}
    WITH got_lvl AS
    (
    SELECT LEVEL AS lvl
    Bishop
    empno
    ename
    FROM scott.emp
    START WITH mgr IS NULL
    CONNECT BY PRIOR empno = mgr
    )
    SELECT lvl
    , LPAD (' ', 3 * LEVEL) | Ename AS indented_ename
    OF got_lvl
    START WITH mgr IS NULL
    CONNECT BY PRIOR empno = mgr
    BROTHERS AND SŒURS OF ORDER OF CASES
    ONCE lvl = 2 THEN ename
    ANOTHER NULL
    END
    ;
    {code}
    Why you can't simply "Brothers and SŒURS of ORDER BY ename" at all levels? If all you care is the order of the items of LEVEL = 2, then this is probably the most effective and simplest way. It really hurt anything if nodes on levels 3, 4, 5,... are in order, too?

    Here's something you can do if you want to order by different unique things to different levels:
    {code}
    WITH got_sort_key AS
    (
    SELECT LEVEL AS lvl
    , LPAD (' ', 3 * LEVEL) | Ename AS indented_ename
    empno
    SYS_CONNECT_BY_PATH (LPAD (CASE
    WHEN LEVEL = 2
    THEN ename
    Of OTHER TO_CHAR (empno)
    END
    10
    )
    , ','
    ) AS sort_key
    FROM scott.emp
    START WITH mgr IS NULL
    CONNECT BY PRIOR empno = mgr
    )
    SELECT lvl
    indented_ename
    empno
    OF got_sort_key
    ORDER BY sort_key
    ;
    {code}
    However, all possible values of the CASE expression must uniquely identify the node; otherwise, the output won't necessarily hierarchical order. You can assign arbitrary unique IDS to the lines (using the ROW_NUMBER analytic function, for example), but that requires another subquery and is also complex and perhaps as ineffective as the solution above with 2 garages CONNECT.

  • Fault of commands running in the back ground with sql developer

    Hi all

    I am new user of oracle sql developer. I started using it and found interseting. It is very easy, just using the GUI interfaces. what I do I can do using the interface rather than use commnads. makes my job easier. But here begins my concern

    If I continue to use the tools of one day that I do not know the commands that are run in fact.
    Are there any thought in a way that i can look at this as each commands or queries that are run in the back ground to my statement in the foreground

    Hello

    If you really want to see the SQL and PL/SQL executed for a given connection, you can try the following:

    1. Tools-> monitor Sessions...
    2. Select a connection for a user with the appropriate privileges (for example, must be able to run DBMS_MONITOR)
    3. in the list of sessions, right click on a session of interest, select the tracing Session and click on apply
    4. After completing the desired on the connection of interest activity, close the connection.
    5. open the trace file in SQL Developer (file-> open, or drag and drop it) - make sure that the drop-down list filter is set to all - to see the SQL code.
    6. choose one of the four views of the data in the trace file tabs: list, tree, statistics, history

    Step 5 is easy if the DB is local. For example, with Oracle 10 g Xe on Windows, find the most recent file of the truth and reconciliation Commission in a directory like

    C:\oraclexe\app\oracle\admin\XE\udump

    For a remote database, you will need to copy the TRC on a shared network drive or ftp to your local machine.

    If you just want to see orders DDL that you manipulate object DB connection browser tree definitions or in the object viewer Actions list, interface user provides usually a SQL tab so that you can view the SQL code before clicking the button apply.

    Hope this helps,
    Gary
    SQL development team

  • Function returning the tree used with the object type

    Hi guys!

    I'm fighting for some time now of a function that should return the tree structure of the employees. Let me clarify...
    I have a table say Manager and employees (two columns for an example)
    MANAGER_ID
    EMPLOYEE_ID

    Example:

    MAN_ID - 1; EMPLOYE_ID - 2;
    MAN_ID - 2; EMPLOYE_ID - 3;
    MAN_ID - 2; EMPLOYE_ID - 4;
    MAN_ID - 4; EMPLOYE_ID - 5

    The purpose of my function is back for a specified MAN_ID everyone in the tree...

    Example:

    RETURN_TREE (1) return {2,3,4,5};
    RETURN_TREE (2) returns {3,4,5};
    RETURN_TREE (4) returns {5};

    How to get there?

    With respect,

    PsmakR

    And use BULK COLLECT or the COLLECT function to build the collection:

    create type emp_table as table of number(6);
    /
    
    DECLARE
     v_emp_list emp_table;
    BEGIN
     select cast(collect(employee_id) as emp_table)
     into v_emp_list
     from employees
     connect by prior employee_id = manager_id
     start with manager_id = :p_man_id
    
     -- or
     /*
     select employee_id
     bulk collect into v_emp_list
     from employees
     connect by prior employee_id = manager_id
     start with manager_id = :p_man_id
     */
    END;
    /
    
  • How to build the file manager with cascade?

    Guy of Halo,

    How can IM new with waterfall, I build a file manager with cascade? is there a lesson or sample

    Thank you

    concerning

    Hello

    Can you clarify a little more what you mean by FileManager? Do you want the opportunity to browse and select files? If so, take a look at this thread. http://supportforums.BlackBerry.com/T5/Cascades-development/using-native-FileBrowse-and-FileSave-dia...

    See you soon

    Swann

  • using the same datamodel with SQL database QML in 2 listviews

    I am using the code for the sample application quotes as starting point. I try to call the same SQL database with the quote template to build a list in the top level of my application and then create a list to the next heirachy.
    For, for example, imagine a list of different types of quotes (funny, sad, happy, etc.) on the home page, then the list of people with their quotes on the 2nd level and their exact quote at the 3rd level. When I use the same quotesModel qml and asyncksource at the top of the list and yet once in 2nd list level I get disconnection issues connect to my SQL database. How would I fix this?

    You only need a data source class, but you will need multiple instances of it.

    The disconnect message means that the new connection is now that of the database of driving. Will there be other errors in the log?

  • Wait for the event begins with SQL * Net message from client-time wait 178577 units

    Hello

    I'm watching events waiting for a request from long time in TOAD.
    I start the query on an instance of TOAD, and open the browser to log on to another instance.
    But I am surprised to see that in "TOtal expected" on the RIGHT part->
    SQL * Net message from client is the longest time and is already - > 178577 units while I just to start the query.

    Considering that, in the current waiting she shows DB file scattered read correctly for a few seconds.

    Please suggest.

    user8941550 wrote:
    Hello. No explanation for this... :-(

    Hello

    people work here, you don't know?
    I think Tom Kyte explains it well enough. This wait event is linked to your session database waiting for the guest to say to do something.

    So it is not related to the database, but to your application.
    Also as it is a wait of session event you might have had your session inactive for some time (do nothing)

    If you want to check the waiting events correctly I suggest using tkprof and start a new session in SQL more as shown by Tom Kyte in the link I posted.

    Then, run your query in sqlplus setting track and pull it out as soon as your statement is completed.
    that is to say:

    -- myest.sql
    alter session set events '10046 trace name context forever, level 12';
    SELECT ... -- your query here
    exit
    

    Run in sqlplus in this way:

    sqlplus user/password@db @mytest.sql
    

    Then check with tkprof.

    Kind regards.
    Al

  • Return the same row with 2 different queries

    Can I set up a hint of context that will allow me to do a search on '21-12345' or '21 & 12345' and have the same return line?

    There are various ways you could do this. You could create a lexer which sets the hyphen as white space, so that the chips would be indexed separately. However, the hyphen has a special meaning in the Oracle text. This means less, so if you search for "word1-word2" score by searching "word2" in the document and who subtracted from the score obtained by searching for "word1" in the document. If you want to treat the hyphen as a regular character without meaning of the Oracle text then you need to escape by placing a backslash immediately seized. Similarly, the ampersand has a special meaning; This means and. So, if you search for 'word1 & word2' will be produced documents with the "word1" and "word2" in there. Please see the demo below.

    SCOTT@orcl_11gR2> -- test environment:
    SCOTT@orcl_11gR2> create table your_table
      2    (clob_column  clob)
      3  /
    
    Table created.
    
    SCOTT@orcl_11gR2> insert into your_table (clob_column)
      2  values ('21-12345')
      3  /
    
    1 row created.
    
    SCOTT@orcl_11gR2> insert into your_table (clob_column)
      2  values ('21 & 12345')
      3  /
    
    1 row created.
    
    SCOTT@orcl_11gR2> insert into your_table (clob_column) values
      2  ('some other data you do not want just for testing')
      3  /
    
    1 row created.
    
    SCOTT@orcl_11gR2> begin
      2    ctx_ddl.create_preference ('your_lexer', 'basic_lexer');
      3    ctx_ddl.set_attribute ('your_lexer', 'whitespace', '-');
      4  end;
      5  /
    
    PL/SQL procedure successfully completed.
    
    SCOTT@orcl_11gR2> create index your_index
      2  on your_table (clob_column)
      3  indextype is ctxsys.context
      4  parameters ('lexer your_lexer')
      5  /
    
    Index created.
    
    SCOTT@orcl_11gR2> select token_text from dr$your_index$i
      2  /
    
    TOKEN_TEXT
    ----------------------------------------------------------------
    12345
    21
    DATA
    OTHER
    TESTING
    WANT
    
    6 rows selected.
    
    SCOTT@orcl_11gR2> set define off
    SCOTT@orcl_11gR2> select *
      2  from   your_table
      3  where  contains (clob_column, '21\-12345') > 0
      4  /
    
    CLOB_COLUMN
    --------------------------------------------------------------------------------
    21-12345
    21 & 12345
    
    2 rows selected.
    
    SCOTT@orcl_11gR2> select *
      2  from   your_table
      3  where  contains (clob_column, '21 & 12345') > 0
      4  /
    
    CLOB_COLUMN
    --------------------------------------------------------------------------------
    21-12345
    21 & 12345
    
    2 rows selected.
    
    SCOTT@orcl_11gR2>
    
  • Build the error associated with a class - why?

    I have a class that I am creating I can use in any application as a utility class to call the browser.

    However, when I add this class to an application - any application, including the HelloCascades - the build fails.

    By comparing the console logs I see this at the end of a good generation (without this class)

    "
    CQS-Vgcc_ntox86-lang-c ++ - Wl, - rpath - link, C:, bbndkbeta4, target_10_0_9_1101, qnx6 / x 86/lib - Wl, - rpath - link, C:, bbndkbeta4, target_10_0_9_1101, qnx6 / x 86/usr/lib - o o-g/hellocascades o-g/.obj/hellocascadesapp.o o-g/.obj/main.o o-g/.obj/moc_hellocascadesapp.o - LC: / bbndkbeta4/target_10_0_9_1101/qnx6 / x 86/lib - LC: / bbndkbeta4/target_10_0_9_1101/qnx6 / x 86/usr/lib - LC : / bbndkbeta4/target_10_0_9_1101/qnx6 / x 86/usr/lib/qt4/lib-LC: / bbndkbeta4/target_10_ 0_9_1101/qnx6 / / usr/lib/qt4/lib - lbb - lbbcascades - lQtDeclarative - lQtScript - lQtSvg - lQtSql - lQtXmlPatterns - lQtXml - lQtGui - lQtNetwork - lsocket - lQtCore - lm - lbps
    make [2]: leaving directory had: / downloads/BB10/samples/Cascades-samples-master/hellocascades / x 86 '
    make [1]: leaving directory had: / downloads/BB10/samples/Cascades-samples-master/hellocascades / x 86 '
    Not find qmake configuration directoryCould not found qmake extended from fichierExemple to use OS configuration before installing MAKEFILE_GENERATOR

    "

    But I can't see the following at the end of the construction that fails:

    "

    CQS-Vgcc_ntox86 - c - Wno-psabi-lang-c ++ g - Wno-psabi-wall-W-D_REENTRANT-DQT_NO_IMPORT_QT47_QML-DQ_OS_BLACKBERRY-DQT_DECLARATIVE_LIB-DQT_SCRIPT_LIB-DQT_SVG_LIB-DQT_SQL_LIB-DQT_XMLPATTERNS_LIB-DQT_XML_LIB-DQT_GUI_LIB-DQT_NETWORK_LIB-DQT_CORE_LIB-DQT_SHARED - Ic: / bbndkbeta4/target_10_0_9_1101/qnx6/usr/share/qt4/mkspecs/no taken into charge/blackberry - x 86 - CQS -... /... /hellocascades - Ic: / bbndkbeta4/target_10_0_9_1101/qnx6/usr/include/qt4/QtCore - Ic: / bbndkbeta4/target_10_0_9_1101/qnx6/usr/include/qt4/QtNetwork - Ic: / bbndkbeta4/target_10_0_9_1101/qnx6/usr/include/qt4/QtGui - Ic: / bbndkbeta4/target_10_0_9_1101/qnx6/usr/include/qt4/QtXml - Ic: / bbndkbeta4/target_10_0_9_1101/qnx6/usr/include/qt4/QtXmlPatterns - Ic : / bbndkbeta4/target_10_0_9_1101/qnx6/usr/include/qt4/QtSql - Ic: / bbndkbeta4/target_10_0_9_1101 / QNX6/usr/include/qt4/QtSvg - Ic: / bbndkbeta4/target_10_0_9_1101/qnx6/usr/include/qt4/QtScript - Ic: / bbndkbeta4/target_10_0_9_1101/qnx6/usr/include/qt4/QtDeclarative - Ic: / bbndkbeta4/target_10_0_9_1101/qnx6/usr/include/qt4 - I... / SRC-Io-g/.moc - Ic : / bbndkbeta4/target_10_0_9_1101/qnx6/usr/include - Ic: / bbndkbeta4/target_10_0_9_1101/qnx6/usr/include/freetype2 - i. o o-g/.obj/hellocascadesapp.o... /SRC/hellocascadesapp.cpp
    CQS-Vgcc_ntox86-lang-c ++ - Wl, - rpath - link, C:, bbndkbeta4, target_10_0_9_1101, qnx6 / x 86/lib - Wl, - rpath - link, C:, bbndkbeta4, target_10_0_9_1101, qnx6 / x 86/usr/lib - o o-g/hellocascades o-g/.obj/hellocascadesapp.o o-g/.obj/invokeBrowser.o o-g/.obj/main.o o-g/.obj/moc_hellocascadesapp.o o-g/.obj/moc_invokeBrowser.o - LC: / bbndkbeta4/target_10_0_9_1101/qnx6 / x 86/lib - LC: / bbndkbeta4/target_10_0_9_1101/qnx6 / x 86/usr/lib - LC : / bbndkbeta4/target_10_0_9_1101/qnx6 / x 86/usr / lib/qt4/lib - LC: / bbndkbeta4/target_10_0_9_1101/qnx6 / / usr/lib/qt4/lib - lbb - lbbcascades - lQtDeclarative - lQtScript - lQtSvg - lQtSql - lQtXmlPatterns - lQtXml - lQtGui - lQtNetwork - lsocket - lQtCore - lm - lbps
    Not find qmake configuration not found directoryCould extended fichierExemple of use OS qmake configuration before you set MAKEFILE_GENERATORC:\bbndkbeta4\host_10_0_9_284\win32\x86\usr\bin\ntox86-ld: o-g/.obj/invokeBrowser.o: reference to undefined symbol '_ZN2bb6system13InvokeRequest11setMimeTypeERK7QString'
    make [2]: leaving directory had: / downloads/BB10/samples/Cascades-samples-master/hellocascades / x 86 '
    make [1]: leaving directory had: / downloads/BB10/samples/Cascades-samples-master/hellocascades / x 86 '
    C:\bbndkbeta4\host_10_0_9_284\win32\x86\usr\bin\ntox86-ld: Notes: '_ZN2bb6system13InvokeRequest11setMimeTypeERK7QString' is defined in DSO C:/bbndkbeta4/target_10_0_9_1101/qnx6/x86/usr/lib/libbbsystem.so.1 try so add to the linker command line
    C:/bbndkbeta4/target_10_0_9_1101/QNX6/x86/usr/lib/libbbsystem.so.1: could not read symbols: invalid operation
    CC: C:/bbndkbeta4/host_10_0_9_284/win32 / x 86/usr/bin/ntox86-ld caught signal 1
    make [2]: * [o-g/hellocascades] error 1
    make [1]: * [debug] error 2
    make: * [Simulator-Debug] error 2

    "

    I build to debug on the Simulator.  I tried the built device and these failure too.  I also tried 3 Beta and Beta 4.

    If you look hard you will see in the Console log this:

    ZN2bb6system13InvokeRequest11setMimeTypeERK7QString

    Now if I comment the line defining the Mime type, this changes then to complain about

    _ZN2bb6system13InvokeRequest6setUriERK7QString

    My apologies in advance for the code.  Probably more like to kill, and I'm sure that the code I created is bad c ++, since in reality, I'm a Java learning C++ programmer.  But that being said, I would still like t understand why this class causes the build error.

    TIA

    /*
     * InvokeBrowser.h
     *
     *  Created on: 30 Nov 2012
     *      Author: ps
     */
    
    #ifndef INVOKEBROWSER_H_
    #define INVOKEBROWSER_H_
    
    #include 
    #include 
    #include 
    #include 
    #include 
    
    class InvokeBrowser : public QObject {
    
          Q_OBJECT
    
    public:
        InvokeBrowser(bb::cascades::Container *parent = 0);
        virtual ~InvokeBrowser();
    
        void launchBrowser(QString);
    
    private:
        void processInvokeReply();
        void showToast(const QString );
    
        bb::system::InvokeManager* _invokeManager;
        bb::system::InvokeReply * _invokeReply;
        bb::system::InvokeRequest * _request;
    };
    
    #endif /* INVOKEBROWSER_H_ */
    
    /*
     * InvokeBrowser.cpp
     *
     *  Created on: 30 Nov 2012
     *      Author: ps
     */
    
    #include "InvokeBrowser.h"
    
    #include 
    
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    
    InvokeBrowser::InvokeBrowser(bb::cascades::Container *parent)
        : QObject(parent)  {
    }
    
    InvokeBrowser::~InvokeBrowser() {
        // TODO Auto-generated destructor stub
        if ( ! _invokeManager ) {
            delete _invokeManager;
            _invokeManager = 0;
        }
        if ( _request ) {
            delete _request;
            _request = 0;
        }
    }
    
    void InvokeBrowser::launchBrowser(const QString URL) {
    
        // Create a new invocation request
        _request = new bb::system::InvokeRequest();
        _request->setAction(QLatin1String("bb.action.OPEN"));
        _request->setMimeType(QLatin1String("text/html"));
        _request->setUri(URL);
    
        // Start the invocation
        _invokeManager = new bb::system::InvokeManager();
        _invokeReply = _invokeManager->invoke(*_request);
    
        if (_invokeReply) {
            // Ensure that processInvokeReply() is called when the invocation has finished
            connect(_invokeReply, SIGNAL(finished()), this, SLOT(processInvokeReply()));
        } else {
            showToast("Error starting browser");
            return;
        }
    
    }
    
    void InvokeBrowser::processInvokeReply() {
    
        if ( !_invokeReply ) {
            return;
        }
        // Check for errors during invocation
        switch (_invokeReply->error()) {
            case bb::system::InvokeReplyError::BadRequest:
                showToast("[ErrorBadRequest] Invoke Failed!");
                break;
            case bb::system::InvokeReplyError::Internal:
                showToast("[ErrorInternal] Invoke Failed!");
                break;
            case bb::system::InvokeReplyError::NoTarget:
                showToast("[ErrorNoTarget] Invoke Failed!");
                break;
            case bb::system::InvokeReplyError::TargetNotOwned:
                showToast("[ErrorTargetNotOwned] Invoke Failed.");
                break;
            default:
                break;
        }
        // Delete the reply later on
        _invokeReply->deleteLater();
        _invokeReply = 0;
    
    }
    
    void InvokeBrowser::showToast(const QString toastString) {
        qDebug()<<"Toast: " + toastString;
    
        bb::system::SystemToast *toast = new bb::system::SystemToast();
        toast->setBody(toastString);
        toast->show();
    
    }
    

    try adding bbsystem library to the list of link libraries

  • The white balance with the new update problem

    Just updated to lightroom and now this happens every time I try to change the balance of whites, very annoying when you are using a controller k 4 having to move the mouse backward and that transmits up to now.

    Untitled.jpg

    Hi all

    This issue should be fixed in the 2015.6.1 CC update that went live today. Please upgrade to Lightroom to the latest version.

    More info here: Lightroom CC now available 2015.6.1

    Concerning

    Pete

  • Cannot build the site offline with absolute links

    Hello.

    I'm building a site offline before uploading to the server.

    At first I just use relative links, so everything is fine. But now that I've changed the absolute links, I can't get a preview of my work because all of the scripts, style sheets, images, etc. are linking to an online address that does not exist yet.

    In site manager, I put in my local root folder information, and my http address. It seems to me that Dreamweaver must be able to substitute the local root folder for the http address and thus be able to process the links locally. But this doesn't seem to be the case.

    So, how can I work offline but use absolute links in my documents.

    Thank you.

    > I went to absolute links because I have

    > my pages in separate directories and names of

    > these directories may change.

    I'm not. If directory names are changing, you must update the links - you were using absolute and relative root site or document relative links. Of course, if you change the name of the directory in DW, it will update all your links for your - unless you use absolute links. DW does not have absolute links.

  • Fill in the select list with two different queries depending on the user's group

    Hello

    I finished my first production application using apex. I have a Select list that takes its values from a sql query. Now, I want this different query for each user based on the group. Basically each user sees only the projects they are responsible - that works fine. But I want all the people of the admin group to see all the projects - how can I do this?

    Thank you very much!!!
    Henrik

    Hello

    Try this

    SELECT s.caption || ' - ' || s.sapnr display_value
          ,s.sharedservice_id return_value
    FROM   sharedservices s, sharedservicelead l
    WHERE  (   s.sharedservicelead_id = l.sharedservicelead_id
            OR s.ssldeputy_id = l.sharedservicelead_id
           )
    AND    l.username = :app_user
    UNION
    SELECT s.caption || ' - ' || s.sapnr display_value
          ,s.sharedservice_id return_value
    FROM   sharedservices s
    WHERE  HTMLDB_UTIL.get_groups_user_belongs_to(:APP_USER) = 'capacitymanagement'
    

    See you soon

    Ben

  • variable with sql reuse various clauses

    Hello

    Is it possible to reuse the same variable with sql different queries in the packages...

    Example:

    I have a Word to say variable

    name of the variable 1): filename

    (2) in variable query: select 'emp.txt' of the double

    so using the name of this variable in the data store, I'm passing filename dynamically, but I need to change the file name to dept.txt emp.txt missing emp.txt food.

    A solution on my side uses a table dump with the file name. more without the use of db tables

    Please share views

    See you soon,.
    Surya

    You will then need the help of beanshell java technology. Variable2 take the second query in cooling mode. Now, create a procedure. At the 1st step of technology will be java beanshell with below codes.

    <>
    String xtr = "#variable2";
    @>

    Now in ko-> step use variable1 in assign mode

    Variable1 =<@=xtr@>

    It will certainly work.

    Thank you.

  • ORA-00900 when you use the command COPY with dynamic SQL

    Helllo,
    I created the following procedure:

    create or replace procedure copyTable (pSourceTableOwner IN varchar2
    pSourceTableOwnerPasword IN varchar2
    pTargetTableOwner IN varchar2
    pTableName IN varchar2
    pDatabaseLink IN varchar2)
    as

    vStatement varchar2 (250): = null;

    Start

    vStatement: = "copy of". pSourceTableOwner | '/' || pSourceTableOwnerPasword | '@' || pDatabaseLink |
    "Insert" | pTargetTableOwner | '.' || pTableName | ' using select * from '. pTableName;

    immediately run vStatement;

    end;
    /

    The generated command (variable vStatement) looks like this:
    "Insert a copy of O_GLCEN/o_glcen@SELLENTW o_jh. "X_PLZ_CD_MERGED_CTIS using select * from X_PLZ_CD_MERGED_CTIS".

    When you call this procedure as "exec copyTable ('O_GLCEN', 'o_glcen', 'o_jh', 'X_PLZ_CD_MERGED_CTIS', 'SELLENTW');" the following lifts:

    FEHLER in line 1:
    ORA-00900: invalid SQL statement
    ORA-06512: at "SYSTEMTECHNIK". COPYTABLE", line 20
    ORA-06512: at line 1

    But when you call the command COPY directly from SQL prompt the statement runs without error.
    Is in general not possible to use the dynamic COPY with SQL command? If it is possible does anyone has an idea what I am doing wrong?

    Any help will be appreciated...

    Rgds
    JH

    I would like to use something like

    vStatement: = ' start in f (select * from ' | pSourceTableOwner |) '.' || pTableName | '@' || pDatabaseLink | Insert loop ') in ' | pTargetTableOwner | '.' || pTableName | "f-values; end loop; end; »
    immediately run vStatement;

  • Family tree in PL SQL

    Hello

    I need to create a family tree with data below.

    ID name relationship
    01John01
    02Max01
    03Smith01
    04Paul03
    05Sam03

    John

    -Max

    -Smith

    -Paul

    -Sam

    I've developed a function, if you enter 01 (Paul) ID it will return MAX & SMITH.

    Can you please help how to proceed with a pl sql going down until the family name?

    I also tried to connect you as below link, but every time I finish with "ORA-30009: not enough memory for operation CONNECT BY.

    Representative of the trees in Oracle SQL

    Check this box:

    WITH T (Id,

    Name,

    Relationship) AS

    (SELECT '01', 'John', '01' FROM DUAL

    UNION ALL

    SELECT '02', 'Max', '01' FROM DUAL

    UNION ALL

    SELECT '03', 'Smith', '01' FROM DUAL

    UNION ALL

    SELECT '04', 'Paul', '03' FROM DUAL

    UNION ALL

    SELECT '05', 'Sam', '03' FROM DUAL

    UNION ALL

    SELECT '06', 'New', '06' DOUBLE)

    Select lpad (substr (nm, instr (nm, ' /',-1) + 1, length (nm)),)

    length (substr (nm, instr (nm, ' /',-1) + 1, length (nm))) +.

                instr(nm, '/', -1), ' ') nm

    from (SELECT NAME, SYS_CONNECT_BY_PATH (NAME, ' /') nm)

    T

    Start with the identity card - relationship = 0

    CONNECT RELATED NOCYCLE = PRIOR ID)

    SQL >

    23.

    NM

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

    John

    Max

    Smith

    Paul

    Sam

    New

    6 selected lines

    SQL >

    -----

    Ramin Hashimzade

Maybe you are looking for

  • request for iPhoto

    Hello When I have my digital camera the thumb importimages in a folder of the event and appear with the title awarded by the camera (e, g, DSCF0001). I rename all with eight-digit reference number, but if I copy them to a memory stick, they always di

  • Why Wizard does not start when the current user?

    Program does not RUN. Wizard does not open after you select the Option for the current user

  • Recovery on Portege M200?

    First of all, everyone knows how to fix system restore problem, when I start the system restore, it appears only a blank window, so I could not restore my computer to an earlier point, which I think can solve the problem together...Since then, I coul

  • system error 070100 00AD027C

    HP printer system error 070100 00AD027C Please give the answer how do slove. Thank you. Jacques nichet

  • black screen after update?

    After installing the updates, my screen is black and I can't do anything? Help