Labkey.Query.insertRows throws null value exception for primary key

LabKey Support Forum (Inactive)
Labkey.Query.insertRows throws null value exception for primary key Ben Bimber  2011-11-28 17:41
Status: Closed
 
Glad you got it working. I agree with Matt's explanation, although I'm not sure what's causing it for you. I tried made a module using your initial SQL (including 'not null'). I then used the following XML and insertRows worked. Here's the XML:

<ns:tables xmlns:ns="http://labkey.org/data/xml">
  <ns:table tableName="specimenrequirements" tableDbType="TABLE">
    <ns:columns>
      <ns:column columnName="m_requirementid"/>
      <ns:column columnName="studyid"/>
      <ns:column columnName="sequencenumber"/>
      <ns:column columnName="organ"/>
      <ns:column columnName="numtumorcases"/>
      <ns:column columnName="desirepairnormal"/>
      <ns:column columnName="numtissuesamples"/>
      <ns:column columnName="sizepertissuesample"/>
      <ns:column columnName="numbloodsamples"/>
      <ns:column columnName="volperbloodsample"/>
      <ns:column columnName="typeofblood"/>
      <ns:column columnName="mintumorperblock"/>
      <ns:column columnName="maxtumorperblock"/>
      <ns:column columnName="sourcesurgery"/>
      <ns:column columnName="sourcebiopsy"/>
      <ns:column columnName="transportmethod"/>
      <ns:column columnName="container"/>
      <ns:column columnName="entityid"/>
      <ns:column columnName="createdby"/>
      <ns:column columnName="created"/>
      <ns:column columnName="modifiedby"/>
      <ns:column columnName="modified"/>
    </ns:columns>
  </ns:table>
</ns:tables>

I didnt need to manually specify isAutoInc. There may be differences in our postgres versions or differences in how they report the column. I have seen problems in the past with PKs not being reported correctly, in which case I needed to manually specify it using XML.

If this happens again, the first thing I'd do is check the schema browser and see if this column has 'AI' (auto increment) under the attributes for that field.