INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

routine issue

routine issue

(OP)
Hi i have the routine below. when called from vb.net i get CustomerID cannot be null. issue with iNewCId.

if a replace iNewCId with a number it works.

Please help

Thanks


-- --------------------------------------------------------------------------------
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
-- --------------------------------------------------------------------------------
DELIMITER $$

CREATE DEFINER=`root`@`localhost` PROCEDURE `rModifyCustomer`(
IN CId INT,
IN CRef VARCHAR(45),
IN CName VARCHAR(45),
IN GendId INT,
IN TitId INT,
IN FName VARCHAR(30),
IN SName VARCHAR(30),
IN Init CHAR(2),
IN DateOB DATE
)
BEGIN
DECLARE iNewCId INT;

SELECT iNewCId = MAX(CustomerId) + 1 FROM
tblCustomer;

IF CId = -1 THEN
INSERT INTO tblCustomer
(
CustomerId,
CustomerRef,
CustomerName,
GenderId,
TitleId,
FirstName,
Surname,
Initial,
DOB
)
VALUES
(
iNewCId,
CRef,
CName,
GendId,
TitId,
FName,
SName,
Init,
DateOB
);
ELSE
UPDATE
tblCustomer
SET
CustomerRef = CRef,
CustomerName = CName,
GenderId = GendId,
TitleId = TitId,
FirstName = FName,
Surname= SName,
Initial = Init,
DOB = DateOB
WHERE CustomerId = CId;
END IF;
END

RE: routine issue

use @iNewCId instead of iNewCId

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon

RE: routine issue

(OP)
hi MYsql says syntax not allowed.

this is Mysql
not SQL server
Thanks

RE: routine issue

Quote:

this is Mysql
not SQL server
Thanks
dude, you're welcome, but i knew that

:D

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon

RE: routine issue

(OP)
why reply then?!

RE: routine issue

(OP)
i posted an issue i have with MYSQL not sql server this is the MYSQL board!

RE: routine issue

I am pretty sure you will find Rudy is right.

I have looked at other My SQL tutorials and can not see variables declared with i preceding the name they all have @

@veriableName is the general convention for variables in SQL, I work with both SQL Server and Oracle and always use @. It seems unlikely that My SQL would be different.

Try changing iNewCId to @NewCId

Ian

RE: routine issue

(OP)
@ does not work in MYSQL

it gets underlined and says syntax error!

RE: routine issue

Quote:

i posted an issue i have with MYSQL not sql server this is the MYSQL board!
why keep bringing this up? i never mentioned sql server

try using SET instead of DECLARE

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon

RE: routine issue

Try Changing

SELECT iNewCId = MAX(CustomerId) + 1 FROM
tblCustomer;

to

set iNewCId = SELECT MAX(CustomerId) + 1 FROM
tblCustomer;

Ian

RE: routine issue

When using @ variables they are set using
@variable:=value

Note the colon, everything should work ;)

mysql> select @this:=curdate();
+------------------+
| @this:=curdate() |
+------------------+
| 2013-02-15 |
+------------------+
1 row in set (0.00 sec)

mysql> select @this;
+------------+
| @this |
+------------+
| 2013-02-15 |
+------------+
1 row in set (0.00 sec)

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.

RE: routine issue

(OP)
got it working now

Thanks

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close