Dynamic variable binding

This commit is contained in:
Juan Ignacio Sánchez Lara 2015-08-10 16:01:47 +02:00
parent 6baa626756
commit 9a3fbb668c

View File

@ -118,7 +118,7 @@ FUNCTION cartodb._CDB_User_RoleFromUsername(username text)
DECLARE
user_role TEXT;
BEGIN
EXECUTE 'SELECT SCHEMA_OWNER FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ''' || username || ''' LIMIT 1' INTO user_role;
EXECUTE 'SELECT SCHEMA_OWNER FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = $1 LIMIT 1' INTO user_role USING username;
RETURN user_role;
END
$$ LANGUAGE PLPGSQL;