Non capisco il comportamento in questo caso. A mio avviso, una query con una sotto-query non valida dovrebbe generare un errore. Ma in questo esempio restituisce alcune righe.La query con sub-selezione interrotta dovrebbe generare un errore ma restituisce righe
Test-dati:
create table test_values (tst_id number, tst_id2 number, tst_value varchar2(10));
create table test_lookup (tst_id number, tst_value varchar2(10));
insert into test_values(tst_id, tst_id2, tst_value) values (1, 2, 'a');
insert into test_values(tst_id, tst_id2, tst_value) values (1, 2, 'b');
insert into test_values(tst_id, tst_id2, tst_value) values (2, 2,'c');
insert into test_values(tst_id, tst_id2, tst_value) values (2, 2,'d');
insert into test_lookup(tst_id, tst_value) values (1, 'findMe');
commit;
funziona come previsto:
select * from test_values where tst_id in (select tst_id from test_lookup where tst_value = 'findMe');
/*
TST_ID TST_ID2 TST_VALUE
---------- ---------- ----------
1 2 b
1 2 a
*/
select tst_id2 from test_lookup where tst_value = 'findMe';
--ORA-00904: "TST_ID2": invalid identifier
Ma la seguente query è anche recupero cime, ovviamente prendendo il -column "test_id2" dai "test_values" - tabella e non dalla tabella "test_lookup" come indicato nella sottoquery e sebbene NON utilizzi alias per le parti interne ed esterne.
select * from test_values where tst_id in (select tst_id2 from test_lookup where tst_value = 'findMe');
/*
TST_ID TST_ID2 TST_VALUE
---------- ---------- ----------
2 2 c
2 2 d
*/
@vmachan l'OP ha pubblicato un testcase completo, incluse le istruzioni create table e insert. Non sono sicuro di quali informazioni extra ti aspetti dall'OP da aggiungere alla loro domanda! – Boneist
Ho posto una domanda simile qui http://stackoverflow.com/questions/34774242/force-outer-select-to-fail-if-the-inner-select-taintain-an-invalid-identifier. Se stai chiedendo come modificare questo comportamento ... sembra che tu non possa. –
Sì. Questo usa il codice corretto (ma più lungo) e tutto va bene;) – evilive