[Gambas-user] Database table row update

John Rose john.aaron.rose at ...626...
Mon Jan 30 15:13:36 CET 2012


I'm using Gambas3.0. I have a database table Site with structure:
CREATE TABLE site(_id Integer Primary Key AutoIncrement, site Text Not
Null, latitude Float, longitude Float, image Blob, description Text,
locality_id Integer, Foreign Key(locality_id) References locality(_id)
On Delete Cascade On Update Cascade)


I have a module's procedure intended to update an existing row (with _id
= 2 which is the second row on the Site table) with new latitude,
longitude, image & description. It is coded as (where ResultSite is the
result of an SQL command resulting in a number of rows selected from
Site):
Public Sub UpdateSiteDetails(SiteIndex As Integer, Latitude As Float,
Longitude As Float, ImagePath As String, Description As String)
  Print "Start Site Details Update"
  Print "New details are:"
  Print "SiteIndex=", SiteIndex
  Print "Latitude=", Latitude
  Print "Longitude=", Longitude
  Print "ImagePath=", ImagePath
  Print "Description=", Description
  DatabaseConnection.Begin
  ResultSite.MoveTo(SiteIndex)
  Print "Old details are:"
  Print "_id=", ResultSite["_id"]
  Print "Latitude=", ResultSite["latitude"]
  Print "Longitude=", ResultSite["longitude"]
  If IsNull(ResultSite["description"]) Then
    Print "Description is Null"
  Else
    Print "Description=", ResultSite["description"] 
  Endif
  Print 1
  ResultSite["latitude"] = Latitude
  Print 2
  ResultSite["longitude"] = Longitude
  Print 3
  ResultSite["image"] = File.Load(ImagePath)
  Print 4
  ResultSite["description"] = Description
  Print 5
  ResultSite.Update()
  Print 6
  DatabaseConnection.Commit
  Print "End Site Details Update"
Catch
  DatabaseConnection.Rollback
  Error.Raise("<b>Update database site table record
error</b><hr>Error:<br>" & DConv(Error.Text))
End

The console result from the procedure is:
New details are:
SiteIndex=      1
Latitude=       48.8814
Longitude=      2.3365
ImagePath=      /tmp/gambas.1001/26989/6.tmp.jpg
Description=    At number 4, was a famous restaurant, run by Jo
Goldenberg. The former restaurant Goldenberg, on the corner of the Rue
des Rosiers and Rue Ferdinand Duval, was closed in 2006. It was known
for its traditional cuisine: it was "kosher style" 
but in fact non-Kosher! The front has a prominent Magen David. 

A violent attack took place in 1982: 6 were killed and 22 were injured.
Traces were still visible on the frontage 10 years later. In 2010, a
fashion clothing store took possession of the premises, keeping the
frontage.

Old details are:
_id=    2
Latitude=       48.8814
Longitude=      2.3365
Description is Null
1


Everything is correct on this console print except that I get a hang at
that point. As you can see, the 'ResultSite["latitude"] = Latitude'
statement seems to be the problem. I've tried varying this statement by
putting .Data at the end of it but with no success. Help please!






More information about the User mailing list