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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Frustrating Error

Status
Not open for further replies.

Dario1984

Technical User
Aug 23, 2005
12
0
0
AU
I'm new to SQL and have tried a number of ways to fix my "missing right parenthesis" error. It puts an asterisk under the keywork ORDER.

CREATE VIEW DRINKER_LIKES_PUB_LOC_VIEW (NAME, DRINK, PUB, STREET, ADDNO) AS
(
SELECT DRINKER_LIKES_PUB_VIEW.Name, DRINKER_LIKES_PUB_VIEW.Drink, DRINKER_LIKES_PUB_VIEW.Pub, Street, Bldg#
FROM Drinker_Likes_Pub_View LEFT OUTER JOIN Located
ON Drinker_Likes_Pub_View.Pub = Located.Pub
ORDER BY Name, Drink
);

Any knowledge about this error would be apprecaited.
 
Dario,

Oracle does not allow an "ORDER BY" in the SELECT statement that defines a VIEW. If you wish to "ORDER BY Name, Drink", then you do that after you have created the view, as you assess the view.

Let us know how things go following that change.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[ Providing low-cost remote Database Admin services]
Click here to join Utah Oracle Users Group on Tek-Tips if you use Oracle in Utah USA.
 
Thanks mate. It's nice to pick up these little important pieces of knowledge from experienced users.
 
If I use that view to build up another view, can I sort it before I create the next view ?
 
Dario,

One of the specifications of a relational table is that the data is "unordered". You should never base any part of an application upon the physical order of a table's rows.

A practical/functional reason why you must not depend on the physical order of rows is because if someone DELETEs one or more rows from a table, when a subsequent INSERT occurs, that INSERT can place the new row into the physical bytes of a previously DELETEd row, thus ruining the sort order upon which your application inappropriately depends.

Therefore, it is good form to always use an ORDER BY in your access statements at query time; do not ever depend upon physical position of rows.

Thoughts???

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[ Providing low-cost remote Database Admin services]
Click here to join Utah Oracle Users Group on Tek-Tips if you use Oracle in Utah USA.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top