472,326 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,326 software developers and data experts.

mysql/Sql Help

Hi ,

Im new to MySql and i have no idea how to convert a sql server user
defined function to MySql. Can any one help me..

CREATE FUNCTION ChildCategories (@categoryId int, @taxId int,
@dummyTaxId int)
RETURNS @retTable TABLE (path varchar(2048),
parent_id int,
category_id int,
taxonomy_id int,
checkout_user_id int)
AS
BEGIN
DECLARE ChildCatIds CURSOR
FOR
Select DISTINCT category_id
FROM E_KEW_Category
WHERE parent_id = @categoryId AND taxonomy_id = @taxId
OPEN childCatIds

DECLARE @childCatId int
FETCH NEXT FROM childCatIds INTO @childCatId
WHILE(@@FETCH_STATUS = 0)
BEGIN
IF(@childCatId IS NOT NULL)

INSERT INTO @retTable(path, parent_id, category_id, taxonomy_id,
checkout_user_id)
SELECT path, parent_id, category_id, taxonomy_id, checkout_user_id
FROM E_KEW_Category
WHERE category_id = @childCatId AND taxonomy_id = @taxId
UNION
SELECT path,parent_id,category_id, taxonomy_id, checkout_user_id
from ChildCategories( @childCatId, @taxId, @dummyTaxId)
FETCH NEXT FROM childCatIds INTO @childCatId

END
CLOSE childCatIds
DEALLOCATE childCatIds
RETURN
END

Thanks in advance
slash
Jul 20 '05 #1
3 1822
slash wrote:
Im new to MySql and i have no idea how to convert a sql server user
defined function to MySql. Can any one help me..


Someone just asked a question on this same topic on another newsgroup
this week. Here's what I wrote in reply:

"Stored procedures and functions are a new feature in MySQL version 5.0."
http://dev.mysql.com/doc/mysql/en/St...rocedures.html

Are you using MySQL version 5.0? Keep in mind that MySQL 5.0 is only
available in alpha release at this time.

Also, the function language you are using seems to be proprietary to MS
SQL Server. MySQL says:
"MySQL follows the SQL:2003 syntax for stored procedures, which is also
used by IBM's DB2."

Other RDBMS vendors (e.g. Microsoft, Oracle, Sybase, etc.) that
implemented a stored procedure & function language prior to the
publication of the SQL:2003 standard, had to invent their own syntax,
and their syntax usually differs from the standard in either large or
small ways.

If you want to port your stored procedures and functions to MySQL 5.0,
you'll have to learn the MySQL syntax, and rewrite your functions on a
case-by-case basis. You might find cases where Microsoft has
implemented some feature that is simply not implemented in MySQL's
stored procedure language.

Bill K.
Jul 20 '05 #2
Thanks for the info bill.
but am using version MY SQL 4.0.15 and i have no idea how to convert
all those stored procs and functions of MS SQL to MY SQL 4.0.15 (am
afraid stored procs and functions are not avialable in this version)..
Give me a clue

Slash
Bill Karwin <bi**@karwin.com> wrote in message news:<cj*********@enews3.newsguy.com>...
slash wrote:
Im new to MySql and i have no idea how to convert a sql server user
defined function to MySql. Can any one help me..


Someone just asked a question on this same topic on another newsgroup
this week. Here's what I wrote in reply:

"Stored procedures and functions are a new feature in MySQL version 5.0."
http://dev.mysql.com/doc/mysql/en/St...rocedures.html

Are you using MySQL version 5.0? Keep in mind that MySQL 5.0 is only
available in alpha release at this time.

Also, the function language you are using seems to be proprietary to MS
SQL Server. MySQL says:
"MySQL follows the SQL:2003 syntax for stored procedures, which is also
used by IBM's DB2."

Other RDBMS vendors (e.g. Microsoft, Oracle, Sybase, etc.) that
implemented a stored procedure & function language prior to the
publication of the SQL:2003 standard, had to invent their own syntax,
and their syntax usually differs from the standard in either large or
small ways.

If you want to port your stored procedures and functions to MySQL 5.0,
you'll have to learn the MySQL syntax, and rewrite your functions on a
case-by-case basis. You might find cases where Microsoft has
implemented some feature that is simply not implemented in MySQL's
stored procedure language.

Bill K.

Jul 20 '05 #3
slash wrote:
Thanks for the info bill.
but am using version MY SQL 4.0.15 and i have no idea how to convert
all those stored procs and functions of MS SQL to MY SQL 4.0.15 (am
afraid stored procs and functions are not avialable in this version)..
Give me a clue


Right. Stored procs and functions are not available in MySQL version
4.0. You cannot convert your procedures, because MySQL 4.0 does not
have that feature at all.

You have four options:

- Stay with Microsoft SQL Server. I don't recommended this; MS SQL
Server is reported to have data corruption bugs and security
vulnerabilities.

- Upgrade your MySQL software to 5.0, and convert the stored procedures.
You'll have to take your chances with the volatility of alpha
software. Also not recommended.

- Convert your database to another RDBMS that supports stored
procedures. For instance, PostgreSQL 7 has a stored procedure language,
and it is also a free, open-source RDBMS. There are also numerous
commercial RDBMS products with full-featured stored procedure languages.
My apologies to other readers for advocating another RDBMS on a MySQL
newsgroup!

- Write application code to do similar work as the stored procedures in
your old database.

Regards,
Bill K.
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ryan Schefke | last post by:
------=_NextPart_000_0077_01C34C8B.2B90C960 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit ..I just sent this out...
0
by: Girish Agarwal | last post by:
--0-474210375-1058976151=:31789 Content-Type: text/plain; charset=us-ascii Content-Id: Content-Disposition: inline Note: forwarded message...
0
by: Yun Guan | last post by:
Hello mysql gurus, I am trying to run perl on mysql database on Red Hat box. I want to install DBI and DBD:mysql using CPAN: perl -MCPAN -e...
0
by: Mark Adams | last post by:
I am a relative newbie to MySQL. I had a Postfix+Courier+MySQL mail server running for several months. It took me a week or so to get it up and...
3
by: Kirk Soodhalter | last post by:
Hi, This started as a phpmyadmin problem, but has somehow morphed into a mysql problem. I don't know how to fix it. I am posting the...
2
by: Saqib Ali | last post by:
I installed mySQL and have it running.... but I think I made a mistake somewhere along the line...... I believe I did follow the instructions that...
1
by: Alex Hunsley | last post by:
I am trying to install the DBD::mysql perl module. However, it claims I need mysql.h: cpan> install DBD::mysql CPAN: Storable loaded ok Going...
5
by: MLH | last post by:
I'm supposed to set a password for the MySQL root user. The output of mysql_install_db instructed me to run the following commands......
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly...
1
by: PowerLifter1450 | last post by:
I've been having a very rough time installinig mySQL on Linux. I have been following the instructions form here:...
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.