- my $sth=$dbh->prepare("replace mediatypetable (mediatypecode,description,itemtypecodes) values (?,?,?)");
- $sth->execute(
+ my $sth = $dbh->prepaer("SELECT * FROM mediatypetable WHERE mediatypecode = ?");
+ $sth->execute($input->param('mediatypecode'));
+ if (my $data = $sth->fetchrow_hashref()){
+ # row exists, so its a modify
+ $sth->finish();
+ $sth = $dbh->prepare("UPDATE mediatypetable SET description=?, itemtypecodes=? WHERE mediatypecode =? ");
+ $sth->execute($input->param('description'),$itemtypecodes,$input->param('mediatypecode'));
+ $sth->finish();
+ }
+ else {
+ # its an add
+ $sth->finish();
+ $sth = $dbh->prepare("INSERT INTO mediattypetable (mediatypecode,description,itemtypecodes) VALUES (?,?,?)");
+ $sth->execute(