. .


ST 4U 146: Deleting from a Table using VA Smalltalk

October 17, 2011 8:21:56.897

Today's Smalltalk 4 You looks at deleting rows from a database using VA Smalltalk. We'll look at the "object" level interface to that today, and get to general use of SQL in a future screencast. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:


If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

Today we'll look at deleting data from a database using VA Smalltalk - to see how to connect, please go back to this tutorial, as we are building on it here. You can do this sort of thing directly via SQL, and we'll be getting to that in another screencast. Today we'll be looking at the "object" interface for this.

Once you have a connection to your database set up (with a user who has permissions to make changes), you can delete data pretty easily. First, query the data out of the database:

"delete a row"
table := connection openTableNamed: 'PEOPLE'.
querySpec := (AbtQuerySpec new)
	statement: 'SELECT * from PEOPLE where PEOPLE.ZIPCODE = 12345';
	hostVarsShape: (nil).
rowToDelete := (connection resultTableFromQuerySpec: querySpec) first.
table deleteRow: rowToDelete.

Next, commit the work:

"commit it" connection commitUnitOfWork

Now, before we executed the delet, here's what we had from the query:

queried data

And here's what we had after the commit:

queried data

That pretty much wraps it up for today - we'll look at some more examples next time.

Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.

Technorati Tags: , ,

[st4u146-iPhone.m4v ( Size: 4045921 )]

posted by James Robertson

 Share Tweet This