If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Corel Paradox > Multiple record outputs

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-13-04, 10:02
Kenyon Kenyon is offline
Registered User
 
Join Date: Aug 2004
Posts: 2
Multiple record outputs

I have a table named Reservations that contains three fields. Room, From Date, To Date.

If my fields were equal to:
Room =A1 (Alpha Field)
From Date =01/30/2004 (Date Field)
To Date = 02/02/2004 (Date Field)

I would like to output a record in the following format until the From Date field is greater than the To Date field. Table name=Booked

Room A1
Date 01/30/2004
Month 01
Day 30

Now add 1 to the Date Field and output a record like

Room A1
Date 01/31/2004
Month 01
Day 31

Add 1 to the Date Field and output Next record like

Room A1
Date 02/01/2004
Month 02
Day 01

Add 1 to the Date Field and output Next record like

Room A1
Date 02/02/2004
Month 02
Day 02

End of output records.

Could you give me the coding for this? I assume it would be in a script.

Thank you.
Reply With Quote
  #2 (permalink)  
Old 08-20-04, 10:05
lmckelvy lmckelvy is offline
Registered User
 
Join Date: Oct 2003
Posts: 107
You could do a scan loop. Assuming both tables already exist and the field names are as you described with Month and Day being integer (or number) fields.


Code:
var

   ResTC, BookTC    tCursor
   NxtDate            date

endvar

if not ResTC.open(":myAlias:Reservations.db") ; open Reservations
     then   errorShow()
              return
endif

if not BookTC.open(":myAlias:Booking.db") ; Open Bookings 
     then   errorShow()
              return
endif

BookTC.edit() ; put Booking.db in edit mode

scan   ResTC:

     NxtDate = ResTC."From Date" ;assign start date

     while NxtDate <= ResTC."To Date" ; loop for bookings

          BookTC.insertAfterRecord() ; new record
          BookTC."Room" = ResTC."Room" ; transfer room number
          BookTC."Date" = NxtDate ; add date for this iteration
          BookTC."Month" = month(NxtDate) ; get the month
          BookTC."Day" = day(NxtDate)  ; get the day
          NxtDate = NxtDate+1 ; increment the date

     endWhile

endscan

;close all tCursors
BookTC.endEdit()
BookTC.close()
ResTC.close()
I did this without a test and without my morning coffee. You may want to add some error trapping to catch records with blank To and/or From dates.

Mac

Last edited by lmckelvy; 08-20-04 at 10:09.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On