PL/SQL polecenie SQL niepoprawnie zakończone

0

declare
cursor c1 is select username from dba_users where username not in ('A', 'B', 'C') order by username;
users VARCHAR2(32000);
sel VARCHAR2(32000);

begin
for c_users in c1
loop
users := users||' '||c_users.username;
EXECUTE IMMEDIATE 'select count(),owner, object_type from dba_objects@dblinkk where owner ='||'c_users.username'|| 'group by owner, object_type
MINUS select count(
),owner, object_type from dba_objects where owner ='||'c_users.username'|| 'group by owner, object_type' INTO sel;
end loop;

users := SUBSTR(users, 2, LENGTH(users));
dbms_output.put_line('users:'||users);
end;
/

Wyświetla się error
ERROR at line 1:
ORA-00936: missing expression
ORA-06512: at line 12

ORA-00933:command not properly ended
ORA-06512: at line 12

1

Na szybko ... masz 3 kolumny w dynamicznym select ale masz tylko jedną zmienną into sel. Po drugie where owner ='||c_users.username bo jak rozumiem nazwę chcesz z kursora pobrać. Po trzecie formatuj kod będzie łatwiej ;)

2

Do tego co napisał @woolfik to:

  1. w selekcie masz count() a nie count(0)
  2. bez sensu używać do tego taska PL/SQLa i wykonywać zapytanie tyle razy ilu masz userów.

Wystaczy zwykły select.

select count(0) from (
  select count(0),uo.owner, uo.object_type from dba_objects@dblinkk uo, dba_users u where uo.username=u.username and u.username not in ('A','B','C') group by uo.owner, uo.object_type 
  MINUS 
  select count(0),uo.owner, uo.object_type from dba_objects uo, dba_users u where uo.username=u.username and u.username not in ('A','B','C') group by uo.owner, uo.object_type
);

1 użytkowników online, w tym zalogowanych: 0, gości: 1