dbTalk Databases Forums  

CREATE FUNCTION not working in MYSQL 5.1

comp.databases.mysql comp.databases.mysql


Discuss CREATE FUNCTION not working in MYSQL 5.1 in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
scooper
 
Posts: n/a

Default CREATE FUNCTION not working in MYSQL 5.1 - 03-06-2010 , 05:04 AM






Would anyone know why this doesn't run

delimiter //

CREATE FUNCTION hello (s CHAR(20)) RETURNS CHAR(50)
RETURN CONCAT('Hello, ',s,'!');
//
delimiter ;
SELECT hello('world');

It comes from the MYSQL Help File.

scooper

Reply With Quote
  #2  
Old   
Lennart
 
Posts: n/a

Default Re: CREATE FUNCTION not working in MYSQL 5.1 - 03-06-2010 , 06:03 AM






On 6 mar, 11:04, "scooper" <robert... (AT) internode (DOT) on.net> wrote:
Quote:
Would anyone know why this doesn't run

delimiter //

CREATE FUNCTION hello (s CHAR(20)) RETURNS CHAR(50)
RETURN CONCAT('Hello, ',s,'!');
//
delimiter ;
SELECT hello('world');

It comes from the MYSQL Help File.

scooper
Works for me, what was the error you got?

mysql> delimiter //
mysql>
mysql> CREATE FUNCTION hello (s CHAR(20)) RETURNS CHAR(50)
-> RETURN CONCAT('Hello, ',s,'!');
-> //
Query OK, 0 rows affected (0.00 sec)

mysql> delimiter ;
mysql> SELECT hello('world');
+----------------------------------------------------+
Quote:
hello('world') |
+----------------------------------------------------+
Hello, world ! |
+----------------------------------------------------+
1 row in set (0.01 sec)

mysql> select @@version;
+-----------+
Quote:
@@version |
+-----------+
5.1.42 |
+-----------+
1 row in set (0.00 sec)

/Lennart

Reply With Quote
  #3  
Old   
scooper
 
Posts: n/a

Default Re: CREATE FUNCTION not working in MYSQL 5.1 - 03-06-2010 , 06:24 AM



It fails as soon as it hits the first left bracket.

scooper


"Lennart" <erik.lennart.jonsson (AT) gmail (DOT) com> wrote

Quote:
On 6 mar, 11:04, "scooper" <robert... (AT) internode (DOT) on.net> wrote:
Would anyone know why this doesn't run

delimiter //

CREATE FUNCTION hello (s CHAR(20)) RETURNS CHAR(50)
RETURN CONCAT('Hello, ',s,'!');
//
delimiter ;
SELECT hello('world');

It comes from the MYSQL Help File.

scooper

Works for me, what was the error you got?

mysql> delimiter //
mysql
mysql> CREATE FUNCTION hello (s CHAR(20)) RETURNS CHAR(50)
-> RETURN CONCAT('Hello, ',s,'!');
-> //
Query OK, 0 rows affected (0.00 sec)

mysql> delimiter ;
mysql> SELECT hello('world');
+----------------------------------------------------+
| hello('world') |
+----------------------------------------------------+
| Hello, world ! |
+----------------------------------------------------+
1 row in set (0.01 sec)

mysql> select @@version;
+-----------+
| @@version |
+-----------+
| 5.1.42 |
+-----------+
1 row in set (0.00 sec)

/Lennart

Reply With Quote
  #4  
Old   
Luuk
 
Posts: n/a

Default Re: CREATE FUNCTION not working in MYSQL 5.1 - 03-06-2010 , 06:38 AM



Op 6-3-2010 12:24, scooper schreef:
Quote:
"Lennart" <erik.lennart.jonsson (AT) gmail (DOT) com> wrote in message
news:afb18c08-e7bd-41cc-b7c8-46e87b3b7ba8 (AT) m37g2000yqf (DOT) googlegroups.com...
On 6 mar, 11:04, "scooper" <robert... (AT) internode (DOT) on.net> wrote:
Would anyone know why this doesn't run

delimiter //

CREATE FUNCTION hello (s CHAR(20)) RETURNS CHAR(50)
RETURN CONCAT('Hello, ',s,'!');
//
delimiter ;
SELECT hello('world');

It comes from the MYSQL Help File.

scooper

Works for me, what was the error you got?

It fails as soon as it hits the first left bracket.

scooper


He did not ask WHEN it fails, but what is the error you get when trying
to do what you did..



--
Luuk

Reply With Quote
  #5  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: CREATE FUNCTION not working in MYSQL 5.1 - 03-06-2010 , 07:59 AM



scooper wrote:
Quote:
It fails as soon as it hits the first left bracket.

scooper


"Lennart" <erik.lennart.jonsson (AT) gmail (DOT) com> wrote in message
news:afb18c08-e7bd-41cc-b7c8-46e87b3b7ba8 (AT) m37g2000yqf (DOT) googlegroups.com...
On 6 mar, 11:04, "scooper" <robert... (AT) internode (DOT) on.net> wrote:
Would anyone know why this doesn't run

delimiter //

CREATE FUNCTION hello (s CHAR(20)) RETURNS CHAR(50)
RETURN CONCAT('Hello, ',s,'!');
//
delimiter ;
SELECT hello('world');

It comes from the MYSQL Help File.

scooper
Works for me, what was the error you got?

mysql> delimiter //
mysql
mysql> CREATE FUNCTION hello (s CHAR(20)) RETURNS CHAR(50)
-> RETURN CONCAT('Hello, ',s,'!');
-> //
Query OK, 0 rows affected (0.00 sec)

mysql> delimiter ;
mysql> SELECT hello('world');
+----------------------------------------------------+
| hello('world') |
+----------------------------------------------------+
| Hello, world ! |
+----------------------------------------------------+
1 row in set (0.01 sec)

mysql> select @@version;
+-----------+
| @@version |
+-----------+
| 5.1.42 |
+-----------+
1 row in set (0.00 sec)

/Lennart


There are no brackets in the code. Only parentheses.

Again - what error message do you get? And what exact version of MySQL
are you running?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
  #6  
Old   
scooper
 
Posts: n/a

Default Re: CREATE FUNCTION not working in MYSQL 5.1 - 03-07-2010 , 11:04 PM



It is Error 1064 (42000)
The version is 4.1.13 (not 5.1).

Thanks for asking,
scooper



"Jerry Stuckle" <jstucklex (AT) attglobal (DOT) net> wrote

Quote:
scooper wrote:
It fails as soon as it hits the first left bracket.

scooper


"Lennart" <erik.lennart.jonsson (AT) gmail (DOT) com> wrote in message
news:afb18c08-e7bd-41cc-b7c8-46e87b3b7ba8 (AT) m37g2000yqf (DOT) googlegroups.com...
On 6 mar, 11:04, "scooper" <robert... (AT) internode (DOT) on.net> wrote:
Would anyone know why this doesn't run

delimiter //

CREATE FUNCTION hello (s CHAR(20)) RETURNS CHAR(50)
RETURN CONCAT('Hello, ',s,'!');
//
delimiter ;
SELECT hello('world');

It comes from the MYSQL Help File.

scooper
Works for me, what was the error you got?

mysql> delimiter //
mysql
mysql> CREATE FUNCTION hello (s CHAR(20)) RETURNS CHAR(50)
-> RETURN CONCAT('Hello, ',s,'!');
-> //
Query OK, 0 rows affected (0.00 sec)

mysql> delimiter ;
mysql> SELECT hello('world');
+----------------------------------------------------+
| hello('world') |
+----------------------------------------------------+
| Hello, world ! |
+----------------------------------------------------+
1 row in set (0.01 sec)

mysql> select @@version;
+-----------+
| @@version |
+-----------+
| 5.1.42 |
+-----------+
1 row in set (0.00 sec)

/Lennart



There are no brackets in the code. Only parentheses.

Again - what error message do you get? And what exact version of MySQL
are you running?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
  #7  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: CREATE FUNCTION not working in MYSQL 5.1 - 03-08-2010 , 09:18 AM



scooper wrote:
Quote:
"Jerry Stuckle" <jstucklex (AT) attglobal (DOT) net> wrote in message
news:hmtjk8$4hj$3 (AT) news (DOT) eternal-september.org...
scooper wrote:
It fails as soon as it hits the first left bracket.

scooper


"Lennart" <erik.lennart.jonsson (AT) gmail (DOT) com> wrote in message
news:afb18c08-e7bd-41cc-b7c8-46e87b3b7ba8 (AT) m37g2000yqf (DOT) googlegroups.com...
On 6 mar, 11:04, "scooper" <robert... (AT) internode (DOT) on.net> wrote:
Would anyone know why this doesn't run

delimiter //

CREATE FUNCTION hello (s CHAR(20)) RETURNS CHAR(50)
RETURN CONCAT('Hello, ',s,'!');
//
delimiter ;
SELECT hello('world');

It comes from the MYSQL Help File.

scooper
Works for me, what was the error you got?

mysql> delimiter //
mysql
mysql> CREATE FUNCTION hello (s CHAR(20)) RETURNS CHAR(50)
-> RETURN CONCAT('Hello, ',s,'!');
-> //
Query OK, 0 rows affected (0.00 sec)

mysql> delimiter ;
mysql> SELECT hello('world');
+----------------------------------------------------+
| hello('world') |
+----------------------------------------------------+
| Hello, world ! |
+----------------------------------------------------+
1 row in set (0.01 sec)

mysql> select @@version;
+-----------+
| @@version |
+-----------+
| 5.1.42 |
+-----------+
1 row in set (0.00 sec)

/Lennart

There are no brackets in the code. Only parentheses.

Again - what error message do you get? And what exact version of MySQL
are you running?

It is Error 1064 (42000)
The version is 4.1.13 (not 5.1).

Thanks for asking,
scooper

(Top posting fixed)

The message number only shows you have a parse error. What's the actual
error message you get?

Your code works fine here (MySQL 5.4.0); are you sure this is the exact
code (i.e. copy/paste)), or is it possible you mistyped it when entering
it? How are you trying to execute your statements (i.e. in a file using
the mysql command, application, etc.)?

P.S. Please don't top post. Thanks.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.