First of all, thank you QQ group Big: The original self-dozen code:
Percent Column_type: binary MySQL data type% input values are:<< "int" >>,<< "decimal (10,2)" >>,<< "varchar" ( XX) ">>,<<" float ">>% return value corresponding to int, decimal, varchar, float%%get_column_type (column_type)->case re : Run (column_type, "int", [caseless]) of{match,_}->integer;_->case Re:run (Type, "decimal", [caseless]) Of{match, _}->decimal;_->case Re:run (type, "varchar", [caseless]) Of{match,_}->varchar;_->case Re:run (type, "float ", [caseless]) of{match,_}->float;_->binaryendendendend.
Long and ugly also a layer of nesting, looking at the headache ....
Programme I: Programme II:
-define (column_types,[{"int", integer},{"varchar", varchar}]). Get_column_type (ColumnType), get_column_ Type (ColumnType,? column_types). Get_column_type (columntype,[column_keyvalue| Column_types])->{matchkey,type} = column_keyvalue, Case Re:run (ColumnType, matchkey,[caseless]) of {match,_}- > type;_-> get_column_type (columntype,column_types) end;get_column_type (_columntype,_)->unknown.
Returns its corresponding shorthand type based on the type of table structure of the database