473,473 Members | 1,954 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1898
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 to the win32 distribution list but no one has...
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 attached. __________________________________
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 shell cpan>install DBI The above succeeded, but...
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 running in September. Now, I did a clean upgrade to...
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 conversation from a php newsgroup since it started there. ...
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 were provided with the distribution at:...
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 to read /home/alex/.cpan/Metadata Database was...
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... /usr/bin/mysqladmin -u root -h appserver password mynwewpasswd...
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 find myself in urgent need of instruction on how to...
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: http://www.hostlibrary.com/installing_apache_mysql_php_on_linux Everytime I get to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.