SQL Generator Issue fix

Source: Internet
Author: User
Tags generator



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?
  1. Select Tc.column_name as column_name,
  2. Tc.data_type as Data_type,
  3. Tc.data_length as Data_length,
  4. Cc.comments as comments
  5. from user_tab_columns TC, user_col_comments cc
  6. where tc.table_name = Cc.table_name
  7. and tc.column_name = Cc.column_name
  8. and Tc.table_name = ' {0} '   
  9. 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?
  1. Select patient_id, --Population master Index   
  2. Health_record_code,--resident health file
  3. HEALTH_CARD_ID,--resident health card
  4. name , --Name   
  5. Sex,--gender code
  6. from Gxwst_patient_baseinfo
  7. 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

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.