Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 DEV-Group
 DEV Discussions (Oracle)
 Oracle 8.1.5.00 SQL differences
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

gor
Retired Admin

Netherlands
5511 Posts

Posted - 11 March 2001 :  04:25:30  Show Profile  Visit gor's Homepage
No question this time, just two things I wanted to post here to remember, and for later refference for MOD builders.

Some differences between the SQL syntax Oracle 8.1.5.0.0 is using and the syntax that is being used so far:

If you do a self-join you can't use this syntax:

SELECT FIELD1, FIELD2 FROM MEMBERS, MEMBERS AS MEMBER_1
WHERE MEMBERS.FIELD3 = MEMBERS_1.FIELD4


There are two things that need to be changed:
1) Oracle doesn't support the AS for tablenames in a self-join
2) Both tables need to have an alias for this to work.

So the correct syntax would be:

SELECT FIELD1, FIELD2 FROM MEMBERS MEMBERS_1, MEMBERS MEMBER_2
WHERE MEMBERS_1.FIELD3 = MEMBERS_2.FIELD4


A way to make the sql-statement work for all is to add this in config.asp:

if strDBType = "oracle" then
strAs = " "
else
strAs = " AS "
end if


and then use:

"SELECT FIELD1, FIELD2 FROM MEMBERS " & strAs & " MEMBERS_1, MEMBERS " & strAs & " MEMBERS_2
WHERE MEMBERS_1.FIELD3 = MEMBERS_2.FIELD4"
ofcourse with the strTablePrefix / strMemberTablePrefix added if you use it in the actual forum-code.
Just remember NOT to use strTablePrefix for the alias names !
So it would be:

strSql = "SELECT FIELD1, FIELD2 FROM "
strSql = strSql & strMemberTablePrefix & MEMBERS " & strAs & " MEMBERS_1, "
strSql = strSql & strMemberTablePrefix & MEMBERS " & strAs & " MEMBERS_2 "
strSql = strSql & " WHERE MEMBERS_1.FIELD3 = MEMBERS_2.FIELD4"


There shouldn't be strTablePrefixes used in the WHERE condition since you are using the aliasses and not the actual table names.


Pierre<
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000 Version 3.4.07