Getting Invalid Identifier for Snowflake Sequence Nextval

Viewed 261

I created a Sequence batch_id_seq in Snowflake. But when I am running the query "select batch_id_seq.nextval" from outside snowflake environment, I am getting the below error:

SQL compilation error: error line 1 at position 7 invalid identifier 'BATCH_ID_SEQ.NEXTVAL'

The query is working fine from within Snowflake Worksheet. Can anyone let me know what needs to be done to resolve the issue.

1 Answers

Most likely you are at different schema SELECT CURRENT_SCHEMA():

select batch_id_seq.nextval

=>

select <schema_name_here>.batch_id_seq.nextval
Related