SQL * more: how to avoid asking them & 1?

I use a parameter within a SQL Script more to set a value for the creation of different environments.
DEFINE _env = '&1'
The parameter & 1 is used. However, a NULL value is allowed. But if this parameter is not defined, sql * more guests to enter something for & 1. How can we avoid this?

SQL use
sqlplus user/password@database @test_parameter.sql

SQL> exit

Verbunden mit:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options

"Geben Sie einen Wert f³r 1 ein:"

SQL> prompt Env&_env.
Env
SQL>
I'm looking for an easy way avoid the message < font color = "red" > "enter a value for 1:" < / police > if no parameter is added.
If a parameter is added, this message does not appear.
sqlplus user/password@database @test_parameter.sql _TST
example script
-- set environment 
------------------
-- Allowed values are 
-- "_DEV" = Development 
-- "_TST" = Test
-- "" = Production)
set verify off

DEFINE _env = '&1'

begin 
  if '&_env' is null 
    or regexp_like ('&_env', '_[[:alnum:]]{3}') then 
     null; --ok
  else
    raise_application_error(-20000,'Parameter 1 (''&_env'') has wrong value. Must start with _ and only 3 letters or be empty.' );
  end if;
end;
/

set echo on

prompt env&_env.
Published by: Sven w. March 15, 2012 16:40

When you want to call it "parameterless" give a string empty (two single quotes) like this:

sqlplus user/password@database @test_parameter.sql ''

Tags: Database

Similar Questions

  • SQL more how to stop script after the exception of the DDL

    Hello

    I have script .sql, which I managed by SQL * more.

    Some migration of data and database structure changes were made in the script.

    So, I use a lot of distinct calls:

    @script_name.sql

    @script_name_1.sql

    @script_name_2.sql

    ...

    Some of the scripts contains DDL as create table or column.

    contains some declare blocks (DML).

    Is it possible to stop the script after an exception has occurred?

    Thank you, Olga.

    Hi, Olga.

    You can use the SQL * more order

    WHENEVER SQLERROR EXIT

    to tell SQL * more to stop the execution of orders and immediately disconnect after any exception SQL is triggered.

    I don't know of anyway to stay connected, but to stop script execution, after an error.

  • How to avoid connecting them to Firefox whenever I open it?

    Firefox used to be signed whenever I opened it. Now it forces me to go through the entire Panel, including the password whenever I start it. How do you stay connected? When I connect, it goes to my correct home page. I just signed each time.

    Websites to remember you and automatically log you on are stored in a cookie.

    • Create a cookie exception allow (Tools > Options > privacy > Cookies: Exceptions) to keep such cookies, especially for sites Web secure and if the cookies expire when Firefox is closed.

    Make sure that you run not Firefox in private browsing mode.

    Do not use clear recent history to eliminate the 'Site preferences' and 'Cookies' as this does not take into account exceptions, but deletes all specified data.

    Compensation of the "Site Preferences" clears all exceptions for cookies, images, windows pop up, installation of software and passwords.

  • SQL * more: how string manipulation on the input parameter?

    Hi people,

    I will be grateful if you could help me create a sql (NOT a bash script!) script that uses a substring of the input parameter to a file name that will be rolled up into stuff.

    example:

    -sample.sql

    which can be used as:

    -$ sqlplus/nolog @sample.sql abcd_efgh

    and the script works similar to the pseudo-code below:

    "...

    file_name = 'test_ ' | substr ("& 1 ', 6)

    name of spool file

    ...

    spool off

    "

    Thank you

    Babak

    Hello

    I found a solution:

    "

    ...

    column new_value filename filename

    Select "test_". filename substr('&1',6)

    Double;

    coil & filename

    ...

    spool off

    ..."

  • How to avoid save them as?

    I've seen others ask this, but no one could provide an answer. Since I updated to the CD player, I always get a promt to save as instead of save just after highlighting or commenting on a file. I need the Save feature to replace my file excising without asking to save slot, because it's very uncomfortable to navigate to the location of the file every time I want to crush. Old version of the player doesn't have this annoying problem.

    I'm running win7 and tried to disable protected mode, but does not help. If I can't solve this problem, will have to use different pdf viewer.

    Allse,

    You must restart the CD player after you disable the protected mode. It's working for you now?

    Thank you

    -Bamboo

  • SQL * more: how to rest the password

    I'm trying to reset my password because I forgot... Currently, using SQL Plus 10.2.0.1.0

    Thank you

    Jason

    If the DB is in your laptop computer, call the sqlplus in the laptop itself and connect with / as sysdba. After which, you can reset the password of another user (for which you want to reset to the start) using

    alter user  identified by 
    

    Arun-

  • Office Jet Pro 8600 more - how to avoid the incoming faxes to print? Win 7

    I want faxes to store only on my computer. Where can I find the "cookie cutter" oumayma option after installing the software?

    Hello

    Sorry this feature works only when the printer is connected to a network (wired or wireless).

  • How to avoid resizing them only grow components

    Hello

    In my application using the latest Flex on WinXP, my components button resize well only when they have to grow. When I reduce the window, components do not reduce their size.

    The problem only occurs when I use a skin during Application. The contentGroup fails to reduce its size.

    Code of the skin:

    < s:Group id = "contentGroup.
    left = "15" right = "15" high = low "15" = "15" >
    < / s:Group >

    Application code:

    < s:layout >
    < s:VerticalLayout / >
    < / s:layout >

    < toolbar: ApplicationMainButtons id = "mainButtons" width = "100%" height = "11" / >

    Where would be the problem please?

    Kind regards

    Bernard

    MinWidth/minHeight on the components and containers you want to reduce the value

  • How to specify the instance in SQL * more command line?

    Hello

    I'm learning to Oracle. I currently have 2 instances of database running. I wanted to connect to one of the bodies and used the following command from the command line:
    sqlplus system as sysdba/abc123@ocp11gsid
    
    where 1234 is the password for the system user in the ocp11gsys instance.
    When I run the command above, SQL * more ask me the password. I do not understand why he asks me the password because I provided on the command line.

    What is the correct command line, so he asks me the password? (without defining the variable ORACLE_SID of environment - basically, I want to know how to specify the user, his password and sid, all in the sqlplus command line, without being prompted to enter the password that I mentioned.)

    Thank you for your help,

    John.

    John,

    This is how it works.

    E:\Documents and Settings\aristadba>sqlplus system/oracle as sysdba
    
    SQL*Plus: Release 11.2.0.1.0 Production on Mon Aug 2 22:49:25 2010
    
    Copyright (c) 1982, 2010, Oracle.  All rights reserved.
    
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    
    SQL>
    

    And now it ask the password,

    E:\Documents and Settings\aristadba>sqlplus system as sysdba/oracle
    
    SQL*Plus: Release 11.2.0.1.0 Production on Mon Aug 2 22:50:42 2010
    
    Copyright (c) 1982, 2010, Oracle.  All rights reserved.
    
    Enter password:
    
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    
    SQL>
    

    Spot the difference?

    The user name and password must unite. What you are to provide the password with the role where it will not be considered.

    Update
    I missed that part,

    What is the correct command line, so he asks me the password? (without defining the variable ORACLE_SID of environment - basically, I want to know how to specify the user, his password and sid, all in the sqlplus command line, without being prompted to enter the password that I mentioned.)

    The only thing that you can specify is the user name and password. The SID must be defined by you, either explicitly using the export or oraenv command if you are on the local system and do not use the TNS to connect to the instance. If you use the TNS, then an appropriate entry should be there which would connect to the required database.

    HTH
    Aman...

    Published by: Aman... on August 2, 2010 22:54

  • How to hide password when calling sql, more than command promt?

    When I try to open sql more in the window command prompt and enter the command sqlplus by chain of username/password@connection followed, the password is not masked.
    How do I show * instead of display characters of password out?

    Also, what is the command to clear the screen: when I try to cls or clears the screen, I get an exception memory windows of somekind and the only option he must kill the command window.

    Advice on her work around this?

    Thank you very much for your time and help.

    user8848256 wrote:
    Can you please give more details on how to do not enter a password when you call sqlplus command window, as you say?

    I tried this:

    sqlplus username / @connection string--> Hit Enter: request password, it does not recognize the connection string to connect to.

    sqlplus username /--> Hit Enter: it does same thing again.asks password but gives AMT error adapter after you have entered the password.

    Leave aside the slash:
    sqlplus username@connect_string

  • I downloaded Safari 10 and now every page that uses Java asks me to activate or not. How to avoid this new feature? I have problems to access my bank account.

    I downloaded Safari 10 and now every page that uses Java asks me to activate or not. How to avoid this new feature? I have problems to access my bank account.

    I think they mean JavaScript.

    In your Safari menu bar, click Safari > Preferences and then select the Security tab, and then select: Enable JavaScript

  • Database demo of vision: how to access the database through SQL * more?

    I'm totally new in this space, so forgive my beginner questions.

    What I want to do, is to integrate EBS with APEX. To get there I downloaded (of delivery) and installed the Vision database unique node in a VirtualBox. To do this, I followed this video on YouTube: https://www.youtube.com/watch?v=8JgxMDPsd6s

    Now I want to install APEX and for this I need to access my database as SYS. Now for my questions:

    1. How can I use SQL * more in the VirtualBox?

    2. What is the default password for SYS with this demo database?

    Thanks, Alex

    File under $ORACLE_HOME and the owner is the user 'oracle '.

    You will need to source the file VISION_ebs.env , and then deliver "env | fate"and you should see the set env variables. You can connect as sysdba.

    Thank you

    Hussein

  • How to add timestamp to log file in SQL * more?

    Version: 11.2.0.3
    Platform: RHEL 5.8 (but I'm looking for a solution that is independent of the platform)


    I want to add the timestamp file name of the log queued in SQL * more.
    The name of the queued log file should look like
    WMS_APP_23-March-2013.log
    I tried the 3 following methods found in the google. But none of them worked!


    I tried this
    col sysdt noprint new_value sysdt_var
    SELECT TO_CHAR(SYSDATE, 'yyyymmdd_hh24miss') sysdt FROM DUAL;
    spool run_filename_&sysdt_var.Log
    as suggested in
    http://power2build.WordPress.com/2011/03/11/sqlplus-spool-name-with-embedded-timestamp/

    and this
    spool filename with timestamp
    col sysdt noprint new_value sysdt
    SELECT TO_CHAR(SYSDATE, 'yyyymmdd_hh24miss') sysdt FROM DUAL;
    spool run_filename_&sysdt..Log
    as suggested in

    http://powerbuildev.WordPress.com/2011/03/11/sqlplus-spool-name-with-embedded-timestamp/


    and this
    column tm new_value file_time noprint
    select to_char(sysdate, 'YYYYMMDD') tm from dual ;
    prompt &file_time
    spool logfile_id&file_time..log
    as suggested in
    Creating a queue with date/time added file name



    None of these worked in RHEL or MS DOS. No work around?

    You are explicitly turned off the replacement of the variables of substitution with the statement "all set."
    http://docs.Oracle.com/CD/E11882_01/server.112/e16604/ch_eight.htm
    "SET DEFINE OFF disables the analysis of orders to replace variables with their values substitution."

  • How to get SQL * more to connect to my database of Apex?

    How can I get SQL * more to connect to my database of Apex? By using the username and password I use to connect to Apex does not (ORA-01017). What should I do to connect to my db Apex?

    Thank you
    Kim

    Connection string is "connect username/password@database".

    The analysis schema is a database account, that's why you can log on to SQL * more like that.

    This allows to get the database name

    select instance_name from v$instance;
    

    And if you forgot the password for the PT

    alter user PT identified by 'your_new_password';
    

    Scott

  • How to avoid performance issues in PL/SQL?

    How to avoid performance issues in PL/SQL?

    According to my knowledge, below a few points to avoid performance problems in PL/SQL.
    Is there any other point to avoid performance problems?

    1. use FORALL instead of the FORUM and GATHER in BULK to avoid a loop several times.
    2. RUN IMMEDIATE is faster than DBMS_SQL
    3. use NOCOPY for OUT and IN OUT if the original value need not be retained. Overhead of keeping a copy of OUT is avoided.

    Thanks for your comments Justin!

    BC explains things right on part SQL...

    http://www.DBA-Oracle.com/art_sql_tune.htm

Maybe you are looking for