Use this page to discuss script 492 SQL utilities: format, generate column lists, procedures for databases
- Add constructive comments, bug reports, or discuss improvements (see the guideline).
- Do not document the script here (the author should do that on vim.org).
- This page may be out of date: check the script's vim.org page above, and its release notes.
Bugs[]
The Formatter does not recognize comment lines and attempts to process them as actual SQL statements
For example, comments of the form
--###########################################################################################
To be fair, this happens on one large blob where the data looks like this:
--########################################################################################### --# PRICE TYPE ID = 0, LABELS=NONE, COLORWAY = FALSE , PRODUCT_TYPE = STANDARD --# FIRST UPC
= 0, LABELS = NONE, COLORWAY = FALSE, PRODUCT_TYPE = STANDARD --# FIRST UPC
update UPC set PROD_ID = 222222222 where PROD_ID = 3003657; insert into UPC(UPC_ID, UPC, PROD_ID, DISPLAY_STAT_CODE, ADD_BY_APP
and gets formatted like this:
--########################################################################################### --# PRICE TYPE ID = 0, LABELS = NONE, COLORWAY = FALSE, PRODUCT_TYPE = STANDARD --#
FIRST UPC
update UPC
set PROD_ID
= 222222222
where PROD_ID
= 3003657;
insert into UPC(UPC_ID, UPC, PROD_ID, DISPLAY_STAT_CODE, ADD_BY_APP, LAST_MODIFIED, CREATED, BASE_FEE_EXEMPT, BACKORDERABLE, NRF_COLOR, NRF_COLOR_DESC, UPC_EFF_DATE, UPC_EXP_DATE, COLORWAY_ID, PID, CONTEXT_ID, V2CFLAG)
OR like this
values (98000000, 'SWATCH', '3958834.fpx', 'Y', '2016-03-16 22:32:49', '2016-03-16 22:32:49', 2565547); --# PRICE TYPE ID = 0, LABELS = NONE, COLORWAY = FALSE, PRODUCT_TYPE = MEMBER --# FIRST UPC
all on one line.
AND the SQL commands are all indented to the far right of the viewport.
Would be nice to be able to specify a comment line as beginning with `--#` to alleviate this issue.
Suggested mappings[]
The suggested mappings don't need the underscore characters. Should be:
vmap <silent>sf <Plug>SQLUFormatter<CR> nmap <silent>scl <Plug>SQLUCreateColumnList<CR> nmap <silent>scd <Plug>SQLUGetColumnDef<CR> nmap <silent>scdt <Plug>SQLUGetColumnDataType<CR> nmap <silent>scp <Plug>SQLUCreateProcedure<CR>
--February 12, 2014