tags:

views:

49

answers:

2

I am trying to declare g_num ,number data type with size it gives an error but in case of varchar2,char it does not.

variable g_name varchar2(5);//correct accept size for varchar 2
variable g_num number(23);//Gives an error

    " VAR[IABLE] [ <variable> [ NUMBER | CHAR | CHAR (n [CHAR|BYTE]) |
              VARCHAR2 (n [CHAR|BYTE]) | NCHAR | NCHAR (n) |
              NVARCHAR2 (n) | CLOB | NCLOB | REFCURSOR ] ]"

Please suggest!

+4  A: 

The answer is already in your error message: NUMBER does not allow a precision in SQL*Plus.

VARIABLE g_num NUMBER;

works.

Here is a list with valid variable declarations in SQL*Plus.

The documentation says:

NUMBER
Creates a variable of type NUMBER with fixed length.


Unfortunately I don't know why you can't specify precision with SQL*Plus, but I have been able to store 1.0E+125 with my tests.

What do you need precision for?

Peter Lang
A: 

peter i agree with your answer but i need an explaination for that ,do u have link for the explaination!

Vineet
Please add comments to answers instead of adding answers to your own question (unless you find the best answer yourself). See my updated answer.
Peter Lang