How do I run a GET statement after importing a SQL script in SQL*Plus?

0
1
Asked By TechieTurtle88 On

I'm really struggling with my SQL class, and I'm stuck on a specific task. I need to load an SQL script I saved into my current SQL*Plus session. The task requires naming the column headings as Emp #, Employee, Job, and Hire Date when I re-run the query. The script I have is: `SELECT empno, ename, job, hiredate FROM emp;`. It seems like the command `@ C:UsersfakenameDesktopp1q7.txt` works perfectly as it loads and displays the correct output table. However, I'm confused about how to run the GET statement after I've imported this script. I attempted to use the RUN command right after the GET statement but ended up getting an error message saying "SQL command not properly ended". I don't know what else to try, and my professor hasn't been any help!

3 Answers

Answered By CodeNinja92 On

When you use `@ filename.sql`, it directly executes the script. However, the `GET` command only loads the script into the buffer without executing it. To actually run the loaded SQL statement, just type `/` (a slash) on a new line or use the `RUN` command by itself. Make sure there are no stray semicolons or formatting issues, as that could cause errors.

Answered By DevGuru45 On

If you haven't made any changes yet, try running the script directly first, and then examine what it shows when you type `RUN`. It should mirror the original command from your file. If it’s exactly as you wrote (the SELECT statement), there shouldn’t be any issues running it. Let's debug this!

Answered By SQLWizard99 On

It sounds like you might have some invalid syntax in the changes you made. The `RUN` command should show the SQL statement from the buffer before executing it. Can you check what it displays? If it’s the same as the script and still doesn’t work, let me know what’s showing up.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.