Labkey.Query.insertRows throws null value exception for primary key | Maya Li | 2011-11-28 13:50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Status: Closed | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
I'm developing a module with my own defined database schema. I am trying to insert a row into a table with the following definition: CREATE TABLE litterbox.specimenrequirements ( m_requirementid serial NOT NULL, studyid bigint, sequencenumber integer, organ character varying(50), numtumorcases integer, desirepairnormal boolean, numtissuesamples integer DEFAULT 0, sizepertissuesample character varying(10), numbloodsamples integer DEFAULT 0, volperbloodsample integer, typeofblood character varying(10), mintumorperblock integer DEFAULT 0, maxtumorperblock integer DEFAULT (-1), sourcesurgery boolean, sourcebiopsy boolean, transportmethod character varying(10), container entityid, entityid entityid, createdby userid, created timestamp without time zone, modifiedby userid, modified timestamp without time zone, CONSTRAINT pk_specimenrequirements PRIMARY KEY (m_requirementid), CONSTRAINT fk_specimenrequirements FOREIGN KEY (studyid) REFERENCES litterbox.study (m_studyid) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION ); I am simply trying to insert a row with the following JavaScript code: function addTissueSpec() { alert('add tissue start'); alert(InitTissueForm.organ.value); LABKEY.Query.insertRows({ schemaName: 'litterbox', queryName: 'specimenrequirements', rowDataArray: [{ "studyid": _studyId, "organ" : InitTissueForm.organ.value, "numtissuesamples": InitTissueForm.numtissuesamples.value, "sizepertissuesample" : InitTissueForm.sizepertissuesample.value }], successCallback: function(data) { var requirementId = data.rows[0].m_requirementid; alert(requirementId + " added success"); }, failureCallback: function() {alert('Something went wrong');} }); } When I call addTissueSpec(), I get the following javascript error (truncated to show only the top): { "exceptionClass": "org.labkey.api.query.InvalidKeyException", "exception": "Value for key field 'm_requirementid' was null or not supplied!", "stackTrace": [ "org.labkey.api.query.DefaultQueryUpdateService.getKeys(DefaultQueryUpdateService.java:397)", "org.labkey.api.query.DefaultQueryUpdateService.getRow(DefaultQueryUpdateService.java:134)", "org.labkey.api.query.AbstractQueryUpdateService.getRows(AbstractQueryUpdateService.java:72)", "org.labkey.query.controllers.QueryController$CommandType$1.saveRows(QueryController.java:2611)", "org.labkey.query.controllers.QueryController$BaseSaveRowsAction.executeJson(QueryController.java:2769)", "org.labkey.query.controllers.QueryController$InsertRowsAction.execute(QueryController.java:2826)", "org.labkey.query.controllers.QueryController$InsertRowsAction.execute(QueryController.java:2819)", "org.labkey.api.action.ApiAction.handlePost(ApiAction.java:147)", "org.labkey.api.action.ApiAction.handleRequest(ApiAction.java:98)", "org.labkey.api.action.BaseViewAction.handleRequestInternal(BaseViewAction.java:166)", "org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)", .. I have written similar code which has worked on other table with similar set up before. I have tried to also add 'm_requirementid: 8' in the rowDataArray config and that didn't seem to work either. Any help with possible leads is appreciated. Maya |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||