473,387 Members | 1,502 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

MySQL function error

dear all,

I have a table called "distributor" having "distributor_id" as a PK
and taking an integer data type as well as "distributor_parent_id"
which also takes an integer data type but can accept null values;

I tried to make this simple function that returns the parent_id by
taking a parameter representing the distributor id; still it fails, I
assume due to the delimiters.

I appreciate any assistance to this regard.

DELIMITER $$

CREATE FUNCTION last_inserted_parent_id ( inserted_id INT )
RETURNS INT
BEGIN
DECLARE parent_id INT$$
SET parent_id = (
SELECT distributor_parent_id
FROM distributor
WHERE distributor_id = inserted_id
)
RETURN parent_id$$
END$$

DELIMITER ;

Nov 8 '07 #1
2 1516
On 8 Nov, 07:47, coosa <coos...@gmail.comwrote:
I have a table called "distributor" having "distributor_id" as a PK
and taking an integer data type as well as "distributor_parent_id"
which also takes an integer data type but can accept null values;

I tried to make this simple function that returns the parent_id by
taking a parameter representing the distributor id; still it fails, I
assume due to the delimiters.

I appreciate any assistance to this regard.

DELIMITER $$
Hi Coosa,

Welcome to comp.lang.php where all things PHP get discussed. But we
tend not to talk about things which are nothing to do with PHP.

Try this list for more suitable places to post your query:

http://www.newzbot.com/search.php?t=...ql&gtag=usenet

C.

Nov 8 '07 #2
coosa wrote:
dear all,

I have a table called "distributor" having "distributor_id" as a PK
and taking an integer data type as well as "distributor_parent_id"
which also takes an integer data type but can accept null values;

I tried to make this simple function that returns the parent_id by
taking a parameter representing the distributor id; still it fails, I
assume due to the delimiters.

I appreciate any assistance to this regard.

DELIMITER $$

CREATE FUNCTION last_inserted_parent_id ( inserted_id INT )
RETURNS INT
BEGIN
DECLARE parent_id INT$$
SET parent_id = (
SELECT distributor_parent_id
FROM distributor
WHERE distributor_id = inserted_id
)
RETURN parent_id$$
END$$

DELIMITER ;

comp.databases.mysql is thataway ==>.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Nov 8 '07 #3

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

Similar topics

6
by: das dsf | last post by:
Hi there! I have both PHP 4.0( RPM) installed and MySQL 4.0.20 installed with the mysqld daemon up and running. But when I look at the output of phpinfo() , I do not see it there, which is...
6
by: aa | last post by:
I use the following fragment of code to output datf from MySQL: ====================================================== $chan = mysql_connect ($db_host, $username, $password); mysql_select_db...
0
by: tevans | last post by:
I'm using Slackware GNU/Linux 9.0 on an Intel PII 266 machine that's SMP capable, but only with one CPU installed, and 64MB of RAM. It's basically a small test system that I play around with in...
0
by: Annie Xie | last post by:
1> anyone has a compiled tarball for mysql new version (-4.0 up) for solaris 2.6 can be shared? The OS was patched latest. 2> I'm trying build it, configure w/o any problem. However, when dong...
0
by: Vladimir Espinosa Angarica | last post by:
Hi Team: I've found a bug in the example presented in the Official MySQL Manual in the section 9.1.15.6 A Simple Embedded Server Example. I tried to compile the program following the...
0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
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. ...
14
by: mistral | last post by:
Need php script to create mySQL database programmatically; since hosting configuration may not allow create database from script, script also need eliminate/rewrite all restrictions in appropriate...
4
by: yogesh | last post by:
mysql in c++ initialize error occurs a simple program is executed in redhat9.0 , using gcc 3.2.2 compiler version ... #include <stdio.h> #include <mysql.h> #include <string.h> int main() {
11
by: kennthompson | last post by:
Trouble passing mysql table name in php. If I use an existing table name already defined everything works fine as the following script illustrates. <?php function fms_get_info() { $result =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.