I
I
Illarion Labahua2018-09-13 16:59:19
Oracle
Illarion Labahua, 2018-09-13 16:59:19

How to declare variables in a simple sql query?

Hello query: insert into MY_TABLE_TAB ( Col1
, Col2, Col3) Values ​​(:Param1, :Param2, :Param3)
something like this:
param1 = 123
param2 = 234
param3 = 345
We are talking about the execution in Oracle SQL Developer, not PL/SQL,

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
ISE73, 2018-09-13
@ISE73

DECLARE
   param1 NUMBER := 123;
   param2 NUMBER := 234;
   param3 NUMBER := 345;
BEGIN
     insert into MY_TABLE_TAB (Col1, Col2, Col3) Values (:param1, :param2, :param3)
END;

P
ponaehal, 2018-09-13
@ponaehal

It is necessary to speak about variables in the context of the development environment in which you plan to execute the request. If we talk about SQLPlus, then something like this (slammed from SQL.ru):

SET DEFINE "&"
VAR db_name VARCHAR2(30)
COLUMN db_name NEW_VALUE db_name
EXEC :db_name := 'Blah';
SELECT :db_name AS db_name FROM dual;
DEFINE db_name

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question