Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
The Best Selling PC Migration Utility.
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
  #1  
Old October 26th, 2003, 05:39 AM
ratumeli ratumeli is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 20 ratumeli User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
create a view

JOB Table
Name Null? Type
----------------------------------------- -------- ------------
JOBID NOT NULL NUMBER(4)
CLIENTID NOT NULL NUMBER(4)
REGONO VARCHAR2(6)
EMPLOYEEID NUMBER(4)
PICKUPTIME NOT NULL DATE
DELIVERYTIME NOT NULL DATE
PICKUPADDRESS NOT NULL VARCHAR2(50)
DELIVERYADDRESS NOT NULL VARCHAR2(50)
COMPLETED NOT NULL CHAR(3)
JOBDATE NOT NULL DATE

DRIVINGHISTORY Table
Name Null? Type
----------------------------------------- -------- ------------
HISTORYID NOT NULL NUMBER(4)
EMPLOYEEID NOT NULL NUMBER(4)
OFFENCENO NOT NULL VARCHAR2(10)
OFFENCETYPE NOT NULL VARCHAR2(20)
OFFENCEDATE NOT NULL DATE
DEMERITPOINT NOT NULL NUMBER(2)

Conditions:
Each row in the JOB table is a job. A set of jobs is a trip if it satisfies the following two requirements:

1. Every member of that set has the same CLIENTID, REGONO and PICKUPTIME, and REGNO is not null;
2. The jobs in the set can be ordered in a sequence so that for all jobs from the second to the second-last in the sequence, the DELIVERYADDRESS of one member of the sequence equals the PICKUPADDRESS of the following member of the sequence.

The PICKUPADDRESS of the first job in a trip sequence is called FIRST and the DELIVERYADDRESS of the final job in a trip sequence is called FINAL.

For each trip consisting of more than one job, list
CLIENTID, REGONO, PICKUPTIME, FIRST, FINAL and the sum of the
DEMERITPOINT of the drivers for the trip (give this column the title DEMERITS).

I'm to create a view called TRIPS which defines the multi-job trips.

I have difficulty with addressing how to label the trips as in how to address the delivery address of one to be the pickup address of another in the query.

Please help with some leads.

Reply With Quote
  #2  
Old October 26th, 2003, 08:10 PM
Dan Drillich Dan Drillich is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 68 Dan Drillich User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
ratumeli,

Using Oracle 8i, I created the table:

create table jobs (
JOBID NUMBER(4) ,
CLIENTID NUMBER(4) ,
REGONO VARCHAR2(6) ,
EMPLOYEEID NUMBER(4) ,
PICKUPTIME DATE ,
DELIVERYTIME DATE ,
PICKUPADDRESS VARCHAR2(50) ,
DELIVERYADDRESS VARCHAR2(50) ,
COMPLETED CHAR(3) ,
JOBDATE DATE
);

insert into jobs values(1,1,'NY',1,sysdate,sysdate,'NY','NJ','N',sysdate);
insert into jobs values(1,1,'NY',1,sysdate,sysdate,'NJ','PA','N',sysdate);
insert into jobs values(1,1,'NY',1,sysdate,sysdate,'PA','CA','N',sysdate);

We can figure out the starting point of a trip (using a self-join and the minus set operation):


select x
from
(
select
a.pickupaddress x, a. deliveryaddress y
from
jobs a, jobs b
where
a.jobid = 1 and
a.deliveryaddress = b.pickupaddress
)

minus

select y
from
(
select
a.pickupaddress x, a. deliveryaddress y
from
jobs a, jobs b
where
a.jobid = 1 and
a.deliveryaddress = b.pickupaddress
);


Then, we can find the route using an hierarchal query:

select pickupaddress, deliveryaddress, level
from jobs
start with pickupaddress = 'NY'
connect by prior deliveryaddress = pickupaddress;

Cheers,
Dan

Reply With Quote
  #3  
Old October 26th, 2003, 08:23 PM
ratumeli ratumeli is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 20 ratumeli User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi Dan

I really appreciate your time and effor you've put in here. You've made this whole exercise more clearer for me.

Will give that a whirl.

Thanks
Ratu.

Last edited by ratumeli : October 26th, 2003 at 08:43 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > create a view


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway