MySQL Forums
Forum List  »  UDF

Newbie to UDF - Asking for guidance
Posted by: Jim Palmer
Date: May 09, 2014 07:07AM

I have a table named "parent_table"

Its structure is:

CREATE TABLE `parent_table` (
`parent_key` int(11) NOT NULL AUTO_INCREMENT,
`parent_description` varchar(200) DEFAULT NULL,
PRIMARY KEY (`parent_key`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;

I have a table named "note"

Its structure is:

CREATE TABLE `note` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`parent_key` int(11) DEFAULT NULL,
`note` varchar(20) DEFAULT NULL,
`ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`reporter` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

I would like to create a UDF which I would use to produce something like the following:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
The parent description

The notes for this parent item are:

REPORTERAA 2014-05-09 06:33 AM -
THIS IS THE FIRST NOTE

REPORTERBB 2014-05-09 06:33 AM -
THIS IS THE NOTE ADDED BY ANOTHER USER

REPORTERCC 2014-05-09 06:33 AM -
THIS IS THE LAST NOTE ADDED TO A THIS PARENT
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

with a query that looks something like the following:

select parent_description, udfCombineNotes(parent_key) from parent_table;

Is this possible in MySQL?

Regards,

Jim P

Options: ReplyQuote


Subject
Views
Written By
Posted
Newbie to UDF - Asking for guidance
2158
May 09, 2014 07:07AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.