mysql declare syntax help

Hi can someone help me get this syntax correct.

I am wanting to declare the field 'nett' ready for a stored procedure.
Nett could be a bigger number as 9999999.

This does not work. Could someone give me an example of this working.
and what data_type to use for storeing values like nett, cost, gross, (big numbers)
A what i have doesnt seem to work.

DECLARE nett BIGINT(10000000) default 0 ;

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Om PrakashCommented:
DECLARE total_count bigint(20);
SET total_count = 10000000;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kingjelyAuthor Commented:
Hi om  !
Is total_count the name of the field?


are you setting total_count to = 10000000? as in, this is the number with-in total_count?

what i want,Is to

Declare a field called 'nett' that holds a 'big number'
and in my code say

'nett' = (cashsales + chargesales +newlaybys - discount)

I'm reading from here,
kingjelyAuthor Commented:

DECLARE total_count BIGINT(20);

I have just put this in the browser and it tells me
!You have an error in your syntax, near ' DECLARE total_count BIGINT(20)

Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

kingjelyAuthor Commented:

also, i have put thi in

and i get
!You have an error in your syntax, near '@nett'

Is something weird is going on, or am I doing something seriously dumb again.
Om PrakashCommented:
Yes total_count  is the variable declared
above will work if this is a part of stored procedure.

Do you need a stored procedure which will return the  nett value by
doing this from SQL table?
SELECT  (cashsales + chargesales +newlaybys - discount) from Table

Variables in sql prompt example:
Ok kingjely: Let me explain you this

DECLARE nett BIGINT(10000000) default 0 ; Doesn't mean it can contain a number as large as 10000000

You have to declare your variables as BIGINT();
BIGINT's Range is -9223372036854775808<x<9223372036854775807

The number in () BIGINT(X) this X is not for the maximum value It is optional display width that may be used by applications to display integer values having a width less than the width specified for the column by left-padding them with spaces and when used in conjunction with ZEROFILL, the default padding of spaces is replaced with zeros. For example, for a column declared as INT(5) ZEROFILL, a value of 4 is retrieved as 00004
DECLARE nett BIGINT() default 0 ;
kingjelyAuthor Commented:
Hi i have been looking here

I'm just trying to get example and try them so i can learn.

I hadn't got to Example 3 yet, but  

Obviously now i see you have to put the Declare after BEGIN

which i didnt even know.

DECLARE nett BIGINT() default 0 ;  <===

I dont think I'm this smart yet, so I'll just keep looking for examples and trying them.

Thanks guys, Im sure there are plenty more questions to come =D
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.