Sign in to follow this  

[MySQL] Stored procedure won't INSERT?

Recommended Posts

Nefarious Trigger    6,988

I am writing some CRUD procedures, and getting nowhere.  I used to develop in MySQL all the time, but moved to MS Sql and now I have forgotten more than I recall...

 

My table Colours has columns:

id - int autonumbering

label - varchar(50)

description - varchar(200)

reference - varchar(6)

 

All I'm trying to do is to put my INSERT procedure together - this should be childs play?

CREATE DEFINER=`niklouch`@`localhost` PROCEDURE `Colour_INSERT`(IN `@label` VARCHAR(50), IN `@description` VARCHAR(200), IN `@reference` VARCHAR(6))
    MODIFIES SQL DATA
INSERT INTO `Colour` (`id`, `label`, `description`, `reference`) VALUES (NULL, @label, @description, @reference)

When run, it certainly inserts a new row, with a new auto-numbered ID, but label, description and reference are all NULL

CALL Colour_INSERT('Red','Deep red akin to burgundy','FF0000')

Just inserts a blank row...

 

WTF?

Share this post


Link to post
Share on other sites
Nefarious Trigger    6,988

Ah now here's a thing - without the  @ before the parameter it works.  No idea where I got that habbit from (certainly not something I would dream up) but hey!

Share this post


Link to post
Share on other sites
sathenzar    23

Yeah well in C# if you use the mysql.net connector you specify parameters with the @ symbol. That's probably where you picked up the habit :)

  • Like 1

Share this post


Link to post
Share on other sites
Nefarious Trigger    6,988

Yeah well in C# if you use the mysql.net connector you specify parameters with the @ symbol. That's probably where you picked up the habit

 

That'll be it - swapping from language to language :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.