pass parameter in sqlplus

Posted on 2011-04-27
Last Modified: 2012-05-11
The following command says TEST is not identified.  I use \oracle\ora92\BIN\sqlplus.exe  seems okay.  Thanks.

C:\oracle\10.2.0\BIN\sqlplus.exe -s user/password @c:\test.sql 'TEST'
Question by:ewang1205
    LVL 76

    Expert Comment

    by:slightwv (䄆 Netminder)
    Try TEST without the single quotes.

    Can you post the contents of test.sql so I can see what it is supposed to do with the parameter?
    LVL 28

    Accepted Solution

    i believe inside your test.sql, it should have been used like '&1' to refer to the passed parameter. If yes, then you just need to pause TEST and no need of quotes.

    if you parameter value has a space as well then try this :

    C:\oracle\10.2.0\BIN\sqlplus.exe -s user/password @c:\test.sql "TEST WORD"
    LVL 23

    Expert Comment

    - for instance you have more than 1 parameter,
    assuming test.sql contain:

    SELECT * FROM test
    WHERE test_id  = &1
    AND test_name = &2

    - you would execute it as follows, using comma to separate the values:
    SQL> @test.sql parameter1, parameter2
    C:\oracle\10.2.0\BIN\sqlplus.exe -s user/password @c:\test.sql 1,TEST

    Author Closing Comment

    Yes, Should be '&1' instead of &1.  Thanks.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Oracle Multiple Union 7 43
    need to improve Oracle query with multiple joins 14 51
    SAP and ODBC links 2 68
    how to tune this sql query 61 74
    Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
    How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
    This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
    This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now