[SOLVED] How to insert into the database the Foreign Key

Hello,

I’m running tests to migrate to version 7 and I have a problem initialize BDM attributes from contract instantiation process inputs, I have no idea how to insert the Foreign Key in the database.

In contracts it generates attributes, Id descriptions status and date.
In suppliers it generates attributes, name and contracts, contracts the type contract with relationship of aggregation with the option Always load related objects.

In the DB the following table is generated with fields persistenceid bigint, name, type and contrato_pid bigint, the problem is I can not insert the value of the contracts persistenceid object in the contracts_pid bigint.

Use the option Auto-generate the initialization script and does not work

Any help will be very grateful.

This is rather basic SQL, please see the following two posts I found from doing a Google search:

http://stackoverflow.com/questions/4775520/mysql-how-to-insert-values-in-a-table-which-has-a-foreign-key
http://dba.stackexchange.com/questions/46410/how-do-i-insert-a-row-which-contains-a-foreign-key

using this information I think the thing to do would be to create a Custom Query to the BDM specific to your needs.

regards
Seán

PS: If this reply answers your question, please mark a resolved

Thanks Sean, the information helped me solve the problem.

Sean hates it when I mention this video. (hes a great guy BTW…)
but I love hello-world tutorials and although this video shows me using the wrong password over and over (I am too lazy to fix the vid), it does give people a complete overview of putting form text into sql using bonitasoft.

video link:

Cheers!
Jim

Please can anyone help me please,
I have 3 tables: course(idc, title), participant(idp,username) and registered. the table registered contain (#idc, #idp, date) in MySQL
I want to insert in the table registered a participant in a course.

I do that:

INSERT INTO ‘registered’ (idc, idp, date) VALUES (
(SELECT idc FROM course WHERE title=‘${title}’;),
(SELECT idp FROM ‘participant’ WHERE ‘username’=‘${login}’;),
CURRENT_DATE);

but it doesn’t work!

thanks for help!

Despite what @gpscruise says (I love the video, it shows we’re all infallible) I’m wondering if the whole query works at all…

Have tried it with dummy fixed values?

I also note in one select you are using quotes and in the other you’re not…any reason why?

What does the log say…?

Regards