简体   繁体   中英

mysql function, how to refer to table field datatype

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

There is no way to do that in MySQL. DECLARE must statically declare a variable's type and size.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM