Solved

Convert Hierarchical query to ANSI Sql

Posted on 2013-01-22
6
446 Views
Last Modified: 2014-05-12
I need to convert this connect by statement to ANSI Sql/ SQL-92 ANSI standard

CREATE OR REPLACE VIEW "IN21_BIRD"."V_UGROUP_GLOBAL_HIERARCHY" ("UGROUP_NAME_INDENTED", "UIC", "HIER_LEVEL", "IS_LEAF", "PATH", "UGROUP_PK", "REGION_PK", "UGROUP_NAME") AS
SELECT     LPAD (' ', LEVEL - 1) || ugroup_name AS ugroup_name_indented,
            uic, LEVEL AS hier_level, CONNECT_BY_ISLEAF AS is_leaf,
            SYS_CONNECT_BY_PATH (ugroup_name, '\') AS PATH, ugroup_pk,
            region_fk AS region_pk, ugroup_name
       FROM ugroup_global
 START WITH ugroup_fk IS NULL
 CONNECT BY PRIOR ugroup_pk = ugroup_fk

CREATE TABLE ADMIN.UGROUP_GLOBAL
(
  UGROUP_PK SMALLINT NOT NULL,
  UGROUP_NAME CHARACTER VARYING(35) NOT NULL,
  UGROUP_FK SMALLINT,
  UIC CHARACTER VARYING(6),
  REGION_FK BYTEINT NOT NULL,
  IS_HOME CHARACTER(1) NOT NULL,
  VALID_START DATE,
  VALID_END DATE
)
DISTRIBUTE ON RANDOM;
0
Comment
Question by:rockrem
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 38808797
having sample data always help^s

what database are you targetting ?
i guess it's from oracle to something else ?
0
 

Author Comment

by:rockrem
ID: 38809799
Postgres
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 38896939
that would be this kind of syntax:
http://www.postgresql.org/docs/8.4/static/queries-with.html
the CTE expressions with recursive working
0

Featured Post

Webinar: MongoDB® Index Types

Join Percona’s Senior Technical Services Engineer, Adamo Tonete as he presents “MongoDB Index Types, How, When and Where Should They be Used?” on Wednesday, July 12, 2017 at 11:00 am PDT / 2:00 pm EDT (UTC-7).

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question