Home » RADICORE » How To » LIST2 Pattern Problem
Re: LINK2 Pattern Problem [message #2126 is a reply to message #2125] |
Thu, 18 June 2009 09:36 |
AJM
Messages: 2368 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
Ever since you brought this problem with the Oracle database to my attention via private email I have been seeking a proper solution. After playing around with tasks which use either the GROUP BY or HAVING clause I have made changes to the 'dml.oracle.php4/5.class.inc' files so that they can construct valid SQL statements using the information provided.
The problem is that each database vendor uses a different interpretation of the SQL standard, so what works in MySQL may not work in Oracle.
Take, for example, the GROUP BY clause. Oracle insists that every column in the SELECT list is also in the GROUP BY clause whereas MySQL is less strict. Although the Oracle implemetation was true in the SQL standard of 1991 this was changed in 1999 so that any column in the GROUP BY clause which is functionally dependent on another column in the GROUP BY clause does *NOT* have to be included. According to relational theory any non-key column on a table is functionally dependent on the primary key of that table, so if the GROUP BY clause contains the primary key then any non-key columns do not have to be specified.
The HAVING clause is used when the result set needs to be filtered by an aggregated column. This cannot be referenced in the WHERE clause as this is used before the results of the aggregation are known, so it has to be moved to the HAVING clause. MySQL is intelligent in that where the SELECT list contains an entry such as '<expression> AS aliasname' (where <expression> is an aggregation, a function or a subquery) it will allow the HAVING clause to reference that entry by 'aliasname' instead of '<expression>'. This is intelligent because it prevents <expression> from having to be defined and evaluated again. Oracle, on the other hand, is not so intelligent. You cannot use 'aliasname' in the HAVING clause, it has to be '<expression>', but ONLY if it is an aggregation, and not a function or a subquery. The only way around this is to put the SQL statement (without the HAVING clause) in a subquery, then enclose this in an outer query with the HAVING clause switched to the WHERE clause.
The attached file contains updates which work in MySQL, and the 'dml.oracle.php4/5.class.inc' file will automaically make changes to the GROUP BY and HAVING clauses which are required for Oracle.
This means that any changes which you made to either 'dict_table.class.inc' or 'std.table.class.inc' can be reversed out as they are no longer needed.
Try it out and let me know how you get on.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
|
LIST2 Pattern Problem
By: ajwid01 on Thu, 18 June 2009 04:52
|
|
|
Re: LINK2 Pattern Problem
By: AJM on Thu, 18 June 2009 05:25
|
|
|
Re: LINK2 Pattern Problem
By: ajwid01 on Thu, 18 June 2009 05:58
|
|
|
Re: LINK2 Pattern Problem
By: AJM on Thu, 18 June 2009 06:17
|
|
|
Re: LINK2 Pattern Problem
By: ajwid01 on Thu, 18 June 2009 06:24
|
|
|
Re: LINK2 Pattern Problem
By: ajwid01 on Thu, 18 June 2009 07:19
|
|
|
Re: LINK2 Pattern Problem
By: AJM on Thu, 18 June 2009 09:36
|
|
|
Re: LINK2 Pattern Problem
By: ajwid01 on Thu, 18 June 2009 09:40
|
|
|
Re: LINK2 Pattern Problem
By: AJM on Thu, 18 June 2009 10:10
|
|
|
Re: LINK2 Pattern Problem
By: AJM on Mon, 22 June 2009 11:19
|
|
|
Re: LINK2 Pattern Problem
By: ajwid01 on Thu, 18 June 2009 09:52
|
|
|
Re: LINK2 Pattern Problem
By: AJM on Thu, 18 June 2009 10:19
|
|
|
Re: LINK2 Pattern Problem
By: ajwid01 on Thu, 18 June 2009 09:54
|
|
|
Re: LINK2 Pattern Problem
By: ajwid01 on Thu, 18 June 2009 10:30
|
|
|
Re: LINK2 Pattern Problem
By: ajwid01 on Thu, 18 June 2009 10:36
|
|
|
Re: LINK2 Pattern Problem
By: AJM on Thu, 18 June 2009 10:47
|
|
|
Re: LINK2 Pattern Problem
By: ajwid01 on Thu, 18 June 2009 11:01
|
|
|
Re: LINK2 Pattern Problem
By: AJM on Thu, 18 June 2009 11:44
|
|
|
Re: LINK2 Pattern Problem
By: ajwid01 on Thu, 18 June 2009 12:02
|
|
|
Re: LINK2 Pattern Problem
By: AJM on Thu, 18 June 2009 12:52
|
|
|
Re: LINK2 Pattern Problem
By: ajwid01 on Fri, 19 June 2009 08:40
|
|
|
Re: LIST2 Pattern Problem
By: AJM on Fri, 19 June 2009 09:11
|
|
|
Re: LIST2 Pattern Problem
By: ajwid01 on Fri, 19 June 2009 09:58
|
|
|
Re: LIST2 Pattern Problem
By: AJM on Fri, 19 June 2009 10:55
|
|
|
Re: LIST2 Pattern Problem
By: ajwid01 on Mon, 22 June 2009 09:30
|
|
|
Re: LIST2 Pattern Problem
By: AJM on Mon, 22 June 2009 09:51
|
|
|
Re: LIST2 Pattern Problem
By: ajwid01 on Mon, 22 June 2009 11:10
|
|
|
Re: LIST2 Pattern Problem
By: ajwid01 on Mon, 22 June 2009 11:35
|
|
|
Re: LIST2 Pattern Problem
By: ajwid01 on Mon, 22 June 2009 11:38
|
|
|
Re: LIST2 Pattern Problem
By: AJM on Mon, 22 June 2009 11:48
|
Goto Forum:
Current Time: Sun Nov 24 02:53:02 EST 2024
Total time taken to generate the page: 0.03756 seconds
|