Example Tasks in SQL

Here are a few examples of simple tasks that you can carry out using the SQL interface.

Adding A New Type Of Attire

As we discussed back in the chapter on the Wacs Set Manager (Chapter 9, wacssetmgr - The Wacs Set Manager), there is a potential catch 22 scenario when trying to mark a set as featuring a particular type of attire. This is that the pulldown menu will only offer you types of attire that have been previously used in another set. The usual way of dealing with this is to add a new keyword that will match that word and therefore create the new category of attire for you. If for some reason you didn't want to do this, you can use SQL to create a new attire entry that will appear in the pulldown menu.

For example, maybe you have a thing for ripped denim jeans and want to add a new attire category of Ripped Jeans to the possible options. You've just added a set which features ripped jeans and it's set number 14. The SQL command you would need to update set 14 to this new attire would be:

Example 19.1. Using SQL to set Attire

SQL> update sets set sattire = 'Ripped Jeans'
  2  where setno = 14;

1 record updated.
SQL> commit;

Commit complete.
SQL> quit

Once this has been done for set 14, Ripped Jeans will appear in the pull-down menu in the set manager for subsequent usage.

Creating A Video Download Record

If you want to be able to move a record sensibly between different hosts via the migration tools, it really does need some kind of download record to uniquely identify it. As we've already seen back in the section called “Self Referential Download Records” there is now (as of Wacs 0.9.1) a web app to simplify this process, but it's still worth reviewing how we might do the same thing manually. It is a fairly simple matter to create a new download record for this purpose using SQL. The first step is to find out what the highest currently used download number is which can be done with this query:

sql> select max(downloadno) from download;

	2672

1 row selected;
sql>

With this duly determined, add one to the value (in this case 2672 becomes 2673) and use that in the SQL query you create. You will also need the related model number, which for the purposes of this illustration will be 2249 for a model called Sarah. The next value is XYZ which is the site id for an imaginary site called XYZ. The next value V is the value for the type of the file - V is for Video Clip, I is for image set. The next value is the set key which is the number obtained from the URL from the originating web site if possible or if not using the name of the video file itself as here. We then give it a name and repeat the name of the video file as the archive that this download record is expected to deliver.

sql> insert into download (downloadno, dmodelno, dsite, dtype, dsetkey,
   > dsetname, darchive)
   > values( 2673,2249,'XYZ','V','sarah04.mpg',
   > 'Sarah - Pink Dress - Garden Bench','sarah04.mpg');

1 row added.
sql> commit;

commit complete.
sql> quit
[Tip]Tip

There is of course a web app for doing this! It's called wacsdnlreg and is available on the Maintenance menu of the front page when in administrator mode as Register Download.