CURRENT_SCHEMA null

drumcircle
Single Node Master

When writing scripts, sometimes CURRENT_SCHEMA is null.  Why?  What to do?

local result = query("SELECT CURRENT_SCHEMA")
	local current_schema = result[1][1]
	local returnText = ""
	local searchCol = ""
	if (current_schema==null) then
	   returnText = "SELECT schema_name FROM exa_schemas WHERE true"
1 ACCEPTED SOLUTION

mwellbro
Xpert

Hi @drumcircle ,

I´d expect CURRENT_SCHEMA to be NULL as long as you did not explicitly "OPEN SCHEMA ... " before , there is no DEFAULT Schema in your connection string an you did not 
just "CREATE SCHEMA ... " ( which would implicitly open the schema after creating it ).

Opening the schema before executing your script should take care of this.

Cheers,
Malte

View solution in original post

1 REPLY 1

mwellbro
Xpert

Hi @drumcircle ,

I´d expect CURRENT_SCHEMA to be NULL as long as you did not explicitly "OPEN SCHEMA ... " before , there is no DEFAULT Schema in your connection string an you did not 
just "CREATE SCHEMA ... " ( which would implicitly open the schema after creating it ).

Opening the schema before executing your script should take care of this.

Cheers,
Malte

View solution in original post