After 9 functions, 6 procedures and 3 tables I have finally managed to get a working version of minesweeper in Oracle SQL Developer. At best this is of very limited interest to a tiny handful of people that just happen to use a certain querying language but I am pretty pleased with myself. For reference it's like making a game using Microsoft Access although that would probably look better. Still, it's quite a challenge and now I can play Minesweeper and it looks like I am working!
For those that are interested here's how I did it (for the rest goodbye and thanks for getting this far):
Step 1: I created a table with 11 columns and 10 rows. A procedure (which itself references a further 'randomiser' procedure) then takes in the number of mines as a parameter and distributes them randomly through the first 10 columns as an X. Where there is no mine it adds an a, b,c,d,e,f,g,h, i or j depending on the column and in the last column it just numbers it from 1-10. These last two steps are important as reference data.
Step 2: Now the mines (and reference data) are in place next comes the numbers. For this I needed a second table and another procedure to populate it (the reason I needed a second table was to overcome the mutating table issue that comes when you try and update a table that is currently in use). This new procedure moves down each of the first ten columns of the first table and populates the second table with either the mine (X) or a number which is determined by one of 9 functions (top left, top right, bottom left, bottom right, left, right, top, bottom or centre) that concatenates the content of all the adjacent positions and then counts the number of mines.
Step 3: A third table (the game table) was created that was entirely populated by blank values. A 'guess' procedure was made (where you specify a column and row ie. 'B7') which then looks at the second reference table and populates it's value into this final game table (the main problem is that after each guess I have to re-query the table with a simple select statement but it still works). The final piece of the puzzle is to create a flag procedure that then populates an F into a field that I think is a mine (and then re-query of course).
There you have it. All this took me about a day and a half and although I confess that is was during work time it's still teaching myself valuable skills in PL/SQL that I can apply to my job. Probably. But just in case my manager is not a Minesweeper fan be sure to tell him I was just doing basic technical exercises. On the other hand if he is a fan then tell him that Battleships is only days away!