Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE » How To » Customizing the SQL statement
Customizing the SQL statement [message #857] Mon, 28 May 2007 08:38 Go to next message
salamsy
Messages: 18
Registered: October 2006
Location: Dakar
Junior Member
Hi,

I cannot implement an SQL statement containing the modifier "WITH ROLL UP" in the "GROUP BY" clause. It runs fine in Mysql but Radicore returns a parse error.

What about the usage of these modifiers in customizing the SQL statement ?

Thanks.

Abdou
Re: Customizing the SQL statement [message #858 is a reply to message #857] Mon, 28 May 2007 11:45 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2368
Registered: April 2006
Location: Surrey, UK
Senior Member
There are certain places in the framework where I parse the SQL statement in order to make adjustments, such as qualifying field names, and as I haven't yet dealt with any GROUP BY ... WITH ROLL UP it probable than deconstructing and reconstructing the string is causing a problem. Can you provide an example of the sql query you are trying to execute?

Re: Customizing the SQL statement [message #859 is a reply to message #858] Tue, 29 May 2007 06:06 Go to previous messageGo to next message
salamsy
Messages: 18
Registered: October 2006
Location: Dakar
Junior Member
Hi,

This query runs on a single table "awl_leader". It counts the number of records and gives a total for each column specified in GROUP BY.

"select lea_region, lea_degree, count(lea_id) from awl_leader group by lea_region, lea_degree with rollup"

Thanks.

Abdou Salam


Abdou Salam
Re: Customizing the SQL statement [message #860 is a reply to message #859] Tue, 29 May 2007 08:20 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2368
Registered: April 2006
Location: Surrey, UK
Senior Member
I have discovered what the problem is - MySQL does not allow a "GROUP BY ... WITH ROLLUP" to be used with "ORDER BY ...". The solution is to edit the getdata() method inside the 'dml.mysql.class.inc' file in order to change
    if (!empty($this->sql_groupby)) {
        $group_str = "GROUP BY $this->sql_groupby";
    } else {
        $group_str = NULL;
    } // if

to the following:
    if (!empty($this->sql_groupby)) {
        $group_str = "GROUP BY $this->sql_groupby";
        if (eregi(" WITH ROLLUP", $this->sql_groupby)) {
            $this->sql_orderby = null;
        } // if
    } else {
        $group_str = NULL;
    } // if

This will cause the ORDER BY clause to be ommitted if the GROUP BY clause contains "WITH ROLLUP".

This change has been tested with version 1.24.0 and will be included in version 1.25.0


Re: Customizing the SQL statement [message #861 is a reply to message #860] Tue, 29 May 2007 08:46 Go to previous messageGo to next message
salamsy
Messages: 18
Registered: October 2006
Location: Dakar
Junior Member
Hi,

Many thanks for quick support as usual.

Abdou Salam

Re: Customizing the SQL statement [message #862 is a reply to message #861] Tue, 29 May 2007 09:11 Go to previous message
AJM is currently offline  AJM
Messages: 2368
Registered: April 2006
Location: Surrey, UK
Senior Member
Glad to be of service.

Don't applaud, just throw money Smile


Previous Topic: Using dropdown
Next Topic: mnu_task.pattern_id='SEARCH'
Goto Forum:
  


Current Time: Sat Nov 23 08:28:54 EST 2024

Total time taken to generate the page: 0.01127 seconds