Pass sql into pl/sql and create RMAN duplicate script.


Posted on 16th Feb 2014 07:03 pm by admin

Hi,

I'm new to pl/sql and I'm trying to write a script that will generate some RMAN commands to do a database clone.

I want to able to run the script and it prompt me for variables to be used in the script.

I've done some research but I've been unable to find any examples of how to do this.

Basic script is (there would obviously be a lot more to the final script):

declare

dbname varchar2(9) := &dbname;

BEGIN
DBMS_OUTPUT.ENABLE(2000);
DBMS_OUTPUT.PUT_LINE(' DUPLICATE TARGET DATABASE TO '|| dbname ||';');
end;
/

Gives me:

Enter value for dbname: ORCL4
old 3: dbname varchar2(9) := &dbname;
new 3: dbname varchar2(9) := ORCL4;
dbname varchar2(9) := ORCL4;
*
ERROR at line 3:
ORA-06550: line 3, column 24:
PLS-00201: identifier 'ORCL4' must be declared
ORA-06550: line 3, column 9:
PL/SQL: Item ignored
ORA-06550: line 7, column 66:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 7, column 9:
PL/SQL: Statement ignored

Thanks,

No comments posted yet

Your Answer:

Login to answer
277 Like 49 Dislike
Previous forums Next forums
Other forums

Line break?
Hi, I'm new to the forum and new to php. I'm not sure if I'm using the correct terminology so here i

Problem with variable declaration in switch statement
Hello, I am having some trouble assigning a value to a variable inside a switch statement. What I a

Session login issue
I'm wondering how to fix a problem I'm having with a session-based login system

Say I go to h

adding 0 to numbers
Hey guys i need to create a 00001 number in a loop. Is there a better way of forcing a 5 digit numbe

Date Question
I'm using the TIMESTAMP() function within mysql to set the date/time for certain events. However, ho

Something like an INI editor or a DelimitedText-Editor
Hi all,

Am very, very, very new to PHP and not sure if I should be posting this to a Javascri

Loops and Classes
I am making a template system and everything seems to be going well up until I have to loop in a var

Concatenate two strings ???
I have string one $string1 and another $string2.

How to concatenate (add) both of them $str

query based on 2 conditions
I want to select if the doc_type is either s OR f but this doesn't work:

Code: [Select]$query

$variable $variables type question
I need to be able to designate an array element dynamically, so I thought to use a variable variable

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash