Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6689795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:33:39+00:00 2026-05-26T05:33:39+00:00

What is the difference between these two variable declarations? 1: num number:=’&&num’; 2: variable

  • 0

What is the difference between these two variable declarations?

1: num number:='&&num';
2: variable num1 number;

Since in both cases I can reference num by using &num or &&num in other files also,
and in the case of bind variables :num1.

Moreover I have one more confusion: whether any of the below statements differ somehow, are they both valid and do they mean the same thing?

1: variable num1 number;
2: var num1 number;

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:33:40+00:00Added an answer on May 26, 2026 at 5:33 am

    You appear to have some confusion about the differences between bind variables in Oracle and substitution variables in SQL*Plus.

    Let’s start with substitution variables. Substitution variables are unique to SQL*Plus and are not part of the database. They won’t work if you try to use them with JDBC, for example.

    Substitution variables can only hold a piece of text. If SQL*Plus encounters a substitution variable in a line of input, it will replace the variable with its text contents:

    SQL> define subvar=X
    SQL> select * from dual where dummy = &subvar;
    old   1: select * from dual where dummy = &subvar
    new   1: select * from dual where dummy = X
    select * from dual where dummy = X
                                     *
    ERROR at line 1:
    ORA-00904: "X": invalid identifier
    

    Note that SQL*Plus replaced our substitution variable with its text value with no regard for whether it gave us valid SQL. In the example above, we omitted the single quotes around &subvar and it gave us invalid SQL, so we got an error.

    The lines beginning old and new show us the line we entered before and after SQL*Plus applied the substitution variables. The new line is the line the database tried to run.

    You can enable or disable the display of the old and new lines using SET VERIFY ON and SET VERIFY OFF. You can also turn the replacement of substitution variables on or off by using SET DEFINE ON and SET DEFINE OFF.

    If we want to run the above query using the substitution variable, we must put quotes around it:

    SQL> select * from dual where dummy = '&subvar';
    old   1: select * from dual where dummy = '&subvar'
    new   1: select * from dual where dummy = 'X'
    
    D
    -
    X
    

    If &subvar happens to contain a string that was a valid number (e.g. 5), then we can get away without using the quotes, but that’s only because taking out the text &subvar and replacing it with the text 5 happens to give us valid SQL.

    For example, suppose we have a table called test with the following data in it:

             A
    ----------
             1
             2
             3
             4
             5
    

    Then we can do

    SQL> define subvar=5
    SQL> select * from test where a = &subvar;
    old   1: select * from test where a = &subvar
    new   1: select * from test where a = 5
    
             A
    ----------
             5
    

    Bind variables, on the other hand, have types. They are not simple text values. Their values are sent to the database, and the database can also set their values.

    SQL> variable bindvar varchar2(1);
    SQL> exec :bindvar := 'X';
    
    PL/SQL procedure successfully completed.
    

    You don’t put quotes around a bind variable when you want to use it:

    SQL> select * from dual where dummy = :bindvar;
    
    D
    -
    X
    
    SQL> select * from dual where dummy = ':bindvar';
    
    no rows selected
    

    In the second example above, we got no rows returned because the DUAL table has no rows with the DUMMY column containing the text :bindvar.

    You’ll get an error if you attempt to assign a value of the wrong type to a bind variable:

    SQL> variable bindvar number;
    SQL> exec :bindvar := 'X';
    BEGIN :bindvar := 'X'; END;
    
    *
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    ORA-06512: at line 1
    

    Bind variables are a standard part of the database, and you can use them with JDBC or whichever method of connecting to the database you choose.


    Finally, variable num1 number and var num1 number both mean the same thing. They both define a bind variable num1 of type number. var is just an abbreviation for variable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone explain the difference between these two, the first one is taken from
What is the difference between these two forms of a string variable in C
Is there any difference between these two declarations? int x[10]; vs. int* x =
Can someone tell me the difference between these two versions of a declaration of
What is actually the difference between these two casts? SomeClass sc = (SomeClass)SomeObject; SomeClass
What is the difference between these two pieces of code type IInterface1 = interface
1)Is there any difference between these two keywords for the elements of collections??( Copy
Is there any difference between these two LINQ statements: var query = from a
What is the difference between these two: font-style:italic font-style:oblique I tried using the W3Schools
What is the difference between these two functions? 1: $(document).ready(function myfunc() { function dosomething()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.