/* DROP TABLE IF EXISTS `tab17557`; DROP VIEW IF EXISTS `view17557`; CREATE TABLE `tab17557` (dd decimal (3,1)) ; CREATE VIEW `view17557` as SELECT dd FROM `tab17557`; INSERT INTO `tab17557` VALUES (7.6); */ #include #include #include int main() { MYSQL *conn; MYSQL_RES *res; MYSQL_FIELD *field; conn = mysql_init(NULL); mysql_real_connect(conn, "localhost", "root", "", "test5", 0, NULL, 0); if (mysql_errno(conn) != 0) { printf("Error: %s\n", mysql_error(conn)); return 1; } /* Checking the table */ res= mysql_list_fields(conn, "tab17557", NULL); while(field = mysql_fetch_field(res)) { printf("field name %s\n", field->name); printf("field table %s\n", field->table); printf("field decimals %d\n", field->decimals); if(field->decimals < 1) printf("Error! No decimals! \n"); printf("\n\n"); } mysql_free_result(res); /* Checking the view */ res= mysql_list_fields(conn, "view17557", NULL); while(field = mysql_fetch_field(res)) { printf("field name %s\n", field->name); printf("field table %s\n", field->table); printf("field decimals %d\n", field->decimals); if(field->decimals < 1) printf("Error! No decimals! \n"); printf("\n\n"); } mysql_free_result(res); return 0; }