7

I'm running the following query:

WITH match_team_vals(match_id, team_id, is_radiant) AS (
VALUES 
(2281450916, 2783913, true),
(2281450916, 2538753, false)
)

INSERT INTO dota_match_team(match_id, team_id, is_radiant)
SELECT match_id, team_id, is_radiant
FROM match_team_vals
RETURNING id AS lineup_id

on this table:

CREATE TABLE dota_match_team
(
  id serial NOT NULL,
  match_id integer NOT NULL,
  team_id integer,
  is_radiant boolean NOT NULL,
  CONSTRAINT dota_match_teams_pkey PRIMARY KEY (id)
)

The error message I get is

ERROR: integer out of range
SQL state: 22003

I've tried casting the match_id and team_id to bigint. Also looking online I see that people have this issue with the serial hitting the upper limit of integers. This doesn't seem to be the case:

SELECT nextval('dota_match_team_id_seq')
returns 31

2 Answers 2

13

Consider altering your table to use a bigger integer (see here for details: http://www.postgresql.org/docs/9.1/static/datatype-numeric.html).

I think the problem is, that your match_id and team_id are of type integer and you try to insert the value 2281450916, but integer's maximum is 2147483647

Sign up to request clarification or add additional context in comments.

1 Comment

Whoops. I changed all of my other ints to bigints but missed these! Thanks a lot.
2

You can run this query:

ALTER TABLE dota_match_team alter column match_id type bigint;

this type cast solve the error for match_id. if you thinkIt is error of serial limit then you can also do.

  SELECT setval('dota_match_team_id_seq' , 100000000);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.