Insert into location table

I'm writing a batch program to sync up the location codes in our user registration system and Talis. I basically need to know how I should go about inserting data into the locations table? Am i safe to just insert a new row?

insert into location (LOCATION_ID, NAME, TYPE)
values ($code, $name, 1)

Thanks

Paul

Inserting rows in to the LOCATION table

The LOCATION table (the name is in upper case and SQL is case sensitive) actually has 7 attributes:

LOCATION_ID
NAME
LOCATION_PROFILE_ID
NOTE
TYPE
WITHIN_SITE_ID
NLOCATION_ID

While the three you mention are are critical you also need to insert a LOCATION_PROFILE_ID. If not then a lot of the rules will not work as rules are assigned to a site profile and not to sites directly.

Also the TYPE for a site is 0 (zero) and not one. The other attributes are not as critical.

On the general issue about the safeness in inserting locations it would depend on the context and why there are different sites and what they are going to be needed for.

Thanks

Brian Crampton
Developer, Talis

Hi Brian, Thanks for the

Hi Brian,
Thanks for the info.

The TYPE info on the majority of our locations is set to 1. The only ones that have a type of 0 also have a LOCATION_PROFILE_ID. I'm presuming that if I don't need a profile associated with the LOCATION I do need to set the TYPE to 1 and set the LOCATION_PROFILE_ID to NULL.

The following is an example of a row in the our current LOCATION table. Is this ok if it does not need an associated profile?

LOCATION_ID, NAME, LOCATION_PROFILE_ID, NOTE, TYPE, WITHIN_SITE_ID, NLOCATION_ID
CKV, KIEV, NULL, , 1, NULL, NULL

Thanks for your help

Paul

Inserting rows into the LOCATION table

Paul,

If the TYPE value is 1 then the rows are not sites but are departments.

The LOCATION table holds different types of location i.e. sites,departments,device,till and area although some like Till are not used or implemented differently i.e.tills are in Income Manager.

Sites have to have location profiles but the other types don't have to ask they are not used to tie into rules i.e. departments don't have loan rules.

If you are adding sites (which I'm not sure if you are) then you need to add location profiles otherwise you don't need to for departments. I realise I didn't ask what you are inserting :-).

Brian Crampton
Developer, Talis