. .

st4u

ST 4U 163: Constructing Queries with Glorp

November 28, 2011 12:38:05.893

Today's Smalltalk 4 You starts executing a few queries against the Emp table we created and mapped here. 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:

Glorp Queries.

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 execute some queries against Oracle using the descriptor we set up - see this video for details on that. First off, we inserted some data so that there would be something to query for:


"create a few more"
listOfEmps := OrderedCollection new.
1 to: 10 do: [:index | | newEmp |
	newEmp := Emp new.
	newEmp firstName: 'Wilma', index printString.
	newEmp lastName: 'Flintstone', index printString.
	listOfEmps add: newEmp
]

"insert them"
session beginUnitOfWork.
listOfEmps do: [:each | session registerAsNew: each].
session commitUnitOfWork.

Now we can execute a few queries. It's worth taking a look at class GlorpSession to get an idea as to the API that's being used here. First, the simplest query - you can #read: any class that's been described in a descriptor:


"query"
emps := session read: Emp.
emps := session readManyOf: Emp.


Those two queries do the same thing - you should see this if you inspect the results:

Glorp Query

You can also include a where clause, but bear in mind the restrictions - in general, you are limited to code that:

  • accesses instance variables
  • compares instance variables using #=, #<, #>, #<>, #isNIL, #notNIL
  • Uses expressions in class ObjectExpression

Note that we use isNIL and notNIL rather than isNil and notNil; Glorp knows how to parse those and create valid SQL (which is what the where block becomes). Here are a few examples:


"where clauses"
session readOneOf: Emp where: [:each | each firstName = 'Fred'].
session readManyOf: Emp where: [:each | each firstName = 'Fred'].
session readManyOf: Emp where: [:each | each firstName = 'Barney'].
session readManyOf: Emp where: [:each | each firstName notNIL].
session readManyOf: Emp where: [:each | each firstName like: 'Wilma%'].

Note the use of #like:, which generates a SQL like statement. Use % rather than * for wildcarding, just as you would with SQL. For that last query, you should see the following results:

where clause

That wraps it up for now - we'll look at removing data 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: , , ,

Enclosures:
[st4u163-iPhone.m4v ( Size: 7493149 )]

posted by James Robertson

 Share Tweet This

smalltalk

Fuel For Squeak

November 28, 2011 9:17:06.827

Fuel is now available for Squeak.

Technorati Tags: ,

posted by James Robertson

 Share Tweet This

holiday

Podcast Break for Thanksgiving

November 26, 2011 11:23:15.251

No podcast this weekend - too busy with the holiday and birthdays (the entire family has them this month, 2 right around Thanksgiving). We'll be back next week though, so stay tuned :)

posted by James Robertson

 Share Tweet This

holiday

Holiday Break

November 24, 2011 9:57:28.044

It's Thanksgiving, so no screencast today or tomorrow - check the archives for now, and new casts will return next week!

posted by James Robertson

 Share Tweet This

skyrimAAC

Thu'umcast 5: Who Needs a Main Quest? (AAC)

November 24, 2011 3:17:24.015

Thu'umcast

Welcome to episode 5 of "Thu'umcast" - a podcast where Michael Lucas-Smith, Scott Dirk, Austin Haley, Makahlua and I document our trials and tribulations in Elder Scrolls V: Skyrim

Today we were joined by Madjinn, who has logged an impressive number of hours in the game (averaging 10 per day since it was released :) ). We talked about some of the more glaring quest glitches (including the nasty one for Jagged Crown/Season Unending). We also talked about monster leveling, followers, and how we've been playing our characters.

If you liked our work on That Podcast, you'll probably like this. We intend to stay with the same idea - a gameplay podcast. If you don't want spoilers, don't listen - we are going to be talking about how we play the game, and what we ran across as we played.

You can subscribe in iTunes (or any podcatcher) using this feed, or this one for the AAC edition. We'll add the iTunes specific links as soon as they are available. In the meantime, join the Facebook Group and follow us on Twitter. If you play on Steam, join the Steam Group. Like the music? Pay Sbeast a visit, we thank him for letting us use it!

Links to all episodes and other information can be found on the Thu'umcast page

.

If you want to download the podcast directly, we've provided it in three formats:

Got feedback? Tweet us!. Enjoy the podcast, and we'll see you in Skyrim!

Technorati Tags: ,

Enclosures:
[thuum5.m4a ( Size: 26689257 )]

posted by James Robertson

 Share Tweet This

skyrim

Thu'umcast 5: Who Needs a Main Quest?

November 24, 2011 3:16:34.565

Thu'umcast

Welcome to episode 5 of "Thu'umcast" - a podcast where Michael Lucas-Smith, Scott Dirk, Austin Haley, Makahlua and I document our trials and tribulations in Elder Scrolls V: Skyrim

Today we were joined by Madjinn, who has logged an impressive number of hours in the game (averaging 10 per day since it was released :) ). We talked about some of the more glaring quest glitches (including the nasty one for Jagged Crown/Season Unending). We also talked about monster leveling, followers, and how we've been playing our characters.

If you liked our work on That Podcast, you'll probably like this. We intend to stay with the same idea - a gameplay podcast. If you don't want spoilers, don't listen - we are going to be talking about how we play the game, and what we ran across as we played.

You can subscribe in iTunes (or any podcatcher) using this feed, or this one for the AAC edition. We'll add the iTunes specific links as soon as they are available. In the meantime, join the Facebook Group and follow us on Twitter. If you play on Steam, join the Steam Group. Like the music? Pay Sbeast a visit, we thank him for letting us use it!

Links to all episodes and other information can be found on the Thu'umcast page

.

If you want to download the podcast directly, we've provided it in three formats:

Got feedback? Tweet us!. Enjoy the podcast, and we'll see you in Skyrim!

Technorati Tags: ,

Enclosures:
[thuum5.mp3 ( Size: 19513208 )]

posted by James Robertson

 Share Tweet This

st4u

ST 4U 162: Using a Glorp Descriptor

November 23, 2011 9:54:25.655

Today's Smalltalk 4 You starts making use of of the Glorp code we wrote here. 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:

Glorp Use.

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 start using our basic Glorp setup to insert and query data from Oracle. To start out, we need to login and get a session (this uses code we created in the last screencast).


login := Login new
database: OracleODBCPlatform new;
username: username;
password: password;
connectString: 'orcl11g';
yourself.

"login and logout"
accessor := DatabaseAccessor forLogin: login.
accessor login.

"create a session"
session := GlorpSession new.
session system: (EmpSystem forPlatform: login database).
session accessor: accessor.

Now we can create an instance and have it inserted into the database. In the code below, ou would normally use #register: - I used #registerAsNew: to ensure that Glorp would treat my object as a new one bound of the database:


"Now insert one"
emp := Emp new.
emp firstName: 'Fred'.
emp lastName: 'Flintstone'.

"insert"
session beginUnitOfWork.
session registerAsNew: emp.
session commitUnitOfWork.


Note the beginning and ending of the transaction. Now, let's use a query to get the data back:


"login"
accessor := DatabaseAccessor forLogin: login.
accessor login.

"query"
emps := session readManyOf: Emp.

It's worth looking at class GlorpSession for the full API range of what you can do; we'll be exploring some of that in future screencasts. Below are two images - a screencap of the inspector on the queried data, and a sqlplus wind showing the same thing:

data"

sqlplus

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

Enclosures:
[st4u162-iPhone.m4v ( Size: 3998020 )]

posted by James Robertson

 Share Tweet This

js4u

JS 4U 109: The context() function

November 22, 2011 10:21:08.936

Javascript 4 U

Today's Javascript 4 You looks at the context() function in JQuery. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube.

Join the Facebook Group to discuss the tutorials. You can view the archives here.

To watch now, click on the image below:

context()

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:

Technorati Tags: , ,

Enclosures:
[js4u109-iPhone.m4v ( Size: 2129223 )]

posted by James Robertson

 Share Tweet This

st4u

ST 4U 161: Installing Glorp in Pharo

November 21, 2011 10:33:15.238

Today's Smalltalk 4 You looks at installing GlorpDBX into Pharo. Yes, I did this screencast just recently, but: there were installation issues then. They've been fixed since, so I didn't want that one hanging out there as "authoritative". 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:

GlorpDBX Install

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:

Technorati Tags: , ,

Enclosures:
[st4u161-iPhone.m4v ( Size: 2541898 )]

posted by James Robertson

 Share Tweet This

games

Thu'umcast Episode 4 Files Reposted

November 21, 2011 8:40:24.378

I had a brain cramp in the editing process for episode 4 - I've reposted all three audio files.

Technorati Tags:

posted by James Robertson

 Share Tweet This