My first problem:
On 23/03/2014 16:21, Lyle wrote:
The actual code for this is: SELECT account_save(id, accno, description, category, gifi_accno, NULL, contra, CASE WHEN link like '%tax%' THEN true ELSE false END, string_to_array(link,':')) FROM lsmb12.chart WHERE charttype = 'A'; At first it looked very odd as you can see NULL being passed explicitly for the heading column. On closer inspection of the table definition in Pg-database.sql:43 I can see it's a foreign key field. Looking at the account_save function definition in Accounts.sql:74 I can see it checks for NULL and swaps it for an ID from the account_headings table. So my problem is actually the SQL above: INSERT INTO account_heading(id, accno, description) SELECT id, accno, description FROM lsmb12.chart WHERE charttype = 'H'; That isn't actually inserting anything: # SELECT id, accno, description # FROM lsmb12.chart WHERE charttype = 'H'; id | accno | description ----+-------+------------- (0 rows) # SELECT DISTINCT charttype FROM lsmb12.chart; charttype ----------- A (1 row) I don't have any H charttypes, only A. What should I do here? Lyle |