Solved

Convert Hierarchical query to ANSI Sql

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

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

I guess that all of us know that caching the data usually increase the performance, but I worried if all of us are aware about the risk that caching the data provides and how to minimize this.  That’s the reason why I decided to write this short art…
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
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.
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…

792 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