On Fri, Jan 17, 2003 at 03:53:52PM +0000, Diana Soares wrote:
> Hi,
> I coudn't compile the my-mysql-utils.cc file.. 
> I'm not going to ask you for help on this (you have more interesting
> things to do :-) and also i didn't used the same version of gcc as you
> did). I've done an UDF sometime ago (microseconds()) and i'll solve the
> problem this time.
> 
> But before i spend more time on this, i would like to see an example of
> your concat_grouped UDF. 
> 
> Could you please send me an example (with results - copy&paste)? 
> The example you gave on the web page did not have the results (also i
> didn't understand the concat() instead of concat_grouped() use.
> 

*blush* my bad.

Here is the updated part of the website.

        CREATE AGGREGATE FUNCTION concat_grouped RETURNS STRING
        SONAME 'my-mysql-utils.so';

        CREATE TABLE table1 ( 
            a int, 
            b varchar(255)
        );

        INSERT INTO table1 VALUES
            (1, 'a'), (1,'b'), (1,'c'),
            (2, 'x'), 
            (3,null), 
            (4, 'eeee'), (4, 'fff'),
            (5, '')
        ;
        
        SELECT a, concat_grouped(b) FROM table1 GROUP BY a;

    +------+-------------------+
    | a    | concat_grouped(b) |
    +------+-------------------+
    |    1 | abc               |
    |    2 | x                 |
    |    3 | NULL              |
    |    4 | eeeefff           |
    |    5 |                   |
    +------+-------------------+

        SELECT a, concat_grouped(b,'-') FROM table1 GROUP BY a;

    +------+-----------------------+
    | a    | concat_grouped(b,'-') |
    +------+-----------------------+
    |    1 | a-b-c                 |
    |    2 | x                     |
    |    3 | NULL                  |
    |    4 | eeee-fff              |
    |    5 |                       |
    +------+-----------------------+

        SELECT a, concat_grouped(b,IF(b = 'b','/',';')) FROM table1 GROUP BY a;

    +------+---------------------------------------+
    | a    | concat_grouped(b,IF(b = 'b','/',';')) |
    +------+---------------------------------------+
    |    1 | a/b;c                                 |
    |    2 | x                                     |
    |    3 | NULL                                  |
    |    4 | eeee;fff                              |
    |    5 |                                       |
    +------+---------------------------------------+

        DROP FUNCTION concat_grouped;

> Thanx in advance,

You're welcome.

> Diana Soares
> 
> 
> -------- my error: ---------
> $ make
> g++ -O3 -I /usr/include/mysql -fno-implicit-templates \
>         -fno-exceptions -fno-rtti -rdynamic -shared \
>         -o my-mysql-utils.so my-mysql-utils.cc
> my-mysql-utils.cc:15: syntax error before `=' token
> my-mysql-utils.cc:16: syntax error before `=' token
> my-mysql-utils.cc:51: 'string' is used as a type, but is not defined as
> a type.
> ...
> 

Somehow it seems to me that your compiler doesn't know about the string
type; but you guessed as much me-thinks. You might want to change some
of the -fXX stuff, like removing them altogether. I actually stole them
from the mysql example provided in the manual :)

> and the other errors are dependent of that ones (undefined
> Usage,etc..)
> I'm using:
> gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
> ----------------------------------------------------
> 
> 
> On Thu, 2003-01-16 at 15:42, Renald Buter wrote:
> > Hai there,
> > 
> > I have created a concat_grouped implementation as a mysql function. And
> > I thought it might interest other users too. No guarantees here, but you
> > might learn from it.
> > 
> > Find it at www.cwts.nl/buter/misc.html
> > 
> > Regards,
> > 
> > Renald
> -- 
> Diana Soares
> 

Renald Buter 

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to