MySQL Forums
Forum List  »  Stored Procedures

Re: CREATE PROCEDURE with variables?
Posted by: Peter Brawley
Date: November 24, 2014 12:49PM

Lose SELECT ...

> INSERT INTO Blogs
> VALUES( Title, Body, Top, Bottom, CURDATE(), CURTIME() )

If Title, Body, Top, Bottom are column names, MySQL will have no way of distinguishing those params from column names, so your Insert will insert Nulls. Best to adopt a param convention like prefixing each name with a param-indicator eg ptitle, pbody &c.

And against possible table changes, it's always best to specify the column names.

And proper-casing & Hungarian casing of database object identifiers can cause mischief in MySQL, best avoid them.

So ...

insert into blogs (title,body,top,bottom,datecol,timecol)
values( ptitle,pbody,ptop,pbottom,Curdate(),Curtime() );

BTW is there some reason you are keeping data & time in separate columns? It appears these cols track current events. Why not use Timestamp?

Options: ReplyQuote


Subject
Views
Written By
Posted
2841
November 24, 2014 11:42AM
Re: CREATE PROCEDURE with variables?
1323
November 24, 2014 12:49PM
1183
November 24, 2014 01:07PM
1174
November 24, 2014 03:22PM
1119
November 24, 2014 04:53PM
917
November 24, 2014 09:50PM


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.