1
1
-- Redirect to the next question when all players have answered
2
2
set page_params = json_object(' game_id' , $game_id, ' player' , $player);
3
3
select CASE
4
- (SELECT count (* ) FROM answers WHERE question_id = $question_id AND game_id = $game_id:: integer )
5
- WHEN (SELECT count (* ) FROM players WHERE game_id = $game_id:: integer )
4
+ (SELECT count (* ) FROM answers WHERE question_id = $question_id AND game_id = CAST( $game_id AS INTEGER ) )
5
+ WHEN (SELECT count (* ) FROM players WHERE game_id = CAST( $game_id AS INTEGER ) )
6
6
THEN ' 0; ' || sqlpage .link (' next-question.sql' , $page_params)
7
7
ELSE 3
8
8
END as refresh,
@@ -11,22 +11,22 @@ FROM sqlpage_shell;
11
11
12
12
-- Insert the answer into the answers table
13
13
INSERT INTO answers(game_id, player_name, question_id, answer_value)
14
- SELECT $game_id:: integer as game_id,
14
+ SELECT CAST( $game_id AS INTEGER ) as game_id,
15
15
$player as player_name,
16
- $question_id:: integer as question_id,
17
- $answer:: integer as answer_value
16
+ CAST( $question_id AS INTEGER ) as question_id,
17
+ CAST( $answer AS INTEGER ) as answer_value
18
18
WHERE $answer IS NOT NULL ;
19
19
-- Redirect to the next question
20
20
SELECT ' text' as component,
21
21
' Waiting for other players to answer... The following players still have not answered: ' as contents;
22
22
select group_concat(name, ' , ' ) as contents,
23
23
TRUE as bold
24
24
from players
25
- where game_id = $game_id:: integer
25
+ where game_id = CAST( $game_id AS INTEGER )
26
26
and not EXISTS (
27
27
SELECT 1
28
28
FROM answers
29
- WHERE answers .game_id = $game_id:: integer
29
+ WHERE answers .game_id = CAST( $game_id AS INTEGER )
30
30
AND answers .player_name = players .name
31
- AND answers .question_id = $question_id:: integer
32
- );
31
+ AND answers .question_id = CAST( $question_id AS INTEGER )
32
+ );
0 commit comments