Comments (3)
@Danieleeee , Oradew uses DBMS_METADATA.get_ddl
function to import objects by default. This functionality can be customized with setting "import.getDdlFunction"
in oradewrc.json
in a way that you write your own function on DB that will be used by Oradew to import objects. This function should have 3 parameters - first 3 paramaters of DBMS_METADATA.get_ddl
(example bellow).
To add a terminator at the end of each imported object you could make a function on your DB as follows, for example:
FUNCTION my_get_ddl (
object_type IN VARCHAR2,
name IN VARCHAR2,
schema IN VARCHAR2 DEFAULT NULL
RETURN CLOB
is
begin
-- transform parameter to add / terminator at the end
DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'SQLTERMINATOR', true);
-- call get_ddl to return object ddl
return DBMS_METADATA.get_ddl(object_type, name, schema);
end;
and then add a property with "import.getDdlFunction": "my_get_ddl"
to your oradew project (oradewrc.json
).
Similiarly you could eliminate "EDITIONABLE" from packages, if a transform parameter exists, otherwise replace content returned by get_ddl
function with:
replace(l_ddl, 'create or replace editionable', 'create or replace')
or something similar as a last resort. :)
from oradew-vscode.
I used your procedure inserted in the code generator, very useful.
function getDdl(
object_type IN VARCHAR2,
name IN VARCHAR2,
schema IN VARCHAR2 DEFAULT NULL
) return clob is
l_clob clob := NULL;
l_clob_header clob := 'CREATE OR REPLACE ';
l_name VARCHAR2(100) := name;
l_object_type VARCHAR2(100) := case object_type
when 'PACKAGE_SPEC' then 'PACKAGE'
when 'PACKAGE_BODY' then 'PACKAGE BODY'
when 'TYPE_SPEC' then 'TYPE'
when 'TYPE_BODY' then 'TYPE BODY'
else object_type
end;
begin
-- dbms_metadata.get_ddl doesn't return objects outside my home schema
-- all_source does (?)
-- this is why we are going down this path
dbms_lob.createtemporary(l_clob,true);
if l_object_type in ('VIEW', 'TRIGGER', 'TABLE') then
/*for rec in (
select text
from all_views
where
view_name = l_name
and owner = schema
)loop
l_clob := rec.text;
end loop; */
-- too hard !! for now as these object has different headers
l_clob := dbms_metadata.get_ddl(l_object_type, name, schema);
else
for rec in (
select text, line
from all_source
where
name = l_name
and owner = schema
and type = l_object_type
order by line
)loop
if rec.line = 1 then
--Add "create or replace" and schema
--\s* - white spaces
l_clob := REGEXP_REPLACE (rec.text, '^(' || l_object_type|| '\s*)', l_clob_header || l_object_type|| ' "' || schema || '".', 1, 0, 'i');
--Add " to object name, if it doesn't exists already
-- 1, 0,'i' - case insensitive
l_clob := REGEXP_REPLACE (l_clob, '"?' || l_name || '"?', '"' || l_name || '"', 1, 0, 'i');
else
dbms_lob.writeappend(l_clob, length(rec.text), rec.text);
end if;
end loop;
end if;
dbms_lob.writeappend(l_clob, length('/'), '/');
return l_clob;
end getDdl;
from oradew-vscode.
Ow, I forgot about this one!
from oradew-vscode.
Related Issues (20)
- Run as Script hangs for a few minutes HOT 3
- Windows econding UTF8 problem HOT 42
- Compile error "ERROR ORA-06550: line 3, column 40:" HOT 8
- Terminal output problem matcher HOT 26
- Generate: "output" doesn't work
- Extension causes high cpu load HOT 1
- Encoding error when importing the selected object HOT 8
- Displaying umlauts in terminal output
- Encoding problem in SQL-Statements HOT 3
- dbms_metadata.get_ddl does not work when used in UTL_GENERATE_ORADEW HOT 3
- Initialize Workspace not working HOT 8
- Oracle wallet authentication compatibility, userless & passwordless HOT 9
- Error while trying to retrieve text for error ORA-01804 HOT 5
- Drop support for sqlplus, sqlcl Liquibase ci/cd HOT 8
- Support latest version of node HOT 6
- Generating a source from a database HOT 5
- Create source from a non-DEV env
- Problem importing when object has "SQL" in the name HOT 1
- problems connecting to oracle database (proxy authentication) HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oradew-vscode.