cancel
Showing results for 
Search instead for 
Did you mean: 

JDBC RECEIVER

sahana_ps
Participant
0 Kudos

Hi all,

I am trying to insert data to field - ' EQUIPMENT_COMMENT ' only in table MOC_EQUIPMENT
this  is my receiver structure:

<Statement>
     <MOC_EQUIPMENT>
          <action> (mapped to constant- INSERT)
          <table>   (mapped to schema.table name)
          <access>
                <EQUIPMENT_COMMENT>
          </access>
    </MOC_EQUIPMENT>
</Statement>

Here i am trying to insert data into  EQUIPMENT_COMMENT field only but i am getting error like "cannot insert NULL into MOC_EQUIPMENT.UNIT_ID "
where UNIT_ID is one more field in the table MOC_EQUIPMENT.

can anyone help to solve this error?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

UNIT_ID seems to be either primary key or part of unique key or not null allowed field.

so in your receiver msg structure add UNIT_ID field, so that you can send the value of UNIT_ID field too.

Answers (4)

Answers (4)

baskar_gopalakrishnan2
Active Contributor
0 Kudos

I see the backend database table is not maintained with database constraints.  Use Describe command to check the table information about primary keys and NOT NULL fields. Looks like this field does not maintain any primary keys. If so, insert the statement with necessary fields (that are not null).
Example in your case: ALways insert data with unit id. (This unit id might be sequencer too). Don't worry about key fields.

Note: If you need to query the table use that not null field unit iD and see how that helps.

sahana_ps
Participant
0 Kudos

adding to my above issue...

can i add "key "condition after access in an INSERT statement ?

<Statement>
     <MOC_EQUIPMENT>
          <action> (mapped to constant- INSERT)
          <table>   (mapped to schema.table name)
          <access>
                <EQUIPMENT_COMMENT>
          </access>

          <key>

          </key>     
    </MOC_EQUIPMENT>
</Statement>

Former Member
0 Kudos

A better way will be to use UPDATE_INSERT, so system will insert if needed or update if needed.

then you can add key after access.

in key, mention primary key fields' names.

Shabarish_Nair
Active Contributor
0 Kudos
sahana_ps
Participant
0 Kudos

hi rajeev,

here the table,in  which i am trying to insert ,i cant consider primary key fields as key because they are not unique values..i have only one field in this table which is not primary key but it has unique values

Former Member
0 Kudos

so a combination of two or more fields can be a unique key for your table, then in that case, have all those fields in key part in msg structure.

if you want to use only INSERT action, then key part is not needed in msg structure.

Shabarish_Nair
Active Contributor
0 Kudos

the error clearly indicates that the table expects a value for the field UNIT_ID.

Check back with the target system and functional owners. You might have to populate that value also whenever you do an insert

rajasekhar_reddy14
Active Contributor
0 Kudos

Testing point of view tets with dummy value and see the output like data inserted in to DB or not,in your case MOC_EQUIPMENT.UNIT_ID alays expects value.

Better to get table structure from DB team and create identical name in JDBC receiver data type.