Can anyone see what is wrong with the program below which tries to represent two football matches in JDB?
As far as I can tell the code should result in representing the matches TEAMA vs TEAMB and TEAMB vs TEAMA but in fact results in TEAMA vs TEAMA and TEAMB vs TEAMB. Similar result occurs when trying to Insert__footballdb 'match' twice rather than doing a bulk insert. Hopefully the program is documented well enough to be self explanatory. Thanks, Matthew. Note 'explanation' I am trying to represent that: TEAMA played at home against TEAMB on 22/7/2006 TEAMB played at home against TEAMA on 23/7/2006 ) load 'data/jdb' NB. folder for the databases ffd =: Open_jdb_ jpath , '~temp' NB. create a database called football footballdb =: Create__ffd 'football' NB. create table to store unique match dates matchdatetb =: Create__footballdb 'matchdate';0 : 0 year int month int day int; ) NB. create table to store unique team names teamnametb =: Create__footballdb 'teamname';0 : 0 value varchar; ) NB. create table to store unique matches matchtb =: Create__footballdb 'match';0 : 0 matchdate matchdate hometeam teamname awayteam teamname; ) Note 'the matches' There are two matches in this example. TEAMA played at home against TEAMB on 22/7/2006 TEAMB played at home against TEAMA on 23/7/2006 ) NB. the two match dates and the teams which played YEARS =. 2006 2006 MONTHS =. 7 7 DAYS =. 22 23 HOMETEAMS =. 'TEAMA';'TEAMB' AWAYTEAMS =. 'TEAMB';'TEAMA' NB. bulk insert the list of unique dates Insert__footballdb 'matchdate';<<"(1) |: ~. YEARS,.MONTHS,.DAYS NB. bulk insert the list of unique team names Insert__footballdb 'teamname';<<~.HOMETEAMS, AWAYTEAMS NB. bulk insert the list of unique matches Insert__footballdb 'match';<(YEARS;MONTHS;DAYS );HOMETEAMS;<AWAYTEAMS Note 'ERROR is observed here' 'match' table has got TEAMA vs TEAMA and TEAMB vs TEAMB but it should have TEAMA vs TEAMB and TEAMB vs TEAMA. ) Reads__footballdb 'year, month, day, hometeam, awayteam from match' ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
