SQL/MySQL/Procedure Function/NUMERIC — различия между версиями

Материал из SQL эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 10:17, 26 мая 2010

NUMERIC(8,2) DEFAULT 9.95

 
mysql>
mysql> delimiter $$
mysql>
mysql> CREATE PROCEDURE myProc()
    -> BEGIN
    ->      DECLARE l_numeric   NUMERIC(8,2) DEFAULT 9.95;
    ->
    ->     select l_numeric;
    -> END$$
Query OK, 0 rows affected (0.00 sec)
mysql> delimiter ;
mysql>
mysql> call myProc();
+-----------+
| l_numeric |
+-----------+
|      9.95 |
+-----------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> drop procedure myProc;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql>



Variable type NUMERIC(8,2)

 
mysql>
mysql> delimiter $$
mysql> CREATE PROCEDURE myProc()
    -> BEGIN
    ->     DECLARE my_currency    NUMERIC(8,2);  /* Number with 2 decimals*/
    ->
    ->     set my_currency = 123123.123;
    ->
    ->     select "my_currency="+my_currency;
    -> END$$
Query OK, 0 rows affected (0.00 sec)
mysql> delimiter ;
mysql>
mysql> call myProc();
+----------------------------+
| "my_currency="+my_currency |
+----------------------------+
|                  123123.12 |
+----------------------------+
1 row in set (0.00 sec)
Query OK, 0 rows affected, 2 warnings (0.00 sec)
mysql>
mysql> drop procedure myProc;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql>