1

in MYSQL i have a myfield column in mytable table which has let's say a varchar(8) data type

CREATE TABLE mytable  ( 
    id      INT  NOT NULL,
    myfield VARCHAR( 8 ))

in a function or procedure i'd like to refer to myfield datatype, something like that:

DECLARE myvar mytable.myfield%TYPE

in alternative to explicitly declare it

DECLARE myvar VARCHAR( 8 )

Is there a way in a MYSQL function or procedure, to refer to a column datatype when declaring variable o return type? thanks

4

1 回答 1

2

在 MySQL 中没有办法做到这一点。DECLARE 必须静态声明变量的类型和大小。

于 2013-04-25T09:42:02.447 回答