How to avoid duplicate values in a table ? #34
Replies: 2 comments 2 replies
-
Hello! What is the desired behavior when someone tries to insert a duplicate name? With the "unique" constraint you already have, you should already be seeing an error message when trying to insert a duplicate. If you want, you can use a select statement with the redirect component and a where clause to redirect the user before the insert statement on duplicates |
Beta Was this translation helpful? Give feedback.
1 reply
-
Hello, SELECT
'form' as component,
'New player' as title,
'Insert' as validate;
SELECT 'Player name' as label, 'player_name' as name;
SELECT 'alert' as 'component',
'Warning' as title,
'The player ''' || :player_name || ''' already exist' as description
WHERE :player_name IS NOT NULL
AND EXISTS (SELECT 1 FROM player WHERE name = :player_name);
INSERT INTO player(name)
SELECT :player_name
WHERE :player_name IS NOT NULL
AND NOT EXISTS (SELECT 1 FROM player WHERE name = :player_name);
SELECT 'list' as component;
SELECT
name as title,
'group.sql?id!'|| id as link
FROM player; |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
For a table like :
How to avoid duplicate "name" value with INSERT :
Luis
Beta Was this translation helpful? Give feedback.
All reactions