Home > database >  Oracle DE address operator & usage in SQL
Oracle DE address operator & usage in SQL

Time:10-03

I want to write a SQL, use the address operator & amp; To SQL incoming parameters, such as:
Select * from TMP @ & amp; Lnka; (write it directly, can regard lnka as variables)
& LNK is a variable name, together with a, such as input 1, the effect is:
Select * from TMP @ 1 a.
How to write?

CodePudding user response:

Using dynamic SQL, perform before joining together into a specific name of the table or dblink name;

CodePudding user response:

SQL> Declare v_sql varchar2 (2000);
2 the begin
3 v_sql:='select * from TMP @' | | & amp; LNK | | 'a';
4 dbms_output. Put_line (' v_sql='| | v_sql);
5 the end;
6/
The value of the input LNK: 1
Original value of 3: v_sql:='select * from TMP @' | | & amp; LNK | | 'a';
The new value 3: v_sql:='select * from TMP @' | | 1 | | 'a';
V_sql=select * from TMP @ 1 a

CodePudding user response:

refer to the second floor sych888 response:
SQL> Declare v_sql varchar2 (2000);
2 the begin
3 v_sql:='select * from TMP @' | | & amp; LNK | | 'a';
4 dbms_output. Put_line (' v_sql='| | v_sql);
5 the end;
6/
The value of the input LNK: 1
Original value of 3: v_sql:='select * from TMP @' | | & amp; LNK | | 'a';
The new value 3: v_sql:='select * from TMP @' | | 1 | | 'a';
V_sql=select * from TMP @ 1 a
+ 1
  • Related