{"action":"opened","issue":{"url":"https://api.github.com/repos/jmoiron/sqlx/issues/154","labels_url":"https://api.github.com/repos/jmoiron/sqlx/issues/154/labels{/name}","comments_url":"https://api.github.com/repos/jmoiron/sqlx/issues/154/comments","events_url":"https://api.github.com/repos/jmoiron/sqlx/issues/154/events","html_url":"https://github.com/jmoiron/sqlx/issues/154","id":97754907,"number":154,"title":"LastInsertId and postgres","user":{"login":"davisford","id":186677,"avatar_url":"https://avatars.githubusercontent.com/u/186677?v=3","gravatar_id":"","url":"https://api.github.com/users/davisford","html_url":"https://github.com/davisford","followers_url":"https://api.github.com/users/davisford/followers","following_url":"https://api.github.com/users/davisford/following{/other_user}","gists_url":"https://api.github.com/users/davisford/gists{/gist_id}","starred_url":"https://api.github.com/users/davisford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davisford/subscriptions","organizations_url":"https://api.github.com/users/davisford/orgs","repos_url":"https://api.github.com/users/davisford/repos","events_url":"https://api.github.com/users/davisford/events{/privacy}","received_events_url":"https://api.github.com/users/davisford/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-28T17:06:57Z","updated_at":"2015-07-28T17:06:57Z","closed_at":null,"body":"Should this work? I know with PostgreSQL you need to add the `RETURNING` clause...\r\n\r\n```sql\r\nCREATE SEQUENCE foo_id_seq;\r\nCREATE TABLE foo ( \r\n  id bigint PRIMARY KEY default nextval('foo_id_seq'::regclass),\r\n  created timestamp with time zone NOT NULL,\r\n  name varchar(255) NOT NULL\r\n);\r\n```\r\n\r\n```go\r\nsql := `INSERT into foo (created, name) VALUES ($1, $2) RETURNING id`\r\nresult, err := db.Exec(sql, time.Now(), \"somename\")\r\nif err {\r\n  panic(err)\r\n}\r\nlastid, lastiderr := result.LastInsertId()\r\nfmt.Println(\"LastId?\", lastid, lastiderr) // prints: LastId? 0 no LastInsertId available\r\n```\r\n\r\nSeems like it works with `lib/pq` by using [QueryRow](https://github.com/lib/pq/issues/77#issuecomment-24875102)"}}