- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- 'Drop / Create Table' inside a stored procedure
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-26-2010 05:50 AM
тАО04-26-2010 05:50 AM
'Drop / Create Table' inside a stored procedure
Does anyone know if it is possible to put CREATE/DROP statements into a stored procedure for Oracle RDB (OpenVMS 8.3, Oracle RDB 7.3)?
Example of sql script:
CREATE MODULE DB_UPGR
LANGUAGE SQL
PROCEDURE PROC();
BEGIN
DROP TABLE UPGR_VERSIONS IF EXISTS;
END;
END MODULE;
COMMIT;
ROLLBACK;
Where 'DROP' expression fails in this way:
cont> DROP TABLE UPGR_VERSIONS IF EXISTS;
%SQL-I-DEPR_FEATURE, Deprecated Feature: Keyword DROP used as an identifier
DROP TABLE UPGR_VERSIONS IF EXISTS;
^
%SQL-F-LOOK_FOR, Syntax error, looking for :, found TABLE instead
I have seen couple of articles where it was said that data definition statements like CREATE/DROP/ALTER are not allowed inside the procedure. The others said that EXECUTE 'statement' could help in this case but I'm afraid it doesn't work for Oracle RDB, does it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-26-2010 06:50 AM
тАО04-26-2010 06:50 AM
Re: 'Drop / Create Table' inside a stored procedure
I suggest you issue under SQL an
HELP COMPOUND_STMT:
Can include only a subset of the SQL statements allowed in a simple statement procedure. (See the compound-use-statement syntax diagram for a list of these valid statements.)
Then Format
...
JFP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-16-2010 12:19 AM
тАО06-16-2010 12:19 AM
Re: 'Drop / Create Table' inside a stored procedure
in addition to this theme: is there any way to get rid of error messages like this
%SQL-F-REL_EXISTS, Table X already exists in this database or schema
%SQL-F-CONALREXI, Constraint name Y already exists in this database or schema
%SQL-F-COLEXISTS, Column Z is named more than once in table NR_CREDITS
when executing a script on the same DB more than once?
Of course we can redirect output to the file and delete this messages to see the 'clear' log... Just wanted to know if this can be done somehow using RDB tools.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-16-2010 06:05 AM
тАО06-16-2010 06:05 AM
Re: 'Drop / Create Table' inside a stored procedure
What happened to your DROP TABLE x IF EXISTS; commands immediately prior to you CREATE TABLE commands? Unlike Orrible Oracle Rdb does not have CREATE OR REPLACE syntax but I guess you can always interrogate the Metadata tables if need be, but not completely sure of the requirement here?
Cheers Richard Maher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-16-2010 01:08 PM
тАО06-16-2010 01:08 PM
Re: 'Drop / Create Table' inside a stored procedure
DROP ... IF EXISTS is useful of course but we have a customer that needs to upgrade his database iteratively and he doesn't want to lose the previous data. So if we include DROP before the CREATE then every upgrade will erase all the data accumulated after the previous upgrade. That's not acceptable.
Of course we can add some check like this:
IF ( EXISTS( SELECT * FROM RDB$RELATIONS WHERE RDB$RELATION_NAME = 'TABLE_NAME' LIMIT TO 1 ROWS ) )
but this can be done only in scope of BEGIN-END expression which doesn't allow CREATE/DROP/ALTER commands as already mentioned above.
WBR, Dmitry