Validates SQLScript code for syntax, patterns, and best practices with auto-fix capability
Validates SQLScript code for syntax, patterns, and best practices with auto-fix capability
/plugin marketplace add secondsky/sap-skills/plugin install sap-sqlscript@sap-skillsValidate SQLScript code for syntax errors, pattern violations, and best practices. Reports issues and offers to auto-fix common problems.
/sqlscript-validate [file_path]
/sqlscript-validate [file_path] --fix
/sqlscript-validate --all
The following issues can be auto-fixed:
| Issue | Auto-Fix Action |
|---|---|
| Missing EXIT HANDLER | Add generic exception handler |
| Unclosed cursor | Add CLOSE statement in finally block |
| Missing semicolon | Add semicolon at statement end |
| SELECT * in procedure | Cannot auto-fix (requires column selection) |
| Hardcoded schema | Replace with parameter or DEFAULT SCHEMA |
| Missing LANGUAGE SQLSCRIPT | Add the clause |
## SQLScript Validation Report
**File**: [filename]
**Lines**: [count]
**Status**: [PASS/FAIL]
### Critical Issues (X found)
1. [Line X]: [Issue description]
**Current**: `[code snippet]`
**Fix**: `[corrected code]`
**Auto-fix available**: Yes/No
### Warnings (X found)
[Similar format]
### Suggestions (X found)
[Similar format]
### Summary
- Critical: X
- Warnings: X
- Suggestions: X
### Auto-Fix Available
Would you like me to automatically fix the X issues that have auto-fix available?
/sqlscript-validate src/procedures/get_orders.sql
/sqlscript-validate src/procedures/get_orders.sql --fix
/sqlscript-validate --all
When this command is invoked:
--all is specified, find all .sql files and .abap files containing AMDP--fix is specified or user confirms, apply auto-fixes-- BAD: No error handling
CREATE PROCEDURE test()
AS
BEGIN
INSERT INTO table VALUES (1);
END;
-- GOOD: Has error handling
CREATE PROCEDURE test()
AS
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION
SELECT ::SQL_ERROR_CODE, ::SQL_ERROR_MESSAGE FROM DUMMY;
INSERT INTO table VALUES (1);
END;
-- BAD: Cursor not closed
OPEN cur;
FETCH cur INTO var;
-- Missing: CLOSE cur;
-- GOOD: Cursor properly closed
OPEN cur;
FETCH cur INTO var;
CLOSE cur;
-- BAD: Hardcoded schema
SELECT * FROM "MYSCHEMA"."MYTABLE";
-- GOOD: Use DEFAULT SCHEMA or parameter
SELECT * FROM "MYTABLE"; -- With DEFAULT SCHEMA clause