Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Java Virtual Machine

807597Oct 15 2005 — edited Oct 17 2005
Why is Java compiler called as Java Virtual Machine? What does it actually signify by VIRTUAL MACHINE?

Comments

Oyvind Isene

Interesting, I would like to try to reproduce your problem. Do you mind posting a short example with command and code you try to reformat? Screen shot is fine.

brouveure

I am using the below command from the path where the sdcli.exe file is available in the SQLDEVELOPER BIN directory

Capture.JPG

I have placed my PL/SQL packages in the folder E:\FORMAT_IN for which I am trying to do the code formatting

Oyvind Isene

Sorry I can't help you; I reproduced a similar error message in both version 17.4 and 17.3: "Failed to create the processor for command format" Since all the other commands to sdcli works I guess a component is left out from these distributions. I found an older version  (4.1.3) and with that one it works.

brouveure

Hi,

Thanks for the update, for me also the SDCLI command works, but I am unable to format the PL/SQL code , in lower version of 4.2 , the advanced formatting option does not exist which is required for formatting PL/SQL, the SDCLI command in lower versions only formats the SQL commands.

Please find the screenshot of the feature missing in below versions of 4.2

Capture1.JPG

Gaz in Oz

As a work around use sqlcl's "FORMAT" command:

https://docs.oracle.com/database/sql-developer-17.4/SQCQR/toc.htm#SQCQR-GUID-6736ADCE-ABD9-49B8-91E5-7973221DC434

FORMAT [BUFFER | RULES <filename> | FILE <input_file> <output_file>]

Where

    FORMAT BUFFER - formats the script in the SQLcl Buffer

    FORMAT RULES <filename> - Loads SQLDeveloper Formatter rules file to formatter

    FORMAT FILE <input_file> <output_file>

[Edit: added sqlcl inline help for FORMAT:

SQL> version

Oracle SQLDeveloper Command-Line (SQLcl) version: 17.4.0.354.2224

SQL> format

FORMAT

---------

FORMAT BUFFER - formats the script in the SQLcl Buffer

FORMAT RULES <filename> - Loads SQLDeveloper Formatter rules file to formatter.

FORMAT FILE <input_file> <output_file>

Format used is default or for SQLcl can be chosen by setting an environmental variable

pointing to a SQLDeveloper export (.xml) of formatter options.

The variable is called SQLFORMATPATH

In SQLDeveloper the format options are the default chosen in the preferences.

SQL>

]

def sounds like a bug, please report to My Oracle Support

using SQLcl as a workaround is a good suggestion, might be faster (much faster than sdcli too!)

Jeff

brouveure

Thanks Jeff, already reported in My Oracle support.

SR Number : 3-16562725141

brouveure

Correct SR Number : 3-16562724151

Gaz in Oz

Here's a working sqlcl example of formatting sql files in F:\IN directory and writing the formatted files to F:\OUT:

F:\Oracle>type format.sql

script

   sqlcl.setStmt('version'); sqlcl.run();

   /* include helpers.js from github, as written by krice etal */

   load('https://raw.githubusercontent.com/oracle/Oracle_DB_Tools/master/sqlcl/lib/helpers.js');

   /* Get File names */

   var cmd = 'cmd /c "for /f %i IN ( \'dir/s/b f:\\IN\\*.sql\' ) DO @echo format file %~fi f:\\OUT\\%~nxi"'

   ctx.write("Debug: " + cmd + "\n");

   var files = helpers.exec(cmd).stdout.split("\n");

   // Uncomment if you want to "include" SQLDeveloper export formatter rules file.

   // sqlcl.setStmt('format rules your_exported_format_rules.xml');

   // sqlcl.run();

   for (f in files) {

      ctx.write(files[f] + "\n");

      /* FORMAT the file(s) */

      sqlcl.setStmt(files[f]);

      sqlcl.run();

   }

/

exit;

F:\Oracle>sql -s /NOLOG @.\format.sql

Oracle SQLDeveloper Command-Line (SQLcl) version: 17.4.0.354.2224

Debug: cmd /c "for /f %i IN ( 'dir/s/b f:\IN\*.sql' ) DO @echo format file %~fi f:\OUT\%~nxi"

format file f:\IN\x.sql f:\OUT\x.sql

format file f:\IN\y.sql f:\OUT\y.sql

format file f:\IN\z.sql f:\OUT\z.sql

F:\Oracle>

(For this to work on linux, the "var cmd =" line would be changed to a linux command).

1 - 9
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 14 2005
Added on Oct 15 2005
25 comments
346 views