How to handle the execution of a set of scripts in SQLDeveloper - oracle

Sometimes I have to apply this kind of sql script that has in another folder more scripts:
PROMPT "--------------------------------------"
PROMPT " APLICANDO Edward"
PROMPT "--------------------------------------"
#./Packages/Edward.sql
#./Packages/Edward2.sql
.
.
.
prompt "------------------------------------------------------"
prompt " FIN DE APLICA Edward"
prompt "------------------------------------------------------"
Usually I had to put that .zip file on the server and execute it in sqlplus, but I don't know if could execute them in SQLDeveloper (in a windows environment). Is there some way to do it in that tool?

If you are not running the scripts using SQL Developer in production, I would not recommend using SQL Developer to test the scripts. You always want your testing to be as close as possible to production.
You had said that SQLPlus will be used run the scripts in production, so I would recommend installing the same version of SQLPlus on your machine to test out the scripts. Running scripts from SQL Developer runs them using SQLcl so the behavior could be slightly different than SQLPlus. Oracle says SQLcl it is 99% compatible with SQLPlus, but without knowing what is in your scripts and what version of SQLPlus/SQLcl/SQL Developer you are using, we can not know for sure.
If you are determined on running your scripts from SQL Developer, in a SQL Worksheet, you just need to change directories to where your scripts live, then execute them just like you would from the command line. If you are on an older version of SQL Developer (pre-SQLcl) this may not work so you will need to upgrade your version of SQL Developer.

Related

Flyway windows command line gives no output, at all

I have been using flyway for a while and have managed to successfully execute migrations. This past week or so whenever I try and use flyway the command executes successfully but I get no output at all!
This is not such a big issue for the migrate command, I can just go and check in the database what has been done from the flyway_schema_history table. It is quite frustrating when using the info command however. Previously I'd used this to sort of pre-view what was about to happen.
I've tried running the command in as many ways as I can think of.
I've now tried three versions of flyway too!
I am currently using flyway-9.7.0 on a windows 10 computer. I am trying to execute my migration scripts on an Oracle 19C database.
I am executing these commands:
flyway migrate -url=jdbc:oracle:thin:#//<URL>:<PORT>/<DB_NAME> -user=<DB_USER> -password=<Password>
-locations=filesystem:C:\flyway-9.7.0\migrations -outputFile=C:\flyway-9.7.0\migrations\out.log
flyway info -url=jdbc:oracle:thin:#//<URL>:<PORT>/<DB_NAME> -user=<DB_USER> -password=<Password>
-outputFile=C:\flyway-9.7.0\migrations\out.log
Both of these commands execute successfully (apparently).
For the "migrate" command the database objects are created in the database, an entry is added to the schemas flyway_schema_history table and a log file is created as specified (but is empty)
For the "info" command the log file is again created (empty)
I get nothing written to the windows CMD window that I am executing the command in however!
Please, what can I do to see some feedback from my commands?

Getting Sqldeveloper working with instantclient on Windows without admin privileges?

I've installed Sqldeveloper Version 19.1 64-bit Version on an enterprise PC with Win10-64bit.
It works fine with embedded jdbc-client, but I need to get it working using the Oracle OCI-client. One reason is the much better support to cancel long running queries.
Using an OCI-client (thick-driver) requires for sure a client like instantclient_12_2.
I have no admin privileges on my workstation and so copied the full instantclient_12_2 to the enterprise PC.
Since I'm not allowed to change the %PATH% myself, I created a start.bat file with required settings, because without, it also won't work (already tried).
PATH="C:\Users\myuser\OneDrive\Oracle\instantclient_12_2";%JAVA_HOME%;%PATH%
C:\Users\myuser\OneDrive\Oracle\sqldeveloper64\sqldeveloper.exe
When I try to configure another Oracle-Client without this change, I get another error, that PATH to instantclient needs to be defined before any others.
Now, starting sqldeveloper with this bat-file works fine. Connections can be established using the internal jdbc client.
Then, I've configured the Oracle Client in SQLdeveloper (Preferences/Database/Advanced) and selected the instantclient directory.
Pressing the "Test" button opens the Messages log "Oracle Client Test Results - Log" and shows an error.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occured, Program will exit.
Unrecognized option: -
Now, I'm lost, because I'm not a Java-Expert. I'm wondering, why sqldeveloper as Java-tool is running, but the instant-client says it can't create the JVM.
The reason for me to use OCI-client is, that it has e.g. better support of User-breaks.
Without admin privileges and no permission to change your %PATH% env permanently, you only need to install the whole directory somewhere and add a .BAT file, that changes environment temporarily before calling SQL-Developer.
Install complete SQL-Developer e.g. in C:\myprogs\sqldeveloper
Install instant-client somewhere, e.g. in C:\myprogs\instantclient_12_2
Create .BAT file, e.g. C:\myprogs\sqldeveloper\startsqldev.bat with following content:
set PATH=C:\myprogs\instantclient_12_2;%PATH%
REM start sqldeveloper
"C:\myprogs\sqldeveloper\sqldeveloper.exe"
It works for versions > 20 as well ;-)
Meanwhile, I've solved it.
Result of testing:
Testing the Instant Client located at C:\Users\myuser\Oracle\instantclient_12_2
Testing client directory ... OK
Testing loading Oracle JDBC driver ... OK
Testing checking Oracle JDBC driver version ... OK
Driver version: 12.2.0.1.0
Testing testing native OCI library load ... OK
Success!
Reason were following mistakes:
Forgot "set" in front of Variable assignment (because I'm usually using Unix)
Used quotation marks during Variable assignment, which are taken as part of the value (also different to UNIX).
Added JAVA_HOME and JRE_PATH
See below my complete bat-file (adapted, because of some secret information within pathnames):
REM Optional: setting of USE_OS_DATETIME_FORMAT changes DATE-Format
set USE_OS_DATETIME_FORMAT=1
set PATH=%USERPROFILE%\OneDrive - myCompany\Oracle\instantclient_12_2;%JAVA_HOME%;%PATH%
REM start your preferred sqldeveloper
"%USERPROFILE%\OneDrive - myCompany\Oracle\sqldeveloperx64.20.2\sqldeveloper.exe"C:\Users\myuser\OneDrive - myCompany\Oracle\sqldeveloperx64.19.1\sqldeveloper.exe"
Additionally, I've added a shortcut to the bat-file and now I can start it simply with CRTL-SHIFT-S ;-)
BTW: Same solution works fine on Win10 as well

LINQPad script fails using lprun, works otherwise, need steps to diagnose the issue

Some environment details:
LINQPad v4.47.02(AnyCPU)
OS Name Microsoft Windows Server 2012 Standard
Version 6.2.9200 Build 9200
System Type x64-based PC
I am trying to figure out how I might diagnose an issue I am encountering when launching a script via the lprun.exe command line utility. When I run the script from the IDE interactively it runs and completes without any exceptions.
When the same script is run under the same user from the command line using: lprun.exe
I get this output.
c:\SQLTasks\Linqpad\Demographics\Demo_GenerateDemographicsSubset.linq(880,20) :
error CS0029: Cannot implicitly convert type 'string' to 'char?'
Due to how LINQPad compiles the script I cant easily locate the area in my script that might be causing this and I'd really like to know if possible what mechanisms might allow it to work interactively and fail from the command line.
Please refer to the discussion on the LINQPad forum: http://forum.linqpad.net/discussion/437/lprun-exe-runtime-error-doesn-t-hapen-when-script-is-run-from-linqpad-ide#latest
Edit: this was due to a bug in how LINQPad reads configuration settings in command-line mode. The bug was fixed as of v4.48.

Oracle 10g - Run a job that executes a batch file in local disk

I'm trying to run a .bat file after my stored procedure has done running. The purpose of the batch file is to create logs based on the code in the stored procedure. But I don't know how to run a .bat or even an exe file using PL/SQL Oracle.
The oracle scheduler can execute OS programs (on the DB server), and you can create a scheduled jobs from pl/SQL.
Look at the documentation of DBMS_SCHEDULER package - http://docs.oracle.com/cd/E11882_01/appdev.112/e25788/d_sched.htm#i1000363

Migrating ANT sqlplus execution from MacOSX to Windows, getting TNS error

I have a working ANT build.xml that executes sqlplus to compile PL/SQL. I develop on MacOSX. My coworker is going to start contributing to the same application. He develops on WinXP. The sqlplus exec from ANT returns a TNS ORA-12560 error on WinXP. The identical build.xml works on MacOSX. The run string that ANT should be constructing on WinXP works in the DOS shell. We have set up the TNS_ADMIN environment variable in WinXP. What could I be missing?
I'm not sure from your description whether you're using the ANT SQL Task (http://ant.apache.org/manual/Tasks/sql.html) or if your using the exec task to call Sqlplus. Can you please clarify?
If you're calling sqlplus as an external command, you will be at the mercy of two main things:
a) environment variables
b) tnsnames.ora file
Windows and unix are different in how they handle specifying where you want to connect. In OSX you'll have the ORACLE_HOME and ORACLE_SID environment variables set. In Windows this would be in the registry. You may also have TNS_ADMIN set which determines where your tnsnames.ora file will be found.
First thing to check would be if you are both using the same tnsnames.ora file.
If you are, have both of you try to run tnsping to verify that the alias is configured properly.
Get back to us with the results of those tests.

Resources