SQL*Plus auto accept CANCEL during recovery

I am scripting out to do an incomplete recovery with a backup controlfile.
How do I get SQL*Plus to automatically accept "CANCEL"
when I get to this point: Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
and then move on to "alter database open resetlogs"
SQL> recover database until cancel;
ORA-00279: change 794271 generated at 12/22/2006 12:09:07 needed for thread 1
ORA-00289: suggestion :
/opt/oracle/flash_recovery_area/DDB/archivelog/1_4_609804799.dbf
ORA-00280: change 794271 for thread 1 is in sequence #4
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
CANCEL
Media recovery cancelled.
SQL> ALTER DATABASE OPEN RESETLOGS;

You can't - that's the whole point behind incomplete media recovery - how does sqlplus know when you want to cancel

Similar Messages

  • Auto Accept changes during sync

    To Desktop Manager product manager & developers,
    Is their any plan to allow for an option to automatically accept changes during a desktop organizer syncronization?  I am using version 4.7 with Outlook and was hoping to have this kind of option and not need to answer the "accept changes" prompts.
    thanks in advance...vsdotnetguy

    In blackberry desktop manager v5.0.1, with Outlook 2007, you can enable auto-accept changes.
    Go into BB DM > Synchronize > (from left menu) configure-Synchronization > push Synchronization button on right. This will bring up Intellisync - Setup. Click advanced button > Confirmations, uncheck Confirm record deletions, uncheck confirm changes and additions
    done and done.

  • Sql  plus not accepting user id and password as scott, tiger resp

    Hi, this is mihir shah
    I have just installed oracle9i
    And I have a problem in opening the sql plus. It asks for user id and pass but when entered scott, tiger it always gives a tns error.
    Could you tell me how to make a database & how to log on & how to make a new user id and password

    It seem that you have problem with network connectivity to you database.
    Check the listener status and the configuration of the files: tnsnames.ora & listener.ora
    In all cases you must specified the error.
    Bye, Aron

  • SQL Script in XE Cancels during Execution without returning any error(s)

    Hi all;
    I'm running a SQL script with a drop table and create table statement along with several hundred insert statements to load data into this table in a Oracle 10g XE database. There's a total of 213 SQL command lines in the script. (1 Drop Tbl/1 Create Tbl/211 Insert(s)).
    I run the script within the Script Editor in the Oracle XE web interface and it processes 45 of 213 of the SQL commands in the script successfully(1 Drop Tbl/1 Create Tbl/43 Insert(s)). Then the Manage Script Results screen shows a status of "Canceled". It doesn't even attempt to insert the other rows and spit back any error messages. I tried debugging by checking the consistency of the insert statements at the break point and couldn't find any discrepancy. The script just stops executing and shows this cancelled status? Can anyone help me figure out why all the lines of this script aren't being executed? I'd appreciate it a lot!
    Thanks.
    -GM

    I've spooled output to a file which I've pasted below in italic pre-tags. I abbreviated some of output to save space in this thread. I didn't want to include 600 rows showing "1 row created" 211 times with 3 spaces between each of them. So here is my abbreviated output:
    SQL> set define off;
    SQL> @\Oracle\UTC_Upload_100807.sql;
    Table tbl_UTC_HPS_Report dropped.
    Table tbl_UTC_HPS_Report created.
    211 rows created.
    SQL> describe tbl_UTC_HPS_Report;
    Name Null? Type
    STATUS VARCHAR2(255)
    CUSTOMER_NAME VARCHAR2(255)
    CUSTOMER_NUMBER VARCHAR2(255)
    LICENSE_DESCRIPTION VARCHAR2(255)
    CONTRACT_DATE VARCHAR2(30)
    CONTRACT_NUMBER VARCHAR2(255)
    QUANTITY NUMBER(5)
    INVOICE_DATE VARCHAR2(30)
    INVOICE_CCY_CODE VARCHAR2(30)
    INVOICE_NUMBER VARCHAR2(255)
    SUPPORT_PROGRAM VARCHAR2(255)
    RENEWAL_START_DATE VARCHAR2(30)
    RENEWAL_END_DATE VARCHAR2(30)
    INVOICE_AMT VARCHAR2(255)
    INSTANCE_NUMBER VARCHAR2(255)
    SQL> select * from tbl_UTC_HPS_Report;
    STATUS
    CUSTOMER_NAME
    CUSTOMER_NUMBER
    LICENSE_DESCRIPTION
    CONTRACT_DATE
    CONTRACT_NUMBER
    QUANTITY INVOICE_DATE INVOICE_CCY_CODE
    INVOICE_NUMBER
    SUPPORT_PROGRAM
    RENEWAL_START_DATE RENEWAL_END_DATE
    INVOICE_AMT
    INSTANCE_NUMBER
    ENTERED
    STATUS
    CUSTOMER_NAME
    CUSTOMER_NUMBER
    LICENSE_DESCRIPTION
    CONTRACT_DATE
    CONTRACT_NUMBER
    QUANTITY INVOICE_DATE INVOICE_CCY_CODE
    INVOICE_NUMBER
    SUPPORT_PROGRAM
    RENEWAL_START_DATE RENEWAL_END_DATE
    INVOICE_AMT
    INSTANCE_NUMBER
    United Technologies Corporation
    STATUS
    CUSTOMER_NAME
    CUSTOMER_NUMBER
    LICENSE_DESCRIPTION
    CONTRACT_DATE
    CONTRACT_NUMBER
    QUANTITY INVOICE_DATE INVOICE_CCY_CODE
    INVOICE_NUMBER
    SUPPORT_PROGRAM
    RENEWAL_START_DATE RENEWAL_END_DATE
    INVOICE_AMT
    INSTANCE_NUMBER
    The last select statement above results in continuous spitting out of column headings with no data. I've truncated it here to save space. When I go through the Oracle Database XE web front end I see that the table was created; however it says "This table has no data". So still no luck. Hope you can help. Thanks.
    -GM

  • Accepting User input in SQL*Plus

    I am writing a SQL script in SQL*Plus that accepts a value from the user and plugs that value into a variable that exist in several locations outside of the PL/SQL block.
    I am able to do this, yet everytime this variable is encountered, the user is prompted for input. I would like to have the user prompted only once at the beginning and then use that value throughout. This seems like a simple task, yet I cannot get it to work.
    Any help would be greatly appreciated.

    You can use &&<variable_name> and it will define the variable and use it throughout the SQL code.

  • ASM Auto Start vs SQL*Plus Contention Issue

    We are trying to install the single server instance of ASM with the Grid Infrastructure and DB 11gR2. We have specified auto start on the oracleasm configuration.
    OS = Linux 5.
    After a reboot. the ASM processes show up when I run "ps -ef|grep asm". When I log into SQL*Plus it says it's connected to an idle instance. However, when I issue the startup command it responds with "ORA-15149: another ASM instance found running on the host".
    My ORACLE_SID = +ASM and my ORACLE_HOME is set to the directory where grid is installed. These are the values that I specified during the Universal Installer session.
    Can someone help me make sense of this?
    Thanks,
    Gregory

    Thanks for your replies.
    It turns out that the problem had to do with how I specified the grid ORACLE_HOME. I still don't understand why it should make a difference, but...
    I am in the habit of typing a few characters of a directory or file name and hitting tab to have the system fill in the rest of the name. As the system finishes a name it appends a slash. So, I would end up with something like
    export ORACLE_HOME=/LIB_ORACLE/11.2.0/grid/That trailing slash was screwing things up. If I entered all of that without the trailing slash, my sqlplus connected just fine.
    Thanks again,
    Gregory

  • How to cancel a search in SQL*Plus

    Once a search is initiated in SQL*Plus Worksheet, how can you stop it? I am on Windows NT. The normal Ctrl-C, Ctrl-Break, Esc don't work. I found an obscure reference in the SQL*Plus documentation about a cancel function, but it didn't give the keystrokes.

    I actually managed to crash an 8.0.5 database by hitting Ctrl-C in the middle of a query.
    Oracle Support advised me that this was a known bug. The solution?
    Don't hit Ctrl-C in the middle of a query!
    null

  • Cancel runnning SQL in SQL*Plus Worksheet?

    Hi,
    can I Cancel a runnning SQL in SQL*Plus Worksheet?
    Thanks
    Markus

    Probably not in current versions.
    SQL*Plus Worksheet is just a Java wrapper around
    command-line SQL*Plus. I recall the EM team were keen
    to see a cancelling feature in 10g, which is one of the
    reasons EM 10g will call iSQL*Plus.
    The iSQL*Plus web interface has had cancel for a few versions
    already. It has a button specially for that.
    (For reference, the EM forum is at Enterprise Manager
    -- CJ

  • Accept user input in sql *plus 9.2.0.1.0

    Any body budy can get any idea about my sourcr code?
    I wrote below code in sql *plus
    accept p_hire_date1 date FORMAT 'DD-MON-YYYY' prompt 'ENTER hire date from:'
    accept p_hire_date2 date FORMAT 'DD-MON-YYYY' prompt 'ENTER hire date to:'
    DECLARE
    v_hd1 employees.hire_date%TYPE := TO_DATE(&p_hire_date1);
    v_hd2 employees.hire_date%TYPE := TO_DATE(&p_hire_date2);
    CURSOR emp_cursor IS
    SELECT e.last_name, e.first_name, e.hire_date, e.salary, d.department_name
    FROM employees e, departments d
    WHERE ((e.hire_date>=v_hd1) AND (e.hire_date<=v_hd2)) AND
    (e.department_id=d.department_id)
    ORDER BY e.first_name;
    emp_record emp_cursor%ROWTYPE;
    BEGIN
    DBMS_OUTPUT.ENABLE
    DBMS_OUTPUT.PUT_LINE(RPAD('Name',20) || RPAD('Hire Date',15) || RPAD('Salary',15) || RPAD('Dept. name',15));
    DBMS_OUTPUT.PUT_LINE(RPAD('-',4*15,'-'));
    FOR emp_record IN emp_cursor
    LOOP
    DBMS_OUTPUT.PUT_LINE(RPAD(emp_record.first_name || ' ' || emp_record.last_name,20) || RPAD(TO_CHAR(emp_record.hire_date),15) || RPAD(TO_CHAR(emp_record.salary),15) || RPAD(emp_record.department_name,15) );
    END LOOP;
    END;
    when I execute it I got this error
    SQL> /
    Enter value for p_hire_date2: 23
    accept p_hire_date1 date FORMAT 'DD-MON-YYYY' prompt 'ENTER hire date from:'
    ERROR at line 2:
    ORA-00900: invalid SQL statement
    any Idea?

    Your "accept" statement seems to be correct.
    Please change the declaration of v_hd1 and v_hd2 as below.
    v_hd1 employees.hire_date%TYPE := TO_DATE('&p_hire_date1','DD-MON-YYYY');
    v_hd2 employees.hire_date%TYPE := TO_DATE('&p_hire_date2','DD-MON-YYYY');
    Since p_hire_date1 and p_hire_date2 are date variables enter a valid date of format DD-MON-YYYY. You have entered 23 which is not a valid date.

  • SQL*Plus report: hide accept value in report

    HI all,
    I have created an SQL Report of an APEX-Application. The output is stored in a HTML file.
    All works fine but one think I want to hide in the HTML report.
    I try to describe what the problem is.
    I prompt the user to put in the application_id of the apex application:
                           accept v_application_Id char prompt 'Appliaction-ID:'
    In the HTML file the following output is shown:
    Report created on:
    25-Jun-2013, 10:06:04
    alt 8: where application_id = &&v_application_id
    neu 8: where application_id = 680
    Workspace
    WORKSPACE
    APPLICATION_ID
    APPLICATION_NAME
    ALIAS
    OWNER
    Q0Q0AUFTRAGSVERWALTUNG
    680
    Q0Q0AUFTRAGSVERWALTUNG
    F680317
    Q0Q0AUFTRAGSVERWALTUNG_ADMIN
    How can I hide the two lines
    alt 8: where application_id = &&v_application_id
    neu 8: where application_id = 680
    from the report?
    I have searched  this forum and toke a look into the documentation but I have nothing found.
    Could anyone please help me?
    Oracle 11g R2
    This is the SQL script what I run in SQL*Plus.
    -- start script
    accept v_application_Id char prompt 'Appliaction-ID:'
    spool C:\a\APEX.html
    set termout off
    SET MARKUP HTML ON SPOOL ON HEAD "<TITLE>SQL*Plus APEX-Report</title> -
    <STYLE TYPE=’TEXT/CSS’><!--BODY {bgcolor: ffffaa background: ffffc6} --></STYLE>"
    clear break
    clear buffer
    clear compute
    clear column
    clear sql
    set feedback off
    set serveroutput on
    -- Report Header
    ttitle left ' ' skip 1
    select TO_CHAR(sysdate,'dd-Mon-yyyy, hh24:mm:ss')  "Report created on:"
    from dual;
    -- Workspace
    ttitle left col 15 '<font face="Arial" size="+2" color="#0000FF">Workspace</font>' skip 1
    set linesize 300
    set pagesize 500
    set serveroutput on
    column workspace format a35
    column application_id format 99999999
    column application_name format a35
    column alias format a35
    column owner format a35
         select
             WORKSPACE,
             APPLICATION_ID ,
             APPLICATION_NAME,
             ALIAS,
             OWNER
         from apex_applications
         where application_id = &&v_application_id;
    ttitle off
         select
             APPLICATION_GROUP,
             APPLICATION_GROUP_ID,
             HOME_LINK,
             PAGE_TEMPLATE,
             ERROR_PAGE_TEMPLATE
         from apex_applications
         where application_id = &&v_application_id;
    set termout on
    set markup html off head '' body '' entmap off spool off pre off
    set feedback on
    set linesize 80
    set pagesize 50
    ttitle off
    set termout on
    set serveroutput off
    spool off
    set echo on
    -- End Script
    best regards
    ben
    Oracle 11g R2

    Hi, Ben,
    The SQL*Plus command to stop those messages is
    SET VERIFY OFF
    Put this command anywhere before the first use of a substitution variable, e.g. before the SPOOL command.
    Those "OLD" and "NEW" messages will stay suppressed until you either end the SQL*Plus session, or issue a SET VERIFY ON command.
    If you use SQL*Plus often, then, when you have a few minutes, look up the SET command in the SQL*Plus manual,
    SET System Variable Summary
    and read a little about each option.  You probably won't remember everything, but you probably will remember what kinds of things can be controlled by the SET command, and have a better idea of where to start looking in the future when you have a different problem.

  • Accept input from Shell script in sql*plus

    Hey! Guys..
    i need the following info.
    I am running a shell script from sql*plus. I need to accept a value from shell script into my .sql file.
    thanks..
    Harsh.

    prompt for input, pass to another shell
    # contract_status_prompt.sh
    read udate?"Enter week-ending date in format dd-mmm-yyyy: "
    contract_status_update.sh $udate >$FDWLOG/current/contractstatusupdate`date +%d%h%y`.log
    echo `date`
    # End contract_status_prompt.sh
    Read the variable passed and use in SQLPlus:
    # contract_status_update.sh
    echo "Running contract_status.sh"
    echo "create records for contract_status"
    echo `date`
    echo " "
    echo " date used is "; print $1
    echo " "
    sqlplus <<exit
    @$FDWSQL/sqlparms
    set time on
    prompt *** Set contract_status_period ***
    update contract_status_period
    set period_date = '$1';
    commit;
    exit
    etc.

  • Recover Database in RMAN vs SQL*PLUS

    Hello,
    Oracle 11.2.0.1, Oracle Linux 5.5 UEK.
    I recently did a "recover database" in sql*plus, but an attempt to open the database gave ORA-01113, complaining the system tablespace requried more recovery. Then I used RMAN (nocatalog) and after the same "recover database" command I was able to open the database.
    It seems there are differences between SQL*PLUS and RMAN "recover database" command. I have not been able to locate the chapter in the Oracle documentation that explains the difference. I have some ideas, but...
    Thanks.
    h3. Solution Summary:
    The recover command in RMAN compared to SQL*Plus implements a more user friendly processing logic based on the current detected scenario. For instance, a RMAN recover database command may actually perform a "recover database using backup controlfile until cancel" and automatically apply all archived and online redo logs if available. The same can be achieved with the recover command in SQL*plus, but will have to be done manually.
    Edited by: Dude on Jan 7, 2011 12:30 PM

    Dude wrote:
    I did not remove any datafiles or redo logs. it is the same restore operation as before, and again RMAN "recovery database" succeeds, whereas SQL recover has trouble. This tells me something is different between the two methods. For one, RMAN does not requrie to specify "using backup controlfile".
    Maybe someting about "resetlogs" that that RMAN recover can handle and SQL recover not?No,problem is there.If you using rman execute RECOVER DATABASE it also will apply online logs(if available) also and as result you will get complete recovery however you must open database with resetlogs option due to you recovered database using backup controlfile.So also you can recover and open database applying this online logs.After executing RECOVER DATABASE USING BACKUP CONTROLFILE you have to pass full path of online log then press ENTER so log will apply and you can open database with RESETLOGS.See below
    C:\Documents and Settings\chinar>rman target sys/sm
    Recovery Manager: Release 10.2.0.1.0 - Production on Fri Jan 7 17:47:49 2011
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    connected to target database (not started)
    RMAN> startup nomount;
    Oracle instance started
    Total System Global Area     138412032 bytes
    Fixed Size                     1247708 bytes
    Variable Size                 71304740 bytes
    Database Buffers              58720256 bytes
    Redo Buffers                   7139328 bytes
    RMAN> restore controlfile from 'D:\oracle\product\10.2.0\flash_recovery_area\T\B
    ACKUPSET\2011_01_07\O1_MF_NCSNF_TAG20110107T171001_6LG48JR5_.BKP'
    2> ;
    Starting restore at 07-JAN-11
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: sid=157 devtype=DISK
    channel ORA_DISK_1: restoring control file
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
    output filename=D:\ORACLE\PRODUCT\10.2.0\ORADATA\T\CONTROL01.CTL
    output filename=D:\ORACLE\PRODUCT\10.2.0\ORADATA\T\CONTROL02.CTL
    output filename=D:\ORACLE\PRODUCT\10.2.0\ORADATA\T\CONTROL03.CTL
    Finished restore at 07-JAN-11
    RMAN> alter database mount;
    database mounted
    released channel: ORA_DISK_1
    RMAN> restore database;
    Starting restore at 07-JAN-11
    Starting implicit crosscheck backup at 07-JAN-11
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: sid=156 devtype=DISK
    Crosschecked 1 objects
    Finished implicit crosscheck backup at 07-JAN-11
    Starting implicit crosscheck copy at 07-JAN-11
    using channel ORA_DISK_1
    Finished implicit crosscheck copy at 07-JAN-11
    searching for all files in the recovery area
    cataloging files...
    cataloging done
    List of Cataloged Files
    =======================
    File Name: D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\T\BACKUPSET\2011_01_07\O
    1_MF_NCSNF_TAG20110107T171001_6LG48JR5_.BKP
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting datafile backupset restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    restoring datafile 00001 to D:\ORACLE\PRODUCT\10.2.0\ORADATA\T\SYSTEM01.DBF
    restoring datafile 00002 to D:\ORACLE\PRODUCT\10.2.0\ORADATA\T\UNDOTBS01.DBF
    restoring datafile 00003 to D:\ORACLE\PRODUCT\10.2.0\ORADATA\T\SYSAUX01.DBF
    restoring datafile 00004 to D:\ORACLE\PRODUCT\10.2.0\ORADATA\T\USERS01.DBF
    channel ORA_DISK_1: reading from backup piece D:\ORACLE\PRODUCT\10.2.0\FLASH_REC
    OVERY_AREA\T\BACKUPSET\2011_01_07\O1_MF_NNNDF_TAG20110107T171001_6LG45BXS_.BKP
    channel ORA_DISK_1: restored backup piece 1
    piece handle=D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\T\BACKUPSET\2011_01_07
    \O1_MF_NNNDF_TAG20110107T171001_6LG45BXS_.BKP tag=TAG20110107T171001
    channel ORA_DISK_1: restore complete, elapsed time: 00:01:04
    Finished restore at 07-JAN-11
    RMAN> recover database;
    Starting recover at 07-JAN-11
    using channel ORA_DISK_1
    starting media recovery
    archive log thread 1 sequence 7 is already on disk as file D:\ORACLE\PRODUCT\10.
    2.0\ORADATA\T\REDO02.LOG
    archive log filename=D:\ORACLE\PRODUCT\10.2.0\ORADATA\T\REDO02.LOG thread=1 sequ
    ence=7
    media recovery complete, elapsed time: 00:00:03
    Finished recover at 07-JAN-11
    RMAN> exit
    Recovery Manager complete.
    C:\Documents and Settings\chinar>sqlplus sys/sm as sysdba
    SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jan 7 17:51:31 2011
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> alter database open;
    alter database open
    ERROR at line 1:
    ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
    SQL> alter database open resetlogs;
    Database altered.
    SQL> And above you see lines as
    archive log thread 1 sequence 7 is already on disk as file D:\ORACLE\PRODUCT\10.
    *2.0\ORADATA\T\REDO02.LOG*
    archive log filename=D:\ORACLE\PRODUCT\10.2.0\ORADATA\T\REDO02.LOG thread=1 sequ
    ence=7
    It means RMAN apply these.So you can apply these using SQLPLUS ALSO.In additionally you can see that from alert log as
    alter database recover if needed
    start until cancel using backup controlfile
    Media Recovery Start
    parallel recovery started with 2 processes
    ORA-279 signalled during: alter database recover if needed
    start until cancel using backup controlfile
    Fri Jan 07 17:50:34 2011
    alter database recover logfile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\T\REDO02.LOG'
    Fri Jan 07 17:50:34 2011
    Media Recovery Log D:\ORACLE\PRODUCT\10.2.0\ORADATA\T\REDO02.LOG
    Fri Jan 07 17:50:34 2011
    Incomplete recovery applied all redo ever generated.
    Recovery completed through change 665263
    Completed: alter database recover logfile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\T\REDO02.LOG'And finally you see clearly that even if you execute RECOVER DATABASE from RMAN it actually execute RECOVER DATABASE UNTIL CANCEL USING BACKUP CONTROLFILE (from alert.log start  until cancel using backup controlfile)
    And these is not any difference.
    Hope that help you and you got answer.

  • Cancel based recovery

    dear dba's,
    i'm using oracle 11gR2 in windows 2003 sever S2.
    could anyone tell me
    1. what is CANCEL BASED RECOVERY
    2. pls give the commands with an explanation
    3. In which suituation we must use this type of recovery.
    Thanks & Regards,
    John Marshal.A

    +1. what is CANCEL BASED RECOVERY+
    It is an incomplete recovery option , at particular time you want to recover yours database for an audit purpose or to avoid any logical error by users in past , but flashback technology now been dominant to cancel based reocovery.
    +2. pls give the commands with an explanation+
    +3. In which suituation we must use this type of recovery.+
    When yours controlfile does not know when so far yours recover could be go on and on by "recover database using backup controlfile until cancel" yours restored controlfile from backup typically does not know how far i need redo if you are doing manual recovery while RMAN does not need cancel based recovery it will keep applying log until it finds and bumped out with an error RMAN-06054: media recovery requesting unknown archived log for ..... .
    Situation could be manual recovery in general when you do not define time.scn based recovery using until clause.
    Copied from my blog but need to be a bit changes thats why pasting here.
    Scenario 1
    I lost all data file but my control file is intact at the same location where it was , before lost datafiles i have backed up the data files, controlfile and archive logs.
    If you are just restoring the data files and not control files then you may know how much archive log sequence required for yours recovery after the backup taken using archived log repository.
    RMAN> backup database;
    Starting backup at 02-OCT-09
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=128 device type=DISK
    channel ORA_DISK_1: starting full datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    input datafile file number=00001 name=/u01/app/oracle/oradata/his/system01.dbf
    input datafile file number=00002 name=/u01/app/oracle/oradata/his/sysaux01.dbf
    input datafile file number=00003 name=/u01/app/oracle/oradata/his/undotbs01.dbf
    input datafile file number=00004 name=/u01/app/oracle/oradata/his/users01.dbf
    channel ORA_DISK_1: starting piece 1 at 02-OCT-09
    channel ORA_DISK_1: finished piece 1 at 02-OCT-09
    piece handle=/u01/app/oracle/flash_recovery_area/HIS/backupset/2009_10_02/o1_mf_nnndf_TAG20091002T112226_5dc712wg_.bkp tag=TAG20091002T112226 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
    Finished backup at 02-OCT-09
    Starting Control File and SPFILE Autobackup at 02-OCT-09
    piece handle=/u01/app/oracle/flash_recovery_area/HIS/autobackup/2009_10_02/o1_mf_s_699189791_5dc72j13_.bkp comment=NONE
    Finished Control File and SPFILE Autobackup at 02-OCT-09
    RMAN> sql 'alter system archive log current';
    using target database control file instead of recovery catalog
    sql statement: alter system archive log current
    RMAN> sql 'alter system archive log current';
    sql statement: alter system archive log current
    RMAN> sql 'alter system archive log current';
    sql statement: alter system archive log current
    RMAN> exit
    Recovery Manager complete.
    [oracle@khurram his]$ sqlplus / as sysdba
    SQL*Plus: Release 11.1.0.6.0 - Production on Fri Oct 2 11:24:04 2009
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> select name,sequence#
      2    from v$archived_log
      3   where status='A'
      4  /
    NAME                                                                                 SEQUENCE#
    /u01/app/oracle/product/11.1.0/db_1/dbs/arch1_2_699187272.dbf                           2
    /u01/app/oracle/flash_recovery_area/HIS/archivelog/2009_10_02/o1_mf_1_2_5dc73qw2_.arc   2
    /u01/app/oracle/product/11.1.0/db_1/dbs/arch1_3_699187272.dbf                           3
    /u01/app/oracle/flash_recovery_area/HIS/archivelog/2009_10_02/o1_mf_1_3_5dc73vgm_.arc   3
    /u01/app/oracle/product/11.1.0/db_1/dbs/arch1_4_699187272.dbf                           4
    /u01/app/oracle/flash_recovery_area/HIS/archivelog/2009_10_02/o1_mf_1_4_5dc740d7_.arc   4
    6 rows selected.You may know if yours control file intact (not lost or restored from backup), you may know how much recovery will go so far by knowing archived logs repository (conrolfile).From above v$archived_log archveilog repository you are seeing that after backup there are sequence required for the archive logs are 2,3 and 4 for recovering the restored backup which you have taken as above.
    SQL> exit
    Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    [oracle@khurram his]$ cd /u01/app/oracle/oradata/his/*.dbf
    bash: cd: /u01/app/oracle/oradata/his/sysaux01.dbf: Not a directory
    [oracle@khurram his]$ rm -rf  /u01/app/oracle/oradata/his/*.dbf
    [oracle@khurram his]$ sqlplus / as sysdba
    SQL*Plus: Release 11.1.0.6.0 - Production on Fri Oct 2 11:28:01 2009
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> shutdown abort
    ORACLE instance shut down.
    SQL> startup mount
    ORACLE instance started.
    Total System Global Area 1620115456 bytes
    Fixed Size                  2144864 bytes
    Variable Size             922748320 bytes
    Database Buffers          687865856 bytes
    Redo Buffers                7356416 bytes
    Database mounted.
    SQL> exit
    Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    [oracle@khurram his]$ rman target /
    Recovery Manager: Release 11.1.0.6.0 - Production on Fri Oct 2 11:29:30 2009
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    connected to target database: HIS (DBID=3219691467, not open)
    RMAN> restore database;
    Starting restore at 02-OCT-09
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=154 device type=DISK
    channel ORA_DISK_1: starting datafile backup set restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/his/system01.dbf
    channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/his/sysaux01.dbf
    channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/his/undotbs01.dbf
    channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/his/users01.dbf
    channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/HIS/backupset/2009_10_02/o1_mf_nnndf_TAG20091002T112226_5dc712wg_.bkp
    channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/HIS/backupset/2009_10_02/o1_mf_nnndf_TAG20091002T112226_5dc712wg_.bkp tag=TAG20091002T112226
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
    Finished restore at 02-OCT-09
    RMAN> recover database;
    Starting recover at 02-OCT-09
    using channel ORA_DISK_1
    starting media recovery
    archived log for thread 1 with sequence 2 is already on disk as file /u01/app/oracle/flash_recovery_area/HIS/archivelog/2009_10_02/o1_mf_1_2_5dc73qw2_.arc
    archived log for thread 1 with sequence 3 is already on disk as file /u01/app/oracle/flash_recovery_area/HIS/archivelog/2009_10_02/o1_mf_1_3_5dc73vgm_.arc
    archived log for thread 1 with sequence 4 is already on disk as file /u01/app/oracle/flash_recovery_area/HIS/archivelog/2009_10_02/o1_mf_1_4_5dc740d7_.arc
    archived log file name=/u01/app/oracle/flash_recovery_area/HIS/archivelog/2009_10_02/o1_mf_1_2_5dc73qw2_.arc thread=1 sequence=2
    media recovery complete, elapsed time: 00:00:01
    Finished recover at 02-OCT-09
    as you can see that 2,3,4 were required during recovery process.Scenario 2
    I lost all data file as well control file , i have backed up the data files, controlfile and archive logs.
    Its like a disastre you lost alls data file and as well controlfile , if you backed the controlfile then remember during controlfile backup it will have file type flag 4 that tells Oracle it is a backup control file. The Stop SCN for alls data file marked to 0xffff.ffffffff (infinity).File type flag in the backup control file tells to oracle that it cannot rely on its redo thread,which means recovering will go on and on , controlfile will not aware how much should i go for redo it will never stop if you are able to supply redo.
    It will always ask you more subsequent redo if you already supplied to it during process that's why it let you open the database in reset logs.
    Lets see after restoring the controlfile and datafiles , you will see SQL tool recovery mechanism ask you recover database using backup controlfile which shows that controlfile does not know where to end the applying redo chain.
    Here an excerpt which shows that restored controlfile does not know till how long the redo should be applied, its the RMAN robustness which does not ask you manually to supply redo, RMAN search the alls redo from archivelogs and if possible you have redo within redo logs.But if you are not with RMAN i.e recovering by SQL then you have to cancel recovery at some end.
    RMAN> shutdown abort
    Oracle instance shut down
    RMAN> exit
    Recovery Manager complete.
    [oracle@khurram ~]$ rm -rf /u01/app/oracle/oradata/his/*
    [oracle@khurram ~]$ rman target /
    Recovery Manager: Release 11.1.0.6.0 - Production on Fri Oct 2 09:32:37 2009
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    connected to target database (not started)
    RMAN> startup nomount
    Oracle instance started
    Total System Global Area    1620115456 bytes
    Fixed Size                     2144864 bytes
    Variable Size                922748320 bytes
    Database Buffers             687865856 bytes
    Redo Buffers                   7356416 bytes
    RMAN> restore controlfile from autobackup;
    Starting restore at 02-OCT-09
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=153 device type=DISK
    recovery area destination: /u01/app/oracle/flash_recovery_area
    database name (or database unique name) used for search: HIS
    channel ORA_DISK_1: AUTOBACKUP /u01/app/oracle/flash_recovery_area/HIS/autobackup/2009_10_02/o1_mf_s_699182899_5dc0c49t_.bkp found in the recovery area
    AUTOBACKUP search with format "%F" not attempted because DBID was not set
    channel ORA_DISK_1: restoring control file from AUTOBACKUP /u01/app/oracle/flash_recovery_area/HIS/autobackup/2009_10_02/o1_mf_s_699182899_5dc0c49t_.bkp
    channel ORA_DISK_1: control file restore from AUTOBACKUP complete
    output file name=/u01/app/oracle/oradata/his/control01.ctl
    output file name=/u01/app/oracle/oradata/his/control02.ctl
    output file name=/u01/app/oracle/oradata/his/control03.ctl
    Finished restore at 02-OCT-09
    RMAN> alter database mount;
    database mounted
    released channel: ORA_DISK_1
    RMAN> restore database;
    Starting restore at 02-OCT-09
    Starting implicit crosscheck backup at 02-OCT-09
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=153 device type=DISK
    Crosschecked 1 objects
    Finished implicit crosscheck backup at 02-OCT-09
    Starting implicit crosscheck copy at 02-OCT-09
    using channel ORA_DISK_1
    Finished implicit crosscheck copy at 02-OCT-09
    searching for all files in the recovery area
    cataloging files...
    cataloging done
    List of Cataloged Files
    =======================
    File Name: /u01/app/oracle/flash_recovery_area/HIS/autobackup/2009_10_02/o1_mf_s_699182899_5dc0c49t_.bkp
    File Name: /u01/app/oracle/flash_recovery_area/HIS/archivelog/2009_10_02/o1_mf_1_5_5dc0d1m8_.arc
    File Name: /u01/app/oracle/flash_recovery_area/HIS/archivelog/2009_10_02/o1_mf_1_3_5dc0cx6p_.arc
    File Name: /u01/app/oracle/flash_recovery_area/HIS/archivelog/2009_10_02/o1_mf_1_4_5dc0czx3_.arc
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting datafile backup set restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/his/system01.dbf
    channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/his/sysaux01.dbf
    channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/his/undotbs01.dbf
    channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/his/users01.dbf
    channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/HIS/backupset/2009_10_02/o1_mf_nnndf_TAG20091002T092724_5dc09dlc_.bkp
    channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/HIS/backupset/2009_10_02/o1_mf_nnndf_TAG20091002T092724_5dc09dlc_.bkp tag=TAG20091002T092724
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
    Finished restore at 02-OCT-09
    [oracle@khurram ~]$ sqlplus / as sysdba
    SQL*Plus: Release 11.1.0.6.0 - Production on Fri Oct 2 09:34:51 2009
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> recover database using backup contorlfile until cancel
    Keep applying log as you can and you have and cancel at an end when alls logs are supplied to recovery process.

  • Connect via SQL*Plus taking more time in Oracle 11 than in 10

    Oracle Version
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE    11.2.0.3.0      Production
    TNS for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Productioncurrently migrating from
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for IBM/AIX RISC System/6000: Version 10.2.0.4.0 - Productio
    NLSRTL Version 10.2.0.4.0 - ProductionOS is AIX 5.3 for Oracle 10 and AIX 6.1 for Oracle 11.
    We are currently in the process of migrating some applications from Oracle 10 to 11. Our admins have setup a new development system for us with an Oracle 11 instance. Regarding performance the new system behaves more or less the same than our old, e.g. when executing SQLs we notice hardly any performance differences and those we find are slightly in favour of the new system.
    But now we discovered that the time it takes to establish a database connection via SQL*Plus is longer on the Oracle 11 system. Running the following code
    sqlplus -s user/pw@database <<END
    quit
    ENDa thousand times takes ~60s under Oracle 10 but ~140s under Oracle 11. This may not seem much but we are running a test framework consisting of a bunch of shell scripts where several thousand connections are openend via SQL*Plus to execute some SQLs, so that even this small time difference results in rather huge difference in total runtime. The SQLs themself require roughly the same time in both databases, as already mentioned above they are in fact slightly faster in Oracle 11.
    To analyze the time difference I ran a trace for the connect with the following parameters in sqlnet.ora
    TRACE_LEVEL_CLIENT=4
    TRACE_UNIQUE_CLIENT=ONand found out that there is a time difference of about 70ms during the connect handshake:
    Oracle 10
    [22-MAR-2013 12:13:09:595] nscon: doing connect handshake...
    [22-MAR-2013 12:13:09:595] nscon: sending NSPTCN packet
    [22-MAR-2013 12:13:09:621] nscon: got NSPTRS packet
    [22-MAR-2013 12:13:09:621] nscon: sending NSPTCN packetOracle 11
    (1) [22-MAR-2013 12:15:26:812] nscon: doing connect handshake...
    (1) [22-MAR-2013 12:15:26:812] nscon: sending NSPTCN packet
    (1) [22-MAR-2013 12:15:26:906] nscon: got NSPTRS packet
    (1) [22-MAR-2013 12:15:26:906] nscon: sending NSPTCN packetUnder Oracle 10 there are 26ms between sending the NSPTCN packet and getting the NSPTRS packet, whereas under Oracle 11 this takes 94ms. I ran the trace again, this time with
    TRACE_LEVEL_CLIENT=16and got the following results for the critical interval:
    Oracle 10:
    [22-MAR-2013 13:17:37:638] nscon: sending NSPTCN packet
    [22-MAR-2013 13:17:37:638] nspsend: entry
    [22-MAR-2013 13:17:37:638] nspsend: plen=218, type=1
    [22-MAR-2013 13:17:37:638] nttwr: entry
    [22-MAR-2013 13:17:37:638] nttwr: socket 9 had bytes written=218
    [22-MAR-2013 13:17:37:638] nttwr: exit
    [22-MAR-2013 13:17:37:638] nspsend: packet dump
    <<packet dump removed>>
    [22-MAR-2013 13:17:37:638] nspsend: 218 bytes to transport
    [22-MAR-2013 13:17:37:638] nspsend: normal exit
    [22-MAR-2013 13:17:37:638] nscon: exit (0)
    [22-MAR-2013 13:17:37:638] nsdo: nsctxrnk=0
    [22-MAR-2013 13:17:37:638] nsdo: normal exit
    [22-MAR-2013 13:17:37:638] nsdo: entry
    [22-MAR-2013 13:17:37:638] nsdo: cid=0, opcode=68, *bl=512, *what=9, uflgs=0x0, cflgs=0x3
    [22-MAR-2013 13:17:37:638] nsdo: rank=64, nsctxrnk=0
    [22-MAR-2013 13:17:37:638] nsdo: nsctx: state=2, flg=0x4005, mvd=0
    [22-MAR-2013 13:17:37:638] nsdo: gtn=10, gtc=10, ptn=10, ptc=2011
    [22-MAR-2013 13:17:37:638] nscon: entry
    [22-MAR-2013 13:17:37:638] nscon: recving a packet
    [22-MAR-2013 13:17:37:638] nsprecv: entry
    [22-MAR-2013 13:17:37:638] nsprecv: reading from transport...
    [22-MAR-2013 13:17:37:638] nttrd: entry
    [22-MAR-2013 13:17:37:665] nttrd: socket 9 had bytes read=8
    [22-MAR-2013 13:17:37:665] nttrd: exit
    [22-MAR-2013 13:17:37:665] nsprecv: 8 bytes from transport
    [22-MAR-2013 13:17:37:665] nsprecv: tlen=8, plen=8, type=11
    [22-MAR-2013 13:17:37:665] nsprecv: packet dump
    [22-MAR-2013 13:17:37:665] nsprecv: 00 08 00 00 0B 00 00 00  |........|
    [22-MAR-2013 13:17:37:665] nsprecv: normal exit
    [22-MAR-2013 13:17:37:665] nscon: got NSPTRS packetOracle 11
    (1) [22-MAR-2013 13:33:40:504] nscon: sending NSPTCN packet
    (1) [22-MAR-2013 13:33:40:504] nspsend: entry
    (1) [22-MAR-2013 13:33:40:504] nspsend: plen=205, type=1
    (1) [22-MAR-2013 13:33:40:504] nttwr: entry
    (1) [22-MAR-2013 13:33:40:504] nttwr: socket 8 had bytes written=205
    (1) [22-MAR-2013 13:33:40:504] nttwr: exit
    (1) [22-MAR-2013 13:33:40:504] nspsend: packet dump
    <<packet dump removed>>
    (1) [22-MAR-2013 13:33:40:505] nspsend: 205 bytes to transport
    (1) [22-MAR-2013 13:33:40:505] nspsend: normal exit
    (1) [22-MAR-2013 13:33:40:505] nscon: exit (0)
    (1) [22-MAR-2013 13:33:40:505] snsbitts_ts: entry
    (1) [22-MAR-2013 13:33:40:505] snsbitts_ts: acquired the bit
    (1) [22-MAR-2013 13:33:40:505] snsbitts_ts: normal exit
    (1) [22-MAR-2013 13:33:40:505] nsdo: nsctxrnk=0
    (1) [22-MAR-2013 13:33:40:505] snsbitcl_ts: entry
    (1) [22-MAR-2013 13:33:40:505] snsbitcl_ts: normal exit
    (1) [22-MAR-2013 13:33:40:505] nsdo: normal exit
    (1) [22-MAR-2013 13:33:40:505] nsdo: entry
    (1) [22-MAR-2013 13:33:40:505] nsdo: cid=0, opcode=68, *bl=2048, *what=9, uflgs=0x0, cflgs=0x3
    (1) [22-MAR-2013 13:33:40:505] snsbitts_ts: entry
    (1) [22-MAR-2013 13:33:40:505] snsbitts_ts: acquired the bit
    (1) [22-MAR-2013 13:33:40:505] snsbitts_ts: normal exit
    (1) [22-MAR-2013 13:33:40:505] nsdo: rank=64, nsctxrnk=0
    (1) [22-MAR-2013 13:33:40:505] snsbitcl_ts: entry
    (1) [22-MAR-2013 13:33:40:505] snsbitcl_ts: normal exit
    (1) [22-MAR-2013 13:33:40:505] nsdo: nsctx: state=2, flg=0x4005, mvd=0
    (1) [22-MAR-2013 13:33:40:505] nsdo: gtn=10, gtc=10, ptn=10, ptc=8155
    (1) [22-MAR-2013 13:33:40:505] nscon: entry
    (1) [22-MAR-2013 13:33:40:505] nscon: recving a packet
    (1) [22-MAR-2013 13:33:40:505] nsprecv: entry
    (1) [22-MAR-2013 13:33:40:505] nsprecv: reading from transport...
    (1) [22-MAR-2013 13:33:40:505] nttrd: entry
    (1) [22-MAR-2013 13:33:40:618] nttrd: socket 8 had bytes read=8
    (1) [22-MAR-2013 13:33:40:618] nttrd: exit
    (1) [22-MAR-2013 13:33:40:618] nsprecv: 8 bytes from transport
    (1) [22-MAR-2013 13:33:40:618] nsprecv: tlen=8, plen=8, type=11
    (1) [22-MAR-2013 13:33:40:618] nsprecv: packet dump
    (1) [22-MAR-2013 13:33:40:618] nsprecv: 00 08 00 00 0B 00 00 00  |........|
    (1) [22-MAR-2013 13:33:40:618] nsprecv: normal exit
    (1) [22-MAR-2013 13:33:40:618] nscon: got NSPTRS packetAny ideas what could be the reason for this time difference? Something in our network configuration or something else?

    With local connections - I do not think a TCP packet send from an IP to the same IP, leaves the interface as an actual wire protocol/signal. If I'm correct, then running local connection tests will be mostly useless in checking the actual network infrastructure.
    Tests 3 and 4 should be showing the same connection times as the same physical network infrastructure is used - only the direction is reversed in the tests.
    I would assume that port settings on the switches and interface settings on the routers treat packets equally in both directions between 2 servers. But this could in part explain the problem if this is not the case. In a case of a router for example, the 1st test's ingress interface is the egress interface of the 2nd test (and vice versa). Configurations can differ substantially between interfaces on the same router. Likewise if there is a firewall - as different rule sets are applied in each test and these rule sets could differ.
    So I would not be too quick to state that this is definitely not a network problem. But I agree that based on the small percentage difference (assuming comparable tests), it does not look like a network issue.
    The next step is to determine what the delay is between the listener accepting the client connection, and the connection being serviced by a dedicated server process.
    This will require listener tracing - tracing the time from when the listener accepted the connection (and parsed the TNS connection string), to handing off the connection to the dedicated server process.
    As a comparison test, you can also test shared server connections. Dispatcher processes (of the db instance) register themselves with the listener. The shared server client hand off is thus done to an existing server process - no need for the Listener to make a kernel call to load and initialise an executable image.
    Shared connections are typically faster than dedicated connections in this respect.
    If there is a major time difference, then it means some kind of issue with the listener dealing with dedicated servers as oppose to dispatcher hand off's. As both connections would have had very similar network transit time - which means the connection time difference is related directly to dealing with a dedicated server connection request and hand off.
    You can also substitute the oracle executable with a wrapper - and troubleshoot the actual dedicated server startup. I've only done this with Oracle XE 10.2 though and with local IPC connections. Unsure how robust this will be for testing purposes via TCP using 11g.

  • Interactive script in SQL*PLUS

    Hi,
    I am a student and we need to write a script to be executed in SQL*PLUS.
    Script has to execute an insert statement but all values need to be provided during runtime and in the end there should be a question if you wan't to save data. When yes then commit when no then rollback.
    Below is my code. Problem is that program asks for variables' values after beginning then it displays all dbms_output.put_line and then continue with pl/sql.
    I want to for examle:
    - display message 'provide date'
    - covvert string date to date type
    - when error then exit, when ok then continue
    - provide other variables in the same way
    - ask for saving.
    My code:
    SET SERVEROUTPUT ON
    set verify off
    ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD';
    declare
    do_save varchar2(240) ;
    v_ename varchar2(50);
    v_job varchar2(50);
    v_sal number;
    v_hiredate date;
    v_tmp varchar(50);
    begin
    DBMS_OUTPUT.put_line('Provide name:');
    v_tmp := '&val_ename';
    v_ename := v_tmp;
    DBMS_OUTPUT.put_line('Provide salary:');
    v_tmp := '&val_sal';
    begin
    v_sal := cast(v_tmp as number);
    exception when others then
    DBMS_OUTPUT.put_line('Incorrect salary format.');
    end;
    DBMS_OUTPUT.put_line('Provide data:');
    v_tmp := '&val_hiredate';
    begin
    v_hiredate := to_date(v_tmp);
    exception when others then
    DBMS_OUTPUT.put_line('Incorrect date format.');
    end;
    INSERT INTO EMP(ENAME, SAL, HIREDATE)
    VALUES (v_ename, v_sal, v_hiredate);
    DBMS_OUTPUT.put_line('Do you want to save? [Y/N]');
    do_save := '&val_save';
    do_save := upper(ltrim(substr(nvl(do_save, 'N'), 1,1)));
    IF do_save = 'Y' THEN
    commit;
    DBMS_OUTPUT.put_line('Data saved.');
    ELSE
    rollback;
    DBMS_OUTPUT.put_line('Data rejected.');
    END IF;
    end;
    /

    user10613699 wrote:
    it is not solving my problem,...Why not? Did you test and also check the documentation link?
    SQL> accept DO_SAVE  prompt 'Do you want to save (Y/N)? ';
    Do you want to save (Y/N)? Y
    SQL> begin
      2    if '&do_save' in ('Y','y') then
      3      commit;
      4    else
      5      rollback;
      6    end if;
      7  end;
      8  /
    old   2:   if '&do_save' in ('Y','y') then
    new   2:   if 'Y' in ('Y','y') then
    PL/SQL procedure successfully completed.
    SQL> Edited by: Sven W. on Nov 17, 2008 4:53 PM

Maybe you are looking for