• Our booking engine at tickets.railforums.co.uk (powered by TrainSplit) helps support the running of the forum with every ticket purchase! Find out more and ask any questions/give us feedback in this thread!

Fares database import

Status
Not open for further replies.

BlueFox

Member
Joined
20 May 2013
Messages
759
Location
Carlisle
A couple of years ago I installed fares datbase on my PC using Soil's code and instructions - http://www.railforums.co.uk/showthread.php?t=81177

I've now got a new PC and want to install it again with the latest fares, but I'm getting an error message when I try to import the data.

Anyone have any ideas how to fix this?

I'm running it on Windows 10 64 bit and an up to date version on MS SQL Server 2012.


I've attached an image of the error message.
 

Attachments

  • CropperCapture[2].png
    CropperCapture[2].png
    12.6 KB · Views: 65
Sponsor Post - registered members do not see these adverts; click here to register, or click here to log in
R

RailUK Forums

najaB

Veteran Member
Joined
28 Aug 2011
Messages
30,840
Location
Scotland
Reading that error message literally: you've got two records in the railcards table with the same key. Have a look at the data (I'm assuming it's an import) and see if it's corrupted.
 

RJ

Established Member
Joined
25 Jun 2005
Messages
8,410
Location
Back office
Open the "create database" file in SQL Explorer and change the parameter under the relevant section (railcards) to ignore duplicate key values. Save the file, delete the "trains" database created in SQL then try again.

Not sure if it breaks anything important, but it stops that error message coming up.
 
Last edited:

BlueFox

Member
Joined
20 May 2013
Messages
759
Location
Carlisle
Open the "create database" file in SQL Explorer and change the parameter under the relevant section (railcards) to ignore duplicate key values. Save the file, delete the "trains" database created in SQL then try again.


That worked, thanks.
 

soil

Established Member
Joined
28 May 2012
Messages
1,956
according to the spec on the atoc website the primary key is the railcard code AND end date. in my database I made the code the primary key.

looking at the data (.rlc file) there are a few multiple entries

e.g.,
Code:
CRC260120161311201418112016ACAMBRIANRAILCARD    NYNNCRCY00800100100100100000800100000000000500000000001200        YZNN021000000
CRC311229992701201618112016ACAMBRIANRAILCARD    NYNNCRCY00800100100100100000800100000000000500000000001200        YZNN021000000

I can't actually see any difference between the two, but in theory I guess they want to be able to change railcards from certain dates. so you could modify the key in the sql file

CONSTRAINT [PK_Railcards_1] PRIMARY KEY CLUSTERED
(
Code:
 ASC,
        [EndDate] ASC
)

or you could delete the duplicate entries manually.

Or you could indeed delete the primary key entirely, the railcards table isn't actually used anywhere.
 

RJ

Established Member
Joined
25 Jun 2005
Messages
8,410
Location
Back office
That worked, thanks.

No worries. There are so many fares revealed in there to be set at rates much lower than they should be - but are very unlikely to be picked up by barriers, revenue staff or even split ticketing websites. It's an incredibly useful tool to have if you know what to look for!
 

RJ

Established Member
Joined
25 Jun 2005
Messages
8,410
Location
Back office
according to the spec on the atoc website the primary key is the railcard code AND end date. in my database I made the code the primary key.

looking at the data (.rlc file) there are a few multiple entries

e.g.,
Code:
CRC260120161311201418112016ACAMBRIANRAILCARD    NYNNCRCY00800100100100100000800100000000000500000000001200        YZNN021000000
CRC311229992701201618112016ACAMBRIANRAILCARD    NYNNCRCY00800100100100100000800100000000000500000000001200        YZNN021000000

I can't actually see any difference between the two, but in theory I guess they want to be able to change railcards from certain dates. so you could modify the key in the sql file

CONSTRAINT [PK_Railcards_1] PRIMARY KEY CLUSTERED
(
Code:
 ASC,
        [EndDate] ASC
)

or you could delete the duplicate entries manually.

Or you could indeed delete the primary key entirely, the railcards table isn't actually used anywhere.[/QUOTE]

In that case it looks like the validity dates - maybe a very subtle update to the validity or implementation necessitated another entry.
 
Status
Not open for further replies.

Top