Returns its corresponding shorthand type based on the type of table structure of the database

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.