SQL/MySQL/Procedure Function/TEXT

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

TEXT type variable

   <source lang="sql">

mysql> mysql> delimiter $$ mysql> mysql> CREATE PROCEDURE myProc()

   -> BEGIN
   ->     DECLARE my_text        TEXT;          /* huge  text */
   ->
   ->     set my_text = "www.sqle.ru";
   ->
   ->     select my_text;
   -> END$$

Query OK, 0 rows affected (0.00 sec) mysql> delimiter ; mysql> mysql> call myProc(); +----------------+ | my_text | +----------------+ | www.sqle.ru | +----------------+ 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>

       </source>
   
  


TEXT variable with DEFAULT value

   <source lang="sql">

mysql> mysql> delimiter $$ mysql> mysql> CREATE PROCEDURE myProc()

   -> BEGIN
   ->     DECLARE l_text TEXT DEFAULT "This is a really long string.  In stored programs we can use text columns fairly freely, but in tables there are some limitations regarding indexing and use in various expressions.";
   ->     select l_text;
   -> END$$

Query OK, 0 rows affected (0.00 sec) mysql> delimiter ; mysql> mysql> call myProc(); +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | l_text | +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | This is a really long string. In stored programs we can use text columns fairly freely, but in tables there are some limitations regarding indexing and use in various expressions. | +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 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>

       </source>