Using Variable Declaration in Oracle

I have syntax problem when declaring in Oracle. I use these variables on an MS SQL server and they work great; However, how can I declare them in Oracle?

Use in MS SQL server:

DECLARE @FROM_DT DATETIME
DECLARE @END_DT  DATETIME
DECLARE @LOCATION  VARCHAR(100)

SET @FROM_DT = '04/01/2011'
SET @END_DT =  '05/09/2011'
SET  @LOCATION ='VA'
+3
source share
2 answers

You cannot declare variables outside the PL / SQL block.

The format of variable declarations inside a PL / SQL block is described in great detail in the manual (including examples):

http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/fundamentals.htm#CIHGGIAH

+4
source

You can pass variables to other sql files. This is not exactly what you want, but it helps me solve some problems without using blocks.

For the instance my config.sql file:

@drop.sql 'MY_USER'

my drop.sql file:

DROP USER "&1" CASCADE;
0
source

All Articles