Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
Can Variables Be Used in SQL Statements
Can Variables Be Used in SQL Statements? - Oracle DBA FAQ - Working with Database Objects in PL/SQL
✍: FYIcenter.com
Yes, you can use variables in SQL statements as part of any expressions. The tutorial script provides you some good examples:
(Connect to XE with SQL*Plus)
CREATE TABLE student (id NUMBER(5) PRIMARY KEY,
first_name VARCHAR(80) NOT NULL,
last_name VARCHAR(80) NOT NULL);
Table created.
DECLARE
var_id NUMBER;
var_name CHAR(10);
BEGIN
var_id := 29;
var_name := 'Bob';
INSERT INTO student VALUES(var_id, var_name, 'Henry');
var_name := 'Joe';
INSERT INTO student VALUES(var_id+1, var_name, 'Bush');
var_name := 'Fyi';
UPDATE student SET first_name = var_name
WHERE id = var_id+1;
DELETE FROM student WHERE id = var_id;
END;
/
SELECT * FROM student;
ID FIRST_NAME LAST_NAME
-------- ----------- -----------
30 Fyi Bush
2007-04-28, 4956👍, 0💬
Popular Posts:
Where are all .NET Collection classes located ? System.Collection namespace has all the collection c...
If client side validation is enabled in your Web page, does that mean server side code is not run? W...
What is Native Image Generator (Ngen.exe)? The Native Image Generator utility (Ngen.exe) allows you ...
What are the types of variables x, y, y and u defined in the following code? #define Atype int* type...
Explain simple Walk through of XmlReader ? In this section we will do a simple walkthrough of how to...