Когда у меня есть два sql-файла, один из них в подкаталоге
main_test.sql
sub/sub_test.sql
и sub_test.sql
вызовы @../main_test.sql
(или @@../main_test.sql
) затем это хорошо работает при выполнении его от подкаталога
sub> sqlplus xxx @ sub_test.sql
Но когда я звоню
sub> cd ..
> sqlplus xxx @ sub/sub_test.sql
это приводит к
SP2-0310: unable to open file "../main_test.sql"
так как путь оценен из моего рабочего каталога, не каталога sql-файла, я звоню.
Существует ли способ использовать относительные пути, начинающие с каталога файла, содержащего вызов?
Жаль, что URL-адрес 'файла' не поддерживается - поскольку это действительно очень хорошо работает при использовании путей 'http: //'!
Я установил 'sub_test \ sub_test.sql' чтобы содержать двойные символы:
@@../main.sql
поместите всю структуру каталогов в контекст Tomcat webapps / ROOT, и он будет работать, если вы вызовете его следующим образом:
SQL> @http://host:port/sub_test/sub_test.sql
Наверное, настройка веб-сервера немного излишняя, я полагаю ?? (Также, очевидно, работает с FTP - не пробовал).
I don't know of a way of achieving this I'm afraid, but it does illustrate one of the problems of this hosted script approach.
I remember back when I started with Oracle in v7.1.whatever we would use scripts for almost everything, but there were so many tasks that could only be achieved with external scripts that you might as well use them for everything. However I think that there have been fewer reasons to do so with every release, and the only ones I have now would be refactored to pl/sql with 11g.
(It looks to me like the filename in the line with the SP2-0310 error was mis-typed. I believe that the file you meant to indicate was "../main_test.sql" and I'll proceed along that line).
If you're in the directory containing main_test.sql and you execute sub/sub_test.sql, and within sub/sub_test.sql you're invoking main_test.sql as "../main_test.sql", yes, you're going to get an error because your current working directory is the one that contains main_test.sql, so looking up one directory level by using ".." isn't going to work. In this case you'll either need to remove the ".." or use "." (single period - indicates current directory) to get things to work.
Share and enjoy.