Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with creating view in SQL Developer

Status
Not open for further replies.

CrystalizeCanada

Instructor
Mar 4, 2009
141
0
0
CA

Hi there,

I have created a Pivot query in Oracle 11g SQL developer and it runs great.

I now want to save as a view (I have rights to do this) and when I get an error I check for erros with the same SQL (I'm just copying and pasting).
I'm just copying it and pasting it so I'm puzzled. Am I not allowed to create a view with this syntax?


WITH pivot_data AS (
SELECT ITEM_CODE, URULE_CODE, RULEIT_TEXT
FROM Lego.RULEIT
WHERE URULE_CODE LIKE 'IInk%'
)
SELECT * FROM pivot_data
PIVOT (
MAX(RULEIT_TEXT)
FOR URULE_CODE
IN (
'IInk10Com',
'IInk10CoPl'
))

any help would be greatly appreciated.

Thanks
Gord

Gordon BOCP
Crystalize
 
Gord,

I believe you will have success if you simply place CREATE VIEW WHATEVER AS... in front of your code:
Code:
CREATE VIEW WHATEVER AS
WITH pivot_data AS (
 SELECT ITEM_CODE, URULE_CODE, RULEIT_TEXT
 FROM Lego.RULEIT
 WHERE URULE_CODE LIKE 'IInk%'
)
SELECT * FROM pivot_data
PIVOT (
MAX(RULEIT_TEXT)
FOR URULE_CODE
IN (
'IInk10Com', 
'IInk10CoPl'
))
Here is a proof of concept that I just tried:
Code:
SQL> create view v as with x as (select * from s_emp) select * from x;

View created.
Let us know your findings,.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
“People may forget what you say, but they will never forget how you made them feel.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top