Solved

Convert Hierarchical query to ANSI Sql

Posted on 2013-01-22
6
412 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
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 142

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

813 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now