powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Oracle [игнор отключен] [закрыт для гостей] / Oracle Database 12c. Новые возможности языка SQL
25 сообщений из 234, страница 6 из 10
Oracle Database 12c. Новые возможности языка SQL
    #38339156
stax..
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Валерий Юринский, допускаются ли вложенные аналитилуские ф-ции

Код: plsql
1.
2.
3.
4.
5.
6.
7.
8.
9.
select e.*
 ,sum (
    (case when lag(sal,1,sal) over (order by empno) >= sal then 1 else 0 end)) 
  over (order by empno) gr 
from emp e order by empno
/

ERROR at line 2:
ORA-30483: window  functions are not allowed here


....
stax
...
Рейтинг: 0 / 0
Oracle Database 12c. Новые возможности языка SQL
    #38340403
antonelly
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
А вот такие запросы работают в 12c:

select * from country co where not exists ( select 1 from city where state_id in (select state_id from state where country_id=co.country_id))

Те с кореллированным подзапросом двойной и более вложенности
...
Рейтинг: 0 / 0
Oracle Database 12c. Новые возможности языка SQL
    #38340434
stax..
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
antonellyА вот такие запросы работают в 12c:

select * from country co where not exists ( select 1 from city where state_id in (select state_id from state where country_id=co.country_id))

Те с кореллированным подзапросом двойной и более вложенности
Код: plsql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
SQL> create table kountry (country_id int,n varchar2(10));

Table created.

SQL> create table sity(sity_id int,state_id int,n varchar2(10));

Table created.

SQL> create table state (state_id int,country_id int,n varchar2(10));

Table created.

SQL> select * from country co where not exists ( select 1 from city where
  2  .
SQL> ed
Wrote file afiedt.buf

  1  select * from kountry co where not exists
  2  ( select 1 from sity where state_id in
  3*  (select state_id from state where country_id=co.country_id))
SQL> /

no rows selected



.....
stax
...
Рейтинг: 0 / 0
Oracle Database 12c. Новые возможности языка SQL
    #38340492
ten
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
antonelly,
Код: plsql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
SQL> select * from v$version;

BANNER                                                                          
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production          
PL/SQL Release 11.2.0.2.0 - Production                                          
CORE	11.2.0.2.0	Production                                                      
TNS for Linux: Version 11.2.0.2.0 - Production                                  
NLSRTL Version 11.2.0.2.0 - Production                                          

SQL> drop table my_dual;

Таблица удалена.

SQL> create table my_dual as select * from dual;

Таблица создана.

SQL> select *
  2    from my_dual co
  3   where exists
  4  	(select 1
  5  	   from my_dual d1
  6  	  where d1.dummy in (select d2.dummy
  7  			       from my_dual d2
  8  			      where d2.dummy = co.dummy));

D                                                                               
-                                                                               
X                                                                               

SQL> spool off
...
Рейтинг: 0 / 0
Oracle Database 12c. Новые возможности языка SQL
    #38340496
ten
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
stax..,
Станислав, скорость интернета возросла? :)
...
Рейтинг: 0 / 0
Oracle Database 12c. Новые возможности языка SQL
    #38340758
stax..
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
tenstax..,
Станислав, скорость интернета возросла? :)
нет, просто ето больной вопрос для меня

как грил Елік, on line view не может быть коррелированным

Код: plsql
1.
2.
3.
4.
5.
6.
7.
8.
9.
  1  select d.dummy from dual d where exists
  2     (select decode(d2.dummy,d4.dummy,'X') x
  3      from dual d2,(select * from dual d3 where d3.dummy= /*'X'*/ d.dummy )d4
  4*    )
SQL> /
    from dual d2,(select * from dual d3 where d3.dummy= /*'X'*/ d.dummy )d4
                                                                *
ERROR at line 3:
ORA-00904: "D"."DUMMY": invalid identifier



......
stax
...
Рейтинг: 0 / 0
Oracle Database 12c. Новые возможности языка SQL
    #38340773
Фотография suPPLer
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
stax..on line view не может быть коррелированным

Точности ради: in line.
...
Рейтинг: 0 / 0
Oracle Database 12c. Новые возможности языка SQL
    #38340787
stax..
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
suPPLerstax..on line view не может быть коррелированным

Точности ради: in line.
конешо in line
сори за мой бед инглиш (да и русиш), но я стараюсь

.....
stax
...
Рейтинг: 0 / 0
Oracle Database 12c. Новые возможности языка SQL
    #38340817
Фотография Sacramento
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
autonellyА вот такие запросы работают в 12c:
Код: plsql
1.
select 1 from dual d1 where 1 in (select 1 from dual d2 join dual d3 on d1.dummy = d3.dummy)

Подпишешсо за старое доброе?
...
Рейтинг: 0 / 0
Oracle Database 12c. Новые возможности языка SQL
    #38340831
wurdu
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
stax..tenstax..,
Станислав, скорость интернета возросла? :)
нет, просто ето больной вопрос для меня

как грил Елік, on line view не может быть коррелированным

Код: plsql
1.
2.
3.
4.
5.
6.
7.
8.
9.
  1  select d.dummy from dual d where exists
  2     (select decode(d2.dummy,d4.dummy,'X') x
  3      from dual d2,(select * from dual d3 where d3.dummy= /*'X'*/ d.dummy )d4
  4*    )
SQL> /
    from dual d2,(select * from dual d3 where d3.dummy= /*'X'*/ d.dummy )d4
                                                                *
ERROR at line 3:
ORA-00904: "D"."DUMMY": invalid identifier



......
staxА как же Using Lateral Inline Views: Example
...
Рейтинг: 0 / 0
Oracle Database 12c. Новые возможности языка SQL
    #38340845
Фотография orawish
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
SacramentoautonellyА вот такие запросы работают в 12c:
Код: plsql
1.
select 1 from dual d1 where 1 in (select 1 from dual d2 join dual d3 on d1.dummy = d3.dummy)

Подпишешсо за старое доброе?

Код: plsql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
Присоединен к:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing opt
ions

SQL> select 1 from dual d1
  2   where 1 in (select 1 from dual d2 join dual d3 on d1.dummy = d3.dummy);

         1
----------
         1
...
Рейтинг: 0 / 0
Oracle Database 12c. Новые возможности языка SQL
    #38340861
stax..
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
wurdustax..пропущено...

нет, просто ето больной вопрос для меня

как грил Елік, on line view не может быть коррелированным

Код: plsql
1.
2.
3.
4.
5.
6.
7.
8.
9.
  1  select d.dummy from dual d where exists
  2     (select decode(d2.dummy,d4.dummy,'X') x
  3      from dual d2,(select * from dual d3 where d3.dummy= /*'X'*/ d.dummy )d4
  4*    )
SQL> /
    from dual d2,(select * from dual d3 where d3.dummy= /*'X'*/ d.dummy )d4
                                                                *
ERROR at line 3:
ORA-00904: "D"."DUMMY": invalid identifier



......
staxА как же Using Lateral Inline Views: Example

імхо, Lateral немножко не то, вот если б
from dual d2,(select * from dual d3 where d3.dummy= d2 .dummy )d4


.....
stax
...
Рейтинг: 0 / 0
Oracle Database 12c. Новые возможности языка SQL
    #38340869
Фотография Валерий Юринский
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
stax..как грил Елік, inline view не может быть коррелированным Все меняется... :-)

query_table_expression ::=

query_table_expression -> LATERAL LATERAL Specify LATERAL to designate subquery as a lateral inline view. Within a
lateral inline view, you can specify tables that appear to the left of the lateral inline
view in the FROM clause of a query. You can specify this left correlation anywhere
within subquery (such as the SELECT, FROM, and WHERE clauses) and at any nesting level.

Restrictions on LATERAL: Lateral inline views are subject to the following
restrictions:
If you specify LATERAL, then you cannot specify the pivot_clause, the unpivot_
clause, or a pattern in the table_reference clause.

If a lateral inline view contains the query_partition_clause, and it is the right
side of a join clause, then it cannot contain a left correlation to the left table in the
join clause. However, it can contain a left correlation to a table to its left in the FROM
clause that is not the left table.

A lateral inline view cannot contain a left correlation to the first table in a right
outer join or full outer join.

Using Lateral Inline Views: Example The following example shows a join with two
operands. The second operand is an inline view that specifies the first operand, table e,
in the WHERE clause. This results in an error.
Код: plsql
1.
2.
3.
SELECT * FROM employees e, (SELECT * FROM departments d
WHERE e.department_id = d.department_id);
ORA-00904: "E"."DEPARTMENT_ID": invalid identifier


The following example shows a join with two operands. The second operand is a
lateral inline view that specifies the first operand, table e, in the WHERE clause and
succeeds without an error.
Код: plsql
1.
2.
SELECT * FROM employees e, LATERAL (SELECT * FROM departments d
WHERE e.department_id = d.department_id);


Выполнение примеров в SQL*Plus
Код: plsql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
SQL*Plus: Release 11.2.0.3.0 Production on Tue Jul 23 16:29:51 2013
Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> SELECT *
  2  FROM employees e
  3     , (SELECT * FROM departments d
  4        WHERE e.department_id = d.department_id);
      WHERE e.department_id = d.department_id)
            *
ERROR at line 4:
ORA-00904: "E"."DEPARTMENT_ID": invalid identifier

SQL> SELECT COUNT(*), max(department_name) AS max_dname
  2  FROM employees e
  3     , LATERAL (SELECT * FROM departments d
  4                WHERE e.department_id = d.department_id);

  COUNT(*) MAX_DNAME
---------- ------------------------------
       106 Shipping


...
Рейтинг: 0 / 0
Oracle Database 12c. Новые возможности языка SQL
    #38340917
stax..
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Валерий Юринскийstax..как грил Елік, inline view не может быть коррелированным Все меняется... :-)

query_table_expression ::=

query_table_expression -> LATERAL LATERAL Specify LATERAL to designate subquery as a lateral inline view. Within a
lateral inline view, you can specify tables that appear to the left of the lateral inline
view in the FROM clause of a query. You can specify this left correlation anywhere
within subquery (such as the SELECT, FROM, and WHERE clauses) and at any nesting level.

Restrictions on LATERAL: Lateral inline views are subject to the following
restrictions:
If you specify LATERAL, then you cannot specify the pivot_clause, the unpivot_
clause, or a pattern in the table_reference clause.

If a lateral inline view contains the query_partition_clause, and it is the right
side of a join clause, then it cannot contain a left correlation to the left table in the
join clause. However, it can contain a left correlation to a table to its left in the FROM
clause that is not the left table.

A lateral inline view cannot contain a left correlation to the first table in a right
outer join or full outer join.

Using Lateral Inline Views: Example The following example shows a join with two
operands. The second operand is an inline view that specifies the first operand, table e,
in the WHERE clause. This results in an error.
Код: plsql
1.
2.
3.
SELECT * FROM employees e, (SELECT * FROM departments d
WHERE e.department_id = d.department_id);
ORA-00904: "E"."DEPARTMENT_ID": invalid identifier


The following example shows a join with two operands. The second operand is a
lateral inline view that specifies the first operand, table e, in the WHERE clause and
succeeds without an error.
Код: plsql
1.
2.
SELECT * FROM employees e, LATERAL (SELECT * FROM departments d
WHERE e.department_id = d.department_id);


Выполнение примеров в SQL*Plus
Код: plsql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
SQL*Plus: Release 11.2.0.3.0 Production on Tue Jul 23 16:29:51 2013
Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> SELECT *
  2  FROM employees e
  3     , (SELECT * FROM departments d
  4        WHERE e.department_id = d.department_id);
      WHERE e.department_id = d.department_id)
            *
ERROR at line 4:
ORA-00904: "E"."DEPARTMENT_ID": invalid identifier

SQL> SELECT COUNT(*), max(department_name) AS max_dname
  2  FROM employees e
  3     , LATERAL (SELECT * FROM departments d
  4                WHERE e.department_id = d.department_id);

  COUNT(*) MAX_DNAME
---------- ------------------------------
       106 Shipping



туплю я, імхо ето немножко не то, как мой тестик будет выглядить с LATERAL (мне понятно если поле с D2)?
Код: plsql
1.
2.
3.
4.
5.
select d.dummy from dual d where exists
   (select decode(d2.dummy,d4.dummy,'X') x
    from dual d2,LATERAL(select * from dual d3 where d3.dummy= /*'X'*/ d.dummy ))d4
   )
/



.....
stax
...
Рейтинг: 0 / 0
Oracle Database 12c. Новые возможности языка SQL
    #38340921
Фотография Валерий Юринский
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
stax..Валерий Юринский, допускаются ли вложенные аналитилуские ф-ции
Код: plsql
1.
2.
3.
4.
5.
6.
7.
8.
9.
select e.*
 ,sum (
    (case when lag(sal,1,sal) over (order by empno) >= sal then 1 else 0 end)) 
  over (order by empno) gr 
from emp e order by empno
/

ERROR at line 2:
ORA-30483: window  functions are not allowed here


Нек, не докускаются :-)
ORA-30483: window functions are not allowed here
Код: plsql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production

SQL> select e.*
  2   ,sum (
  3      (case when lag(sal,1,sal) over (order by empno) >= sal then 1 else 0 en
d))
  4    over (order by empno) gr
  5  from emp e order by empno;
    (case when lag(sal,1,sal) over (order by empno) >= sal then 1 else 0 end))
               *
ERROR at line 3:
ORA-30483: window  functions are not allowed here

...
Рейтинг: 0 / 0
Oracle Database 12c. Новые возможности языка SQL
    #38340926
stax..
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
1259Валерий Юринский,
как насчет вложенных аналит. ф-ций? 14599470

.....
stax
...
Рейтинг: 0 / 0
Oracle Database 12c. Новые возможности языка SQL
    #38340934
Фотография Валерий Юринский
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
stax..туплю я, імхо ето немножко не то, как мой тестик будет выглядить с LATERAL (мне понятно если поле с D2)?
Код: plsql
1.
2.
3.
4.
5.
select d.dummy from dual d where exists
   (select decode(d2.dummy,d4.dummy,'X') x
    from dual d2,LATERAL(select * from dual d3 where d3.dummy= /*'X'*/ d.dummy ))d4
   )
/


Код: plsql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production

SQL> select d.dummy
  2  from dual d
  3  where exists
  4     (select decode(d2.dummy, d4.dummy, 'X') x
  5      from dual d2
  6         , LATERAL (select * from dual d3
  7                    where d3.dummy= /*'X'*/ d.dummy ) d4)
  8  ;

D
-
X

Лишнюю скобку убрал правильно? (выделено малиновым)
...
Рейтинг: 0 / 0
Oracle Database 12c. Новые возможности языка SQL
    #38340937
Фотография Валерий Юринский
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
stax..1259Валерий Юринский,
как насчет вложенных аналит. ф-ций? 14599470
Нет, не допускаются. (см. выше)
...
Рейтинг: 0 / 0
Oracle Database 12c. Новые возможности языка SQL
    #38340988
stax..
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Валерий Юринскийstax..туплю я, імхо ето немножко не то, как мой тестик будет выглядить с LATERAL (мне понятно если поле с D2)?
Код: plsql
1.
2.
3.
4.
5.
select d.dummy from dual d where exists
   (select decode(d2.dummy,d4.dummy,'X') x
    from dual d2,LATERAL(select * from dual d3 where d3.dummy= /*'X'*/ d.dummy ))d4
   )
/


Код: plsql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production

SQL> select d.dummy
  2  from dual d
  3  where exists
  4     (select decode(d2.dummy, d4.dummy, 'X') x
  5      from dual d2
  6         , LATERAL (select * from dual d3
  7                    where d3.dummy= /*'X'*/ d.dummy ) d4)
  8  ;

D
-
X

Лишнюю скобку убрал правильно? (выделено малиновым)
Да, дописывая LATERAL автоматом скобочку добавил
спасибо за тесты, жалко що нельзя вложенные аналит ф-ции

зы
без LATERAL запрос слетает?

......
stax
...
Рейтинг: 0 / 0
Oracle Database 12c. Новые возможности языка SQL
    #38341164
Фотография Валерий Юринский
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
stax..зы
без LATERAL запрос слетает?
Нет, не слетает.
Работает и без LATERAL:
Код: plsql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production

SQL> select d.dummy from dual d where exists
  2     (select decode(d2.dummy,d4.dummy,'X') x
  3      from dual d2
  4         , (select * from dual d3 where d3.dummy= /*'X'*/ d.dummy )d4
  5     )
  6  ;

D
-
X
...
Рейтинг: 0 / 0
Oracle Database 12c. Новые возможности языка SQL
    #38341230
stax..
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Валерий Юринскийstax..зы
без LATERAL запрос слетает?
Нет, не слетает.
Работает и без LATERAL:
Код: plsql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production

SQL> select d.dummy from dual d where exists
  2     (select decode(d2.dummy,d4.dummy,'X') x
  3      from dual d2
  4         , (select * from dual d3 where d3.dummy= /*'X'*/ d.dummy )d4
  5     )
  6  ;

D
-
X



я подозревал что не слетит, мне кажется что для exists LATERAL не очень походит

.....
stax
...
Рейтинг: 0 / 0
Oracle Database 12c. Новые возможности языка SQL
    #38341255
Фотография SY
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
stax..я подозревал что не слетит, мне кажется что для exists LATERAL не очень походит


Не путай correlated subquery и lateral in-line view:


Код: plsql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
SQL> select d.dummy from dual d where exists
  2     (select decode(d2.dummy,d4.dummy,'X') x
  3      from dual d2
  4         , (select * from dual d3 where d3.dummy= /*'X'*/ d.dummy )d4 -- works, since d3 is correlated to d
  5     )
  6  /

D
-
X

SQL> select d.dummy from dual d where exists
  2     (select decode(d2.dummy,d4.dummy,'X') x
  3      from dual d2
  4         , (select * from dual d3 where d3.dummy= /*'X'*/ d2.dummy )d4 -- fails, since d3 is neither correlated nor lateral to d2
  5     )
  6  /
       , (select * from dual d3 where d3.dummy= /*'X'*/ d2.dummy )d4 -- fails, since d3 is neither correlated nor lateral to d2                                                        *
ERROR at line 4:
ORA-00904: "D2"."DUMMY": invalid identifier


SQL> select d.dummy from dual d where exists
  2     (select decode(d2.dummy,d4.dummy,'X') x
  3      from dual d2
  4         , LATERAL(select * from dual d3 where d3.dummy= /*'X'*/ d2.dummy )d4 -- works, since d3 is lateral to d2
  5     )
  6  /

D
-
X

SQL>



SY.
...
Рейтинг: 0 / 0
Oracle Database 12c. Новые возможности языка SQL
    #38341275
Фотография Валерий Юринский
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
SY,

А как вы перевели бы LATERAL на русский?

Спасибо!
...
Рейтинг: 0 / 0
Oracle Database 12c. Новые возможности языка SQL
    #38341289
Фотография SY
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Валерий ЮринскийSY,

А как вы перевели бы LATERAL на русский?


Трудно сказать, может "боковой"?

SY.
...
Рейтинг: 0 / 0
Oracle Database 12c. Новые возможности языка SQL
    #38341300
Фотография SY
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
SYТрудно сказать, может "боковой"?


То есть добавить слово боковой к русскому переводу термина in-line view.

SY.
...
Рейтинг: 0 / 0
25 сообщений из 234, страница 6 из 10
Форумы / Oracle [игнор отключен] [закрыт для гостей] / Oracle Database 12c. Новые возможности языка SQL
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]