AW: [BioSQL-l] how do you update the value of a tag?

Hilmar Lapp hlapp at gnf.org
Thu Nov 27 07:20:03 EST 2003


Have you verified that your change of the tag does indeed not get updated in the database?
 
There's a couple of things to note here.
 
 - most often one can ignore the statement execution errors, as they are usually caught and dealt with internally, unless there is a bug of course. But generally speaking, the only reason you see those messages is because I haven't silenced the DBD driver yet by default. (It can be silenced by changing a single line of code.)
 
  - for the case at hand, the code first attempts an insert instead of an update because the look-up key for the association consists of almost all columns of the association table, and those associations most often do not exist yet, hence an update would most often fail (note that those associations do not have a generated primary key, and have no resemblance in the object model)
 
  - if you want to update tags, the best thing to do is to delete the feature first, which will also remove the associations:
 
[...]
$source->remove(); # delete the feature in the database
$source->remove_tag('standard_name'); # then modify to your liking
[...]
$source->store(); # finally re-insert; this is now the same as ...->create();
 
-hilmar

	-----Ursprüngliche Nachricht----- 
	Von: Frederic Pecqueur [mailto:Frederic.Pecqueur at devgen.com] 
	Gesendet: Mo 24.11.2003 08:05 
	An: biosql-l at open-bio.org 
	Cc: 
	Betreff: [BioSQL-l] how do you update the value of a tag?
	
	

	Hi,
	
	I have a problem when I want update the value of a tag in a Sequence of BioSQL.
	
	I use this code :
	
	    my $adp = $db->get_object_adaptor('Bio::SeqI');
	
	    my $lseq = $adp->find_by_unique_key(Bio::Seq::RichSeq->new(
	                                                  -accession_number => $id,
	                                                  -namespace => $namespace
	                                                  ));
	
	    my $source;
	    foreach my $feat ( $lseq->get_SeqFeatures )
	    {
	      if ( $feat->primary_tag eq 'gene' )
	      {
	        $source = $feat;
	        last;
	      }
	    }
	
	    $source->remove_tag('standard_name');
	
	    $source->add_tag_value('standard_name','my new value');
	
	    $source->store();
	
	Apparently the problem comes from the update of the "Seqfeature Qualifier Value" table.
	I obtain several errors about a bad insert command.
	I don't understand why the API uses an "INSERT" command and not an "UPDATE" command??
	
	Here is the errors:
	
	DBD::Oracle::st execute failed: ORA-00001: unique constraint (BIOSQL.XPKSEQFEATURE_QUALIFIER_ASSOC) violated (DBD ERROR: OCIStmtExecute) [for statement ``INSERT INTO seqfeature_qualifier_value (fea_oid, trm_oid, value, rank) VALUES (?, ?, ?, ?)'' with params: :p4=1, :p1='5321562', :p2=1968, :p3='a new value']) at usr/lib/perl5/site_perl/5.6.1/Bio/DB/BioSQL/BasePersistenceAdaptor.pm line 418.
	
	somebody has an idea?
	
	Thanks a lot.
	Frédéric.
	
	_______________________________________________
	BioSQL-l mailing list
	BioSQL-l at open-bio.org
	http://open-bio.org/mailman/listinfo/biosql-l
	




More information about the BioSQL-l mailing list