Add customer through sql

English! place to talk about development, programming and coding
Post Reply
brightrif
Znuny newbie
Posts: 40
Joined: 03 Nov 2011, 11:41
Znuny Version: 3.0.10
Real Name: Bright
Company: Computer world

Add customer through sql

Post by brightrif »

hi,
i have to insert 3k customers in OTRS. i made a script for this

insert into CUSTOMER_USER (ID,LOGIN,EMAIL,CUSTOMER_ID,FIRST_NAME,LAST_NAME,PHONE,VALID_ID,CREATE_TIME,CREATE_BY,CHANGE_TIME,CHANGE_BY) values (SE_CUSTOMER_USER.nextval,'640038077','xxxx@xx.com','640038077','A. Jalil','Alam','5590',1,sysdate,201,sysdate,201);

but after i execute this i got error.

could you help me,
artjoms15
Znuny advanced
Posts: 121
Joined: 30 Aug 2011, 10:48
Znuny Version: 3.3.8 && 4.0.9
Real Name: Artjoms Petrovs
Location: Latvia

Re: Add customer through sql

Post by artjoms15 »

What kind of error do you have? Can you post a screenshot please?
Ar cieņu / Kind regards,
----------------------------------------
Artjoms Petrovs
Sistēmu analītiķis/Programmētājs /
Systems Analyst/Programmer
brightrif
Znuny newbie
Posts: 40
Joined: 03 Nov 2011, 11:41
Znuny Version: 3.0.10
Real Name: Bright
Company: Computer world

Re: Add customer through sql

Post by brightrif »

Error starting at line 1 in command:
insert into CUSTOMER_USER (ID,LOGIN,EMAIL,CUSTOMER_ID,FIRST_NAME,LAST_NAME,PHONE,VALID_ID,CREATE_TIME,CREATE_BY,CHANGE_TIME,CHANGE_BY) values (SE_CUSTOMER_USER.nextval,'640038077','xxxx@xxxxx.xx','640038077','A. Jalil','Alam','5590',1,sysdate,201,sysdate,201)
Error report:
SQL Error: ORA-02291: integrity constraint (BRI.FK_CUSTOMER_USER_CREATE_BY_ID) violated - parent key not found
02291. 00000 - "integrity constraint (%s.%s) violated - parent key not found"
*Cause: A foreign key value has no matching primary key value.
*Action: Delete the foreign key or add a matching primary key.
artjoms15
Znuny advanced
Posts: 121
Joined: 30 Aug 2011, 10:48
Znuny Version: 3.3.8 && 4.0.9
Real Name: Artjoms Petrovs
Location: Latvia

Re: Add customer through sql

Post by artjoms15 »

Well, it seems that you don' t have an agent with that accoding ID "201" in OTRS usually e-mail or login is used as ID, which should be inserted as ID (don' t know your database structure, so you should browse it and find according value (I have a feeling that 201 is database inner row ID))
Ar cieņu / Kind regards,
----------------------------------------
Artjoms Petrovs
Sistēmu analītiķis/Programmētājs /
Systems Analyst/Programmer
brightrif
Znuny newbie
Posts: 40
Joined: 03 Nov 2011, 11:41
Znuny Version: 3.0.10
Real Name: Bright
Company: Computer world

Re: Add customer through sql

Post by brightrif »

thank you very much,

it is insert the value now . but i can't see this customer in web console. is there any other changes i have to made
artjoms15
Znuny advanced
Posts: 121
Joined: 30 Aug 2011, 10:48
Znuny Version: 3.3.8 && 4.0.9
Real Name: Artjoms Petrovs
Location: Latvia

Re: Add customer through sql

Post by artjoms15 »

Check what customer backend you are using. If you use LDAP, then consider of adding one more customer backend source in Config.pm file. Else if you already use database source then check if the CustomerID and CustomerUserID are filled in (Obligatory) in the database. These are the fields which links customers into the system.
Ar cieņu / Kind regards,
----------------------------------------
Artjoms Petrovs
Sistēmu analītiķis/Programmētājs /
Systems Analyst/Programmer
Post Reply