Solved

Error Creating View:  ORA-00933: SQL command not properly ended

Posted on 2008-06-13
3
1,124 Views
Last Modified: 2008-09-13
Hi all,

I have a view I am trying to create using TOAD, or SQL Plus for that matter.  I get the error message:  Error Creating View:  ORA-00933: SQL command not properly ended  If I just run the select statement, it works fine.  Please help!!!

Here is the full code:

CREATE VIEW APPS.REPORTS_EMPLOYEECLOCK
AS
SELECT p2.full_name, p.full_name, sum(t.clock), sum(t.pay), sum(t.labor) from (select distinct person_id, full_name from hr.per_all_people_f where current_employee_flag = 'Y') p, hr.per_all_assignments_f a, (select distinct person_id, full_name, person_type_id from hr.per_all_people_f where current_employee_flag = 'Y') p2, (select c.person_id, c.time_in, nvl(c.total_hours,0) as clock, nvl(c.supervisor_hours,0) as pay, sum(nvl(l.break_adjusted_time_out - l.time_in,0)*24) as labor from ctl.timeclock_clock_card c, ctl.timeclock_labor_card l where c.person_id = l.person_id(+) and l.time_in(+) between c.time_in and c.time_out group by c.person_id, c.time_in, c.total_hours, c.supervisor_hours) t where t.person_id = p.person_id and t.person_id = a.person_id(+) and a.supervisor_id = p2.person_id(+) group by p2.full_name, p.full_name order by p2.full_name, p.full_name;
0
Comment
Question by:jwebster77
3 Comments
 
LVL 16

Expert Comment

by:Richard Olutola
ID: 21779808
Perhaps if you format your code better you may be able to see where the problem lies. I don't know your logic so only you can check for logical errors.

See the following as my interpretation of what you're trying to do and see if it's the wrong idea:


CREATE VIEW APPS.REPORTS_EMPLOYEECLOCK

AS

SELECT 

	p2.full_name, 

	p.full_name, 

	sum(t.clock), 

	sum(t.pay), 

	sum(t.labor) 

from (select 

		distinct person_id, 

		full_name 

	from hr.per_all_people_f 

	where current_employee_flag = 'Y') p, 

		hr.per_all_assignments_f a, 

		(select 

			distinct person_id, 

			full_name, 

			person_type_id 

		from hr.per_all_people_f 

		where current_employee_flag = 'Y') p2, 

			(select c.person_id, 

				c.time_in, 

				nvl(c.total_hours,0) as clock, 

				nvl(c.supervisor_hours,0) as pay, 

				sum(nvl(l.break_adjusted_time_out - l.time_in,0)*24) as labor 

			from ctl.timeclock_clock_card c, 

				ctl.timeclock_labor_card l 

			where c.person_id = l.person_id(+) 

				and l.time_in(+) between c.time_in 

				and c.time_out 

			group by c.person_id, c.time_in, c.total_hours, c.supervisor_hours) t 

where t.person_id = p.person_id 

	and t.person_id = a.person_id(+) 

	and a.supervisor_id = p2.person_id(+) group by p2.full_name, p.full_name 

order by p2.full_name, p.full_name;

Open in new window

0
 
LVL 4

Expert Comment

by:jtrifts
ID: 21785454
Does the DML work without the "APPS." prefix?
i.e.
CREATE VIEW REPORTS_EMPLOYEECLOCK
AS
SELECT p2.full_name
, p.full_name
, sum(t.clock)
, sum(t.pay)
, sum(t.labor)
from (select distinct person_id
                   , full_name
         from hr.per_all_people_f
         where current_employee_flag = 'Y') p
, hr.per_all_assignments_f a
, (select distinct person_id
              , full_name
              , person_type_id
   from hr.per_all_people_f
   where current_employee_flag = 'Y') p2
, (select c.person_id
             , c.time_in
              , nvl(c.total_hours,0) as clock
              , nvl(c.supervisor_hours,0) as pay
              , sum(nvl(l.break_adjusted_time_out - l.time_in,0)*24) as labor
   from ctl.timeclock_clock_card c
         , ctl.timeclock_labor_card l
   where c.person_id = l.person_id(+)
   and l.time_in(+) between c.time_in and c.time_out
   group by c.person_id, c.time_in, c.total_hours, c.supervisor_hours) t
where t.person_id = p.person_id
and t.person_id = a.person_id(+)
and a.supervisor_id = p2.person_id(+)
group by p2.full_name, p.full_name
order by p2.full_name, p.full_name;
0
 

Accepted Solution

by:
jwebster77 earned 0 total points
ID: 21848455
The problem was an issue with the Toad software an not the query itself.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Bulk insert into global temporary table 2 61
Export BLOB data from Oracle 10g 4 34
Wrap Oraccle SQL*Plus executable Command 4 68
Queries 15 34
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now