Search results
SELECT my_column INTO the_variable FROM my_table; END; Make sure that the query only returns a single row: By default, a SELECT INTO statement must return only one row. Otherwise, PL/SQL raises the predefined exception TOO_MANY_ROWS and the values of the variables in the INTO clause are undefined.
There are a several ways of declaring variables in SQL*Plus scripts. The first is to use VAR, to declare a bind variable. The mechanism for assigning values to a VAR is with an EXEC call: SQL> var name varchar2(20) SQL> exec :name := 'SALES' PL/SQL procedure successfully completed.
5 lip 2011 · This worked for me in Toad for Oracle when using any of these functions: Execute as script or Execute via Toad script runner or Execute via SQL*Plus. However, if you try running with the Execute/compile statement at caret it returns an error message: "ORA-009000: invalid SQL statement".
15 wrz 2014 · I tried your PL/SQL with Substitution variables example and I get an error message that says ORA-01008: not all variables bound. I got the same error message with your other two examples.
If you want to use the value of a bind variable in a SQL*Plus command, it must first be copied to a substitution variable. SQL*Plus commands such as SPOOL, SET and TTITLE are executed in the SQL*Plus program and are not passed to the database for execution.
This Oracle tutorial explains how to declare variables in Oracle / PLSQL with syntax and examples. In Oracle / PLSQL, a variable allows a programmer to store data temporarily during the execution of code.
11 kwi 2011 · This post shows how substitution variables can replace hard-coded text in Oracle SQL and SQL*Plus statements. Jump straight to the Substitution Variable Examples if you don't have time to read this whole post, and are trying to solve a specific problem using variables in SQL statements in SQL*Plus.