Getting Invalid Identifier for Snowflake Sequence Nextval

1.3k Views Asked by At

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.

2

There are 2 best solutions below

1
Lukasz Szozda On

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

select batch_id_seq.nextval

=>

select <schema_name_here>.batch_id_seq.nextval
0
ekibet On

Kindly check if the role you are using has the proper rights and grants to be able to access the schema.