can't see compiler errors
true-hb opened this issue · 20 comments
Compile Current File works. But when I got error messages, I can't see them in the problems window. What can I do?
Amendment: Even when I select an invalid statement and use "Run Selected Statement" by right mouse button, the errors are shown in problems window.
But when I select the whole package source using Ctrl+a and subsequently use "Run Selected Statement", the errors are not shown.
Hi, can you please post printscreen or terminal output after compiling?
this is terminal output (partly in german, sorry):
Executing task: C:\Program Files\nodejs\node.exe c:\Users\Truetken-H.vscode\extensions\mp.oradew-vscode-0.3.11\node_modules\gulp\bin\gulp.js --cwd c:\cvs\resusDB --gulpfile c:\Users\Truetken-H.vscode\extensions\mp.oradew-vscode-0.3.11\out\gulpfile.js --color true --silent true compile --env RES_TEST --file c:\cvs\resusDB\packages\RD_POI-body.SQL <
Success => RESUS@RES_TEST $c:\cvs\resusDB\packages\RD_POI-body.SQL
Das Terminal wird von Aufgaben wiederverwendet, drücken Sie zum Schließen eine beliebige Taste.
What kind of error do you expect?
Can you send me a peace of code so I can reproduce?
Thanks a lot.
Take this one:
CREATE OR REPLACE PACKAGE test_oradew AS
FUNCTION incorrect (n NUMBER)
RETURN VARCHAR22;
END test_oradew;
/
The answer is
> Executing task: C:\Program Files\nodejs\node.exe c:\Users\Truetken-H\.vscode\extensions\mp.oradew-vscode-0.3.11\node_modules\gulp\bin\gulp.js --cwd c:\cvs\resusDB --gulpfile c:\Users\Truetken-H\.vscode\extensions\mp.oradew-vscode-0.3.11\out\gulpfile.js --color true --silent true compile --env RES_TEST --file c:\cvs\resusDB\packages\test_oradew.sql <
Success => RESUS@RES_TEST $c:\cvs\resusDB\packages\test_oradew.sql
Das Terminal wird von Aufgaben wiederverwendet, drücken Sie zum Schließen eine beliebige Taste.
When I execute the following statement:
select name,type,line,position,text,attribute,message_number from user_errors
order by 1,2,3
I get this:
NAME TYPE LINE POSITION TEXT ATTRIBUTE MESSAGE_NUMBER
------------ -------- ---- -------- ---------------------------------------- --------- --------------
TEST_ORADEW PACKAGE 2 2 PL/SQL: Declaration ignored ERROR 0
TEST_ORADEW PACKAGE 3 9 PLS-00201: identifier 'VARCHAR22' must ERROR 201
be declared
btw.: I'm working with Windows 10, the database ist Oracle 11g and sqlcl in Version 19.2.0.
May be interesting: When I work directly with sqlcl, I get
java.io.UnsupportedEncodingException: WE8MSWIN1252
for any Select-Statement until I do the following:
set encoding ibm852
I think the problem is that you have to put your package into correct file structure, as Oradew gets from file structure object information to then query from errors:
./src/RESUS/PACKAGES/TEST_ORADEW.sql
would be a correct one in your case.
If you run it outside of SRC structure, you can run it with "Run Current File as Script" (F5) and see errors from SqlPlus, but they are not parsed as Problems...
Yeah, this works. But I'm not satisfied, because we have another directory structure in git.
We use the following structure:
- ./packages/{object-name}-spec.sql für Package-Specifications
- ./packages/{object-name}-body.sql für Package-Bodies
- ./trigger/{object-name}-trigger.sql für Triggers
- ./views/{object-name}-view.sql für Views
Currently we don't have any more objecttypes in git.
We use just one database-schema, so we don't need the schema-name.
We don't use the schema name in our database-scripts, so the syntax always is
CREATE OR REPLACE {object-type} {object-name} AS ...
instead of
CREATE OR REPLACE {object-type} "{schema-name}"."{object-name}" AS ...
Is it possible to define such a structure by configuration?
Hey, thanks for your feedback.
- If you have only one schema in your project, you can ommit schema directory from structure. It will work.
- Unnused directories (objecttypes) can be removed as well.
- Ommiting schema name in object code is also not a problem when compiling.
- Custom structure and object-file name is a problem right now. but something could be done to make it configurable as you suggest...
Any ideas on how to make this object-structure mapping configurable ?
I would put this in the resources\oradewrc-schema.json:
"source.pattern": {
"description": "Naming patterns for the sources of different object types",
"type": "object",
"properties": {
"package-spec": {
"default": "./src/{schema-name}/PACKAGES/{object-name}.sql",
"description": "Naming pattern for package specifications",
"type": "string"
},
"package-body": {
"default": "./src/{schema-name}/PACKAGE_BODIES/{object-name}.sql",
"description": "Naming pattern for package bodies",
"type": "string"
},
"trigger": {
"default": "./src/{schema-name}/TRIGGERS/{object-name}.sql",
"description": "Naming pattern for triggers",
"type": "string"
},
"type-spec": {
"default": "./src/{schema-name}/TYPES/{object-name}.sql",
"description": "Naming pattern for type specifications",
"type": "string"
},
"type-body": {
"default": "./src/{schema-name}/TYPE_BODIES/{object-name}.sql",
"description": "Naming pattern for type bodies",
"type": "string"
},
"view": {
"default": "./src/{schema-name}/VIEWS/{object-name}.sql",
"description": "Naming pattern for views",
"type": "string"
},
"function": {
"default": "./src/{schema-name}/FUNCTIONS/{object-name}.sql",
"description": "Naming pattern for functions",
"type": "string"
},
"procedure": {
"default": "./src/{schema-name}/PROCEDURES/{object-name}.sql",
"description": "Naming pattern for procedures",
"type": "string"
}
}
}
you might add following to ensure that the object-name is part of the pattern:
"pattern" : "([\w_.-](\{schema-name\})?[\w_.-]/)+[\w_.-]\{object-name\}[\w_.-]"
Great suggestion!
Could we use regex to extract "schema-name", "object-type" and "object-name" from file path based on configured pattern?
We have this function that extracts object info from path:
oradew-vscode/src/common/utility.js
Line 41 in 01f5582
that should be modified to use "source.patterns".
Oooh, sorry, I'm no javascript geek.
But I will try ;-)
// something like this may be used to get the object-typ to a filename
let mapObjectTypeToPattern = {
"PACKAGE" : source.pattern.package-spec.pattern,
"PACKAGE BODY" : source.pattern.package-body.pattern,
"TRIGGER" : source.pattern.trigger.pattern,
"TYPE" : source.pattern.type-spec.pattern,
"TYPE BODY" : source.pattern.type-body.pattern,
"VIEW" : source.pattern.view.pattern,
"FUNCTION" : source.pattern.function.pattern,
"PROCEDURE" : source.pattern.procedure.pattern
};
const invertPattern = obj => val => {
for (let key in obj) {
if (obj[key].match(val) )
return key;
}
};
From now it get's really difficult. Maybe you can use something like the split-function for patterns.
I will try to look for something like that later ...
I got an idea. First you switch the pattern ton another pattern:
altPattern = new RegExp ('^(' + replace (source.pattern, '{object-name}', '|') + ')$';)
So, if source.pattern
is "package/{object-name}-spec.sql", altPattern
should be "^(package/|-spec.sql$)"
Now you can do somehing like this:
objectName = fileName.replace (altPattern);
Ok?
Could we just add regex to "source.pattern" and then use this pattern to extract data from filepath.
For example:
We have filepath: "./src/RESUS/PACKAGES/TEST_ORADEW.sql", is it possible to write a regex with groups that would extract "RESUS", "PACKAGES" and "TEST_ORADEW"?
Thanks for your help, @true-hb.
Sorry, I'm not sure if not know what you mean.
If you have
filepath="./src/RESUS/PACKAGES/TEST_ORADEW.sql";
with
var regex=new RegExp('\w+');
var match=regex.exec (filepath);
you should get an array with ["src","RESUS","PACKAGES","TEST_ORADEW","sql"]
Is that what you need?
Sorry again, my javascript is not so good ;-)
I got an idea. First you switch the pattern ton another pattern:
altPattern = new RegExp ('^(' + replace (source.pattern, '{object-name}', '|') + ')$';)
So, ifsource.pattern
is "package/{object-name}-spec.sql",altPattern
should be "^(package/|-spec.sql$)"
Now you can do somehing like this:
objectName = fileName.replace (altPattern);
Ok?
This does not work with a path lile "./src/{schema-name}/PACKAGES/{object-name}.sql".
The path has to be "src/{schema-name}/PACKAGES/{object-name}.sql" (without ./ at the beginning).
What about using globs to match object-type from path?
Convert all patterns to:
"./src/*/FUNCTIONS/*.sql"
"./src/*/PROCEDURES/*.sql"
....
etc. and then try to match those with actual file path:
"./src/RESUS/FUNCTIONS/my-object.sql" for example.
When a match is found we get the object-type.
Then extract object-name etc as you suggest....
this looks like a good idea to me!
@true-hb , I released 0.3.12 with "source.pattern" configuration.