Results 1 to 1 of 1

Thread: Despair- My error is half way down the page now

  1. #1
    tlck9 is offline Sugar Community Member
    Join Date
    Aug 2006
    Posts
    71

    Angry Despair- My error is half way down the page now

    I am sorry to post this again, but I dont seem to be able to cure this problem and It is getting beyond a joke, with the error spanning half of the screen.

    I am using

    The version of SQL we are using is SQL Server 2005, on a PC with Windows XP sp2

    Version 4.5.1d (Build 1273)

    the compatibility mode is set to 90

    Here is a snapshot of my error:
    SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.SQL Error : 'ROW_NUMBER' is not a recognized function name.

    Top of the screen. Also whenever I click on a hoerlink re to take me to the account I get the same error


    I've found the function in the MSSQLManager.php file and there is a number of places the variables exist, so I've copied the whole function and pasted it below...
    -----------------------------------------------------------------------------------------------------------------

    function limitQuery($sql,$start,$count, $dieOnError=false, $msg=''){
    $newSQL = $sql;
    if (strpos($sql, "UNION"))
    {
    $newSQL = $this->handleUnionLimitQuery($sql,$start,$count);
    }else{
    if ($start < 0) $start=0;
    $GLOBALS['log']->debug(print_r(func_get_args(),true));
    $this->lastsql = $sql;
    preg_match("/^(\s*SELECT )(.*?FROM.*WHERE)(.*)$/is",$sql, $matches);
    if(!empty($matches[3])){
    if($start == 0){
    $match_two = strtolower($matches[2]);
    if(!strpos($match_two, "distinct")> 0 && strpos($match_two, "distinct") !==0){
    //proceed as normal
    $newSQL = $matches[1] . " TOP $count " . $matches[2] . $matches[3];
    }else{

    $distinct_o = strpos($match_two, "distinct");
    $up_to_distinct_str = substr($match_two, 0, $distinct_o);
    //check to see if the distinct is within a function, if so, then proceed as normal
    if(strpos($up_to_distinct_str,"(")){
    //proceed as normal
    $newSQL = $matches[1] . " TOP $count " . $matches[2] . $matches[3];

    }else{
    //if distinct is not within a function, then parse

    //string contains distinct clause, "TOP needs to come after Distinct"
    //get position of distinct
    $match_zero = strtolower($matches[0]);
    $distinct_pos = strpos($match_zero , "distinct");
    //get position of where
    $where_pos = strpos($match_zero, "where");
    //parse through string
    $beg = substr($matches[0], 0, $distinct_pos+9 );
    $mid = substr($matches[0], strlen($beg), ($where_pos+5) - (strlen($beg)));
    $end = substr($matches[0], strlen($beg) + strlen($mid) );
    //repopulate matches array
    $matches[1] = $beg; $matches[2] = $mid; $matches[3] = $end;

    $newSQL = $matches[1] . " TOP $count " . $matches[2] . $matches[3];
    }
    }
    }
    else{
    preg_match("/^(.*)(ORDER BY)(.*)$/is",$matches[3], $orderByMatch);

    //if there is a distinct clause, parse sql string as we will have to insert the rownumber
    //for paging, AFTER the distinct clause
    $hasDistinct = strpos($matches[0], "distinct");
    if($hasDistinct){
    $matches_sql = strtolower($matches[0]);
    $distinct_pos = strpos($matches_sql , "distinct");
    $distinct_com_pos = strpos($matches_sql , ",",$distinct_pos );
    $where_pos = strpos($matches_sql, "where");
    //split the sql into a string before and after the distinct clause
    if ($distinct_pos>0 && $distinct_com_pos>0){
    $distinctSQLARRAY[0] = substr($matches_sql,0, $distinct_com_pos+1);
    $distinctSQLARRAY[1] = substr($matches_sql,$distinct_com_pos+1);
    //get position of order by (if it exists) so we can strip it from the string
    $ob_pos = strpos($distinctSQLARRAY[1], "order by");
    if($ob_pos){
    $distinctSQLARRAY[1] = substr($distinctSQLARRAY[1],0,$ob_pos);

    }

    }

    }

    if(!empty($orderByMatch[3])){
    //if there is a distinct clause, form query with rownumber after distinct
    if($hasDistinct){
    $newSQL ="SELECT TOP $count * FROM
    (
    " . $distinctSQLARRAY[0] . " ROW_NUMBER() OVER (ORDER BY " . $this->returnOrderBy($sql, $orderByMatch[3]) . ") AS row_number, " . $distinctSQLARRAY[1]. "
    ) AS a
    WHERE row_number > $start";

    }else{
    $newSQL ="SELECT TOP $count * FROM
    (
    " . $matches[1] . " ROW_NUMBER() OVER (ORDER BY " . $this->returnOrderBy($sql, $orderByMatch[3]) . ") AS row_number, " . $matches[2] . $orderByMatch[1]. "
    ) AS a
    WHERE row_number > $start";

    }

    }else{
    //if there is a distinct clause, form query with rownumber after distinct
    if($hasDistinct){
    $newSQL ="SELECT TOP $count * FROM
    (
    " . $distinctSQLARRAY[0] . " ROW_NUMBER() OVER (ORDER BY ".$this->getTableNameFromModuleName($_REQUEST['module'],$sql).".id) AS row_number, " . $distinctSQLARRAY[1] . "
    ) AS a
    WHERE row_number > $start";

    }else{
    $newSQL ="SELECT TOP $count * FROM
    (
    " . $matches[1] . " ROW_NUMBER() OVER (ORDER BY ".$this->getTableNameFromModuleName($_REQUEST['module'],$sql).".id) AS row_number, " . $matches[2] . $matches[3]. "
    ) AS a
    WHERE row_number > $start";
    }
    }

    }
    }

    }
    $GLOBALS['log']->debug('Limit Query: ' . $newSQL);
    $result = $this->query($newSQL, $dieOnError, $msg);
    $this->dump_slow_queries($newSQL);
    return $result;
    }
    ------------------------------------------------------------------------

    Hopefully someone will now be able to point us in the right direction






    PLEASE PLEASE HELP ME.....

    Tracey
    Last edited by tlck9; 2007-08-08 at 03:42 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 10
    Last Post: 2009-05-25, 08:06 AM
  2. Replies: 0
    Last Post: 2007-04-25, 03:09 AM
  3. Replies: 2
    Last Post: 2006-05-05, 07:33 PM
  4. External logining page
    By marcinand in forum Help
    Replies: 6
    Last Post: 2005-05-06, 06:00 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •