SQL Questions other than SELECT

SQL Questions other than SELECT

by Stephen Richards -
Number of replies: 2

Hi, I'm very new to coderunner.

I've been trying to create a simple SQL question that asks students to insert a new record into a database. The approach I've tried was to create a simple DB and upload the file. This would also apply to things like creating new tables as well.

The question asks for specific data to be added to a table.

In the standard input for the question I have tried a select statement that would give the required output if the values had been inserted correctly. It doesn't seem to get run.

I've also tried putting the select statement in the extra template data section. When I do this, the command gets run before the student answer is carried out and doesn't show the new values.

The only way I can find to do it seems to be to put the select statement at the end of the student answer which is not ideal.


How can I go about achieving this?

Thanks

In reply to Stephen Richards

Re: SQL Questions other than SELECT

by Paul McKeown -
Hi,

I think your select statement should be in a test case box, rather than the standard input.

As per the documentation, each test will run an sqlite3 command script of the following form:
.mode column
.headers on
<code in extra>
<student answer>
<testcode>
You can put code in the extra box for setting things up, eg, you might want insert a few more records into the table before running the student answer.

I've attached an example question that I think is the sort of thing you are trying to do.

Let me know if you're actually trying to do something different.

Cheers,
Paul
In reply to Paul McKeown

Re: SQL Questions other than SELECT

by Stephen Richards -
Thanks.
I had misunderstood the "test case n" textbox and assumed it was for a test title / description not realising it was for test code. I always complain to my students that it doesn't matter what we do as teachers to make the task clear, you always find a new and inventive way to break it and it seems I'm no better myself :-S