Send to Printer


ST 4U 154: Empty Query Results in VA Smalltalk

November 4, 2011 8:27:27.370

Today's Smalltalk 4 You looks at how to determine whether your database query came back empty in VA Smalltalk. 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:

Empty Results.

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 checking the results from a query in VA Smalltalk, and then prompting the user on empty results. Let's do a query that should result in no answers:

"try a query that should return no rows"
resultCollection := OrderedCollection new.
querySpec := (AbtQuerySpec new)
	statement: 'SELECT * FROM PEOPLE where ZIPCODE = 34567'.
result := connection resultTableFromQuerySpec: querySpec.
result do: [:eachRow | resultCollection add: (eachRow)].
resultCollection isEmpty
	ifTrue:  [CwMessagePrompter message: 'No Rows Came Back' title: 'No Rows'].

The checking is fairly obvious; we simply use standard collection protocol. Then we use the standard CWMessagePrompter class to pop up a warning dialog.

And that's about it for today

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: , ,

[st4u154-iPhone.m4v ( Size: 2026693 )]

posted by James Robertson

 Share Tweet This