Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2005

    Unanswered: I'm confused: Read a variable/prompt?

    Could someone please tell me how to run a sql script several times that takes a different variable each time. I don't have create procedure priviledges on my server so I can't write a procedure. So I was trying to do the prompt thing but I can't get it to work.

    So I want to select * from a table where column1 = some_variable.

    I put that select statement in a .sql file but i can't get the variable to go through. Please help Thanks a lot

  2. #2
    Join Date
    Jan 2004
    Croatia, Europe
    Provided Answers: 5
    Create the .SQL file as you already did (for example, "my_query.sql"), but use "&" in front of the variable. For example,

    SELECT ename FROM emp WHERE deptno = &department_number;

    Invoke it from the SQL prompt using

    SQL> @my_query

    and it'll ask you to enter variable value every time.

  3. #3
    Join Date
    Feb 2005
    Thanks a lot!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts