0

I want to get the sequence for the id column in the tags table as

 SELECT pg_get_serial_sequence(‘tags’, ‘id’);

And then I want to use the result from the above Query (the sequence) as an input to the second query. Let s say the first query is called sequence I want to perform the second query as:

 SELECT setval(**sequence**, SELECT max(id) FROM tags); 

Any idea on how to do this ?

codigomonstruo
  • 1,081
  • 1
  • 11
  • 45

1 Answers1

0

You can use ActiveRecord::Base.connection.execute("your SQL query here").

kitz
  • 879
  • 2
  • 9
  • 24