PDA

View Full Version : Updating projects via SQL


gandalf
11-05-11, 04:27 AM
Not sure that this fits in this forum, but I didn't see one that made more sense. I'm trying to update project_department for all our projects (up until now, only one department was using dP). I tried the following SQL:

UPDATE dp_projects
SET project_department=1
WHERE project_department=0

When I view the table data, all projects now have 1 in the project_department field. However, if I view a project, nothing (blank) is selected in the Departments drop-down (the departments do appear in the drop-down list).

A similar change to the field project_company_internal was reflected in the Internal Division drop-down, though in this case I was changing the values to NULL.

Do I need to update an additional field or two somewhere?

Not feeling particularly wizardy today. :)

Thank you!

Atreides
11-05-11, 05:40 PM
Have you checked if there is a department with dept_id = 1?

Edit: actually, only departments of the company selected for the project will be shown in the drop-down. If you set it to a department that doesn't belong to the company selected, then nothing will be selected in the drop-down.

gandalf
17-05-11, 05:18 AM
Yes there is a department with dept_id = 1. And yes, the department belongs to the selected company (there is only one company in my configuration).

Thank you!

ajdonnison
17-05-11, 01:53 PM
project_departments is a hold-over from an earlier version - the field is deprecated and instead you should add an entry into the project_departments table which contains the project_id and the department_id.

gandalf
18-05-11, 07:57 AM
Thanks, ajdonnison! This worked for me:

INSERT INTO dp_project_departments (project_id, department_id) SELECT project_id,1 FROM dp_projects