Forum Stats

  • 3,750,552 Users
  • 2,250,192 Discussions
  • 7,867,005 Comments

Discussions

sqlprompt with particular colors - how my login.sql should look like?

User_A36HO
User_A36HO Member Posts: 40 Red Ribbon
edited Jan 3, 2018 7:20PM in SQLcl

Hello -

In my sqlcl prompt currently looks like this

[email protected] >

with no particular colors.

Let's say, i would like to have "SCOTT" in green color and "ORCL" in red color.

How this can be done by editing my login.sql file?

SET sqlprompt "' '_user '@' _connect_identifier >"

Thank you,

vr - i love sqlcl

KayK
«1

Answers

  • Gaz in Oz
    Gaz in Oz Member Posts: 3,778 Bronze Crown
    edited Jan 2, 2018 6:06PM
    SET sqlprompt "@|GREEN  ' '_user|@ '@' @|RED  _connect_identifier|@ >"
    KayK
  • User_A36HO
    User_A36HO Member Posts: 40 Red Ribbon
    edited Jan 2, 2018 6:25PM

    Getting long Java exception block after trying your suggested solution.

    Here is the bottom part of this Java exception:

    Jan 02, 2018 5:23:21 PM oracle.dbtools.raptor.scriptrunner.cmdline.SqlCli log

    SEVERE: No enum constant org.fusesource.jansi.AnsiRenderer.Code.GREEN

    java.lang.IllegalArgumentException: No enum constant org.fusesource.jansi.AnsiRenderer.Code.GREEN

            at java.lang.Enum.valueOf(Enum.java:238)

            at org.fusesource.jansi.AnsiRenderer$Code.valueOf(AnsiRenderer.java:127)

            at org.fusesource.jansi.AnsiRenderer.render(AnsiRenderer.java:105)

            at org.fusesource.jansi.AnsiRenderer.render(AnsiRenderer.java:92)

            at org.fusesource.jansi.Ansi.render(Ansi.java:500)

            at oracle.dbtools.raptor.scriptrunner.cmdline.SqlCli.getPrompt(SqlCli.java:1039)

            at oracle.dbtools.raptor.scriptrunner.cmdline.SqlCli.startSQLPlus(SqlCli.java:1046)

            at oracle.dbtools.raptor.scriptrunner.cmdline.SqlCli.main(SqlCli.java:477)

    No enum constant org.fusesource.jansi.AnsiRenderer.Code.GREEN

  • Gaz in Oz
    Gaz in Oz Member Posts: 3,778 Bronze Crown
    edited Jan 2, 2018 6:55PM
  • User_A36HO
    User_A36HO Member Posts: 40 Red Ribbon
    edited Jan 2, 2018 8:19PM

    Yes, I do understand and appreciate that it works in your particular case, in your environment.

    However, the same line

    SET sqlprompt "@|GREEN  ' '_user|@ '@' @|RED  _connect_identifier|@ >"

    does NOT work for me.

    So, may be, if I post here full JAVA exception stack, it can be helpful in resolving my issue:

    +++++++++++++++++++++++++++

    Jan 02, 2018 7:15:01 PM oracle.dbtools.raptor.newscriptrunner.ScriptExecutor run
    SEVERE: java.lang.Enum.valueOf(Enum.java:238)
    java.lang.IllegalArgumentException: No enum constant org.fusesource.jansi.AnsiRenderer.Code.GREEN
            at java.lang.Enum.valueOf(Enum.java:238)
            at org.fusesource.jansi.AnsiRenderer$Code.valueOf(AnsiRenderer.java:127)
            at org.fusesource.jansi.AnsiRenderer.render(AnsiRenderer.java:105)
            at org.fusesource.jansi.AnsiRenderer.render(AnsiRenderer.java:92)
            at org.fusesource.jansi.Ansi.render(Ansi.java:500)
            at oracle.dbtools.raptor.scriptrunner.commands.SetSQLPrompt.doHandleCmd(SetSQLPrompt.java:55)
            at oracle.dbtools.raptor.newscriptrunner.commands.AForAllStmtsCommand.handleEvent(AForAllStmtsCommand.java:37)
            at oracle.dbtools.raptor.newscriptrunner.CommandRegistry.fireListeners(CommandRegistry.java:443)
            at oracle.dbtools.raptor.newscriptrunner.ScriptRunner.run(ScriptRunner.java:217)
            at oracle.dbtools.raptor.newscriptrunner.ScriptExecutor.run(ScriptExecutor.java:342)
            at oracle.dbtools.raptor.newscriptrunner.ScriptExecutor.run(ScriptExecutor.java:225)
            at oracle.dbtools.raptor.newscriptrunner.SQLPLUS.runLoginSQLFile(SQLPLUS.java:2866)
            at oracle.dbtools.raptor.newscriptrunner.SQLPLUS.runUserLoginSQL(SQLPLUS.java:2774)
            at oracle.dbtools.raptor.newscriptrunner.SQLPLUS.runConnect(SQLPLUS.java:2590)
            at oracle.dbtools.raptor.newscriptrunner.SQLPLUS.run(SQLPLUS.java:217)
            at oracle.dbtools.raptor.newscriptrunner.ScriptRunner.runSQLPLUS(ScriptRunner.java:413)
            at oracle.dbtools.raptor.newscriptrunner.ScriptRunner.run(ScriptRunner.java:250)
            at oracle.dbtools.raptor.newscriptrunner.ScriptExecutor.run(ScriptExecutor.java:342)
            at oracle.dbtools.raptor.newscriptrunner.ScriptExecutor.run(ScriptExecutor.java:225)
            at oracle.dbtools.raptor.scriptrunner.cmdline.SqlCli.handleLoginSql(SqlCli.java:895)
            at oracle.dbtools.raptor.scriptrunner.cmdline.SqlCli.main(SqlCli.java:469)

    Jan 02, 2018 7:15:02 PM oracle.dbtools.raptor.scriptrunner.cmdline.SqlCli log
    SEVERE: No enum constant org.fusesource.jansi.AnsiRenderer.Code.GREEN
    java.lang.IllegalArgumentException: No enum constant org.fusesource.jansi.AnsiRenderer.Code.GREEN
            at java.lang.Enum.valueOf(Enum.java:238)
            at org.fusesource.jansi.AnsiRenderer$Code.valueOf(AnsiRenderer.java:127)
            at org.fusesource.jansi.AnsiRenderer.render(AnsiRenderer.java:105)
            at org.fusesource.jansi.AnsiRenderer.render(AnsiRenderer.java:92)
            at org.fusesource.jansi.Ansi.render(Ansi.java:500)
            at oracle.dbtools.raptor.scriptrunner.cmdline.SqlCli.getPrompt(SqlCli.java:1039)
            at oracle.dbtools.raptor.scriptrunner.cmdline.SqlCli.startSQLPlus(SqlCli.java:1046)
            at oracle.dbtools.raptor.scriptrunner.cmdline.SqlCli.main(SqlCli.java:477)
    No enum constant org.fusesource.jansi.AnsiRenderer.Code.GREEN
    The system cannot find the path specified.

  • Gaz in Oz
    Gaz in Oz Member Posts: 3,778 Bronze Crown
    edited Jan 3, 2018 2:06AM

    Please suplply:

    . Your OS and version (windows "ver", unix/linux What is the shell command to determine the version of Unix or Linux that is currently running? )

    . Your sqlcl version

    . Your java version (sqlcl "show java").

    Yes, it is your environment.

    Have you set your path variable to include

    .../sqlcl/

    .../sqlcl/bin

    .../directory/to/jdk/bin

    ...

    Is JAVA_HOME set?

  • Gary Graham-Oracle
    Gary Graham-Oracle Member Posts: 3,256 Bronze Crown
    edited Jan 3, 2018 3:14AM

    Could it be that the jar file that should contain AnsiRenderer.Code.GREEN (sqlcl\lib\jline.jar) got corrupted somehow?

  • User_A36HO
    User_A36HO Member Posts: 40 Red Ribbon
    edited Jan 3, 2018 1:21PM

    sqlcl version:

    sqlcl-17.4.0.354.2224-no-jre

    +++++++++++++++++++++++++++++++++++++++++

    .  java version (sqlcl "show java").

    show java

    Java Detail

    -----------

    java.home= C:\Program Files\Java\jdk1.8.0_152\jre

    java.vendor= Oracle Corporation

    java.vendor.url= http://java.oracle.com/

    java.version= 1.8.0_152

    --------------------------------------------------------------------------------

    os.arch= amd64

    os.name= Windows 10

    os.version= 10.0

    .... more lines here that I cut off

    ++++++++++++++++++++++++++++++++

    Again, it does work for me without colors i.e my login.sql is this:

    SET sqlprompt "'I am: '_user '@' _connect_identifier >"

    then I have NO ISSUES.

    I guess I can live without colors, not a big issue.

    What is troubling in my view that "SqlCL" is such a "delicate flower".

    Even minor change (such this color attempt) completely destroys the whole interface.

    ++++++++++++++++++++++++++++++++++++++++

    Another question that I wondering about: why for Windows environment we have two executables:

    sql.exe

    and

    sql.bat

    ++++++++++++++++++++++
    I wonder what document or article explains when to use "sql.exe" vs. "sql.bat" ? etc.

    Back to the color issue, I have included all above suggested ideas, and still getting the same java error stack.

    Do we need to setup CLASSPATH as well?

    and how about settings for SQLPATH or SQL_PATH?

    Do we need those?

    Thank you,

    vr

  • Gary Graham-Oracle
    Gary Graham-Oracle Member Posts: 3,256 Bronze Crown
    edited Jan 3, 2018 2:35PM

    Well, the essence of my prior post was to suggest that perhaps your extract utility did not install SQLcl 17.4 correctly from the zip file.  I personally use 7-zip, per Oracle IT. 

    When I open a Cmd window I may want to do more than just use SQLcl, so this is more than one needs, but in terms of environment variables here is an example of what I use...

    EnvSettingsForSQLcl.jpg

    And I have the habit of starting SQLcl from its own bin directory, so I never add the SQLcl stuff to my PATH

  • User_A36HO
    User_A36HO Member Posts: 40 Red Ribbon
    edited Jan 3, 2018 2:52PM

    Thank you, I would have to spend more time on making my setup for sqlcl identical to what you've just posted in above.

    I will update this thread later on today or tomorrow.

    But aside from the above, would you explain why do we have "sql.exe" and "sql.bat"?

    When do you use "sql.exe" vs. "sql.bat"?

    What web posts is available to explain this area?

    Regards,

    vr

  • User_A36HO
    User_A36HO Member Posts: 40 Red Ribbon
    edited Jan 3, 2018 5:56PM

    No luck yet after trying to apply all your recommendations in my environment.

    Long JAVA error stack is no longer returned but instead I am getting two lines error:

    Environment variable echo on not defined

    The syntax of the command is incorrect.