简体   繁体   中英

Usage of && to pass same value to variable in Oracle SQL query

I have below script where I have to pass same OWNER and TABLE_NAME values twice times. Instead I am trying use '&&' like mentioned at https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:818426831007

But wondering why it is not working for below query

SELECT table_name, round (SUM(bytes)/1024/1024/1024, 2) AS "Total Size"
FROM (SELECT s.segment_name AS table_name, s.bytes
FROM dba_SEGMENTS s
          WHERE s.segment_name IN
                   ('&&table_name')
                    and s.owner='&&owner'
UNION
         SELECT l.table_name AS table_name, s.bytes
           FROM dba_SEGMENTS s, dba_lobs l
          WHERE s.segment_name = l.segment_name AND l.owner = '&owner'
                AND l.table_name IN
                       ('&table_name'))
GROUP BY table_name;

It is working. I am using SQL*PLUS. I had to restart my session cause I already passed some values to these variables when I was working around with the script. Thanks everyone. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM