Next http://blog.csdn.net/panliuwen/article/details/47406455 SQL generator-Generate annotated SQL statements
Today I use my own SQL generator, I feel good, I can write the field comments on the SQL. But there are still some problems:
1, the field is not sorted; 2, the UPDATE statement is more than one set;3, the first row of the SELECT statement field does not add "," delimited, syntax error, 4, to handle the select has a full selection of errors
For the above questions, I deal with the following:
1. field is not sorted
Add an ORDER BY statement, order by COLUMN_ID, and the complete SQL statement looks like this:
[SQL]View Plaincopyprint?
- Select Tc.column_name as column_name,
- Tc.data_type as Data_type,
- Tc.data_length as Data_length,
- Cc.comments as comments
- from user_tab_columns TC, user_col_comments cc
- where tc.table_name = Cc.table_name
- and tc.column_name = Cc.column_name
- and Tc.table_name = ' {0} '
- Order by tc.column_id
Select Tc.column_name as column_name, Tc.data_type as Data_type, tc.data_length as Data_length, Cc.comments as comments from User_tab_columns TC, user_col_comments cc where tc.table_name = Cc.table_name and tc.column_name = Cc.column_name and tc.table_name = ' {0} ' ORDER by tc.column_id
2, the UPDATE statement more than one set
Delete the extra set directly
3, the first row of the SELECT statement field is not added "," delimited, syntax error occurred
The first line adds ","
After the fix, write the SQL basically no problem, I paste a generated SQL, as follows:
[SQL]View Plaincopyprint?
- Select patient_id, --Population master Index
- Health_record_code,--resident health file
- HEALTH_CARD_ID,--resident health card
- name , --Name
- Sex,--gender code
- from Gxwst_patient_baseinfo
- where patient_id = ' 1234567 '
Select patient_id,--Population Master Index health_record_code,--resident Health Profile health_card_id,--resident Health Card name,--name sex,-- Gender code from gxwst_patient_baseinfo where patient_id = ' 1234567 '
4, processing does not have a full selection of fields, the last field contains "," the problem
Increase counter judgment
5, paste the revised resources
http://download.csdn.net/detail/panliuwen/8993531
To summarize this program, there are many imperfections, such as the ability to identify data types date, VARCHAR2 and number, there is no way to implement the associated query.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
SQL Generator Issue fix