Jump to content



Photo

[MySQL] Stored procedure won't INSERT?


  • Please log in to reply
3 replies to this topic

#1 +Nik L

Nik L

    Where's my pants?

  • Tech Issues Solved: 2
  • Joined: 14-January 03

Posted 07 July 2014 - 19:18

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?




#2 OP +Nik L

Nik L

    Where's my pants?

  • Tech Issues Solved: 2
  • Joined: 14-January 03

Posted 07 July 2014 - 19:24

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!



#3 sathenzar

sathenzar

    Neowinian

  • Joined: 12-June 06

Posted 15 July 2014 - 14:45

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 :)

#4 OP +Nik L

Nik L

    Where's my pants?

  • Tech Issues Solved: 2
  • Joined: 14-January 03

Posted 15 July 2014 - 14:53

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 :)





Click here to login or here to register to remove this ad, it's free!