Skip to Main Content

SQLcl: MCP Server & SQL Prompt

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!

23.1: @script- starts script.sql, not script-.sql as expected [Fixed in 23.3]

user9540031Apr 22 2023 — edited Oct 25 2023

Tested on Windows 7 and 10

Steps to reproduce:

1/ Create the following files in your working directory

1.a/ tst-.sql

prompt === tst-.sql

1.b/ tst--.sql

prompt "=== tst--.sql"

2/ Test in SQLcl 23.1

2.a/ Start the above 2 scripts, as shown below.

Remark: pressing Ctrl+R in order to submit the command line is mandatory, otherwise SQLcl will not understand that the command line is complete and self-sufficient.

% sqlcl /nolog

SQLcl: Release 23.1 Production on Sat Apr 22 14:59:18 2023

Copyright (c) 1982, 2023, Oracle.  All rights reserved.

SQL> @tst-

Error starting at line : 1 in command -
@tst-
Error report -
SP2-0310: Unable to open file: "tst.sql"

SQL> @tst--

Error starting at line : 1 in command -
@tst--
Error report -
SP2-0310: Unable to open file: "tst.sql"

Well… That's unfortunate! SQLcl seems to have stripped the trailing hyphens (-) at the end of the filenames :-(

But it gets worse!

2.b/ Now create the following file in the working directory:

tst.sql

prompt === tst.sql
define foo = ""
@@tst-&foo

Then call that script in SQLcl 23.1:

% sqlcl /nolog

SQLcl: Release 23.1 Production on Sat Apr 22 15:19:13 2023

Copyright (c) 1982, 2023, Oracle.  All rights reserved.

SQL> @tst
=== tst.sql
=== tst.sql
=== tst.sql
=== tst.sql
=== tst.sql
=== tst.sql
=== tst.sql
=== tst.sql
=== tst.sql
=== tst.sql
=== tst.sql
=== tst.sql
=== tst.sql
=== tst.sql
=== tst.sql
=== tst.sql
=== tst.sql
=== tst.sql
=== tst.sql

Error starting at line : 3 File @ E:\Home\user9540031\Temp\tst.sql
In command -
@@tst-&foo
Error report -
SP2-0309: SQLcl command procedures may only be nested to a depth of 20.

Could it be worse? Definitely.

2.c/ Update tst.sql, as follows:

prompt === tst.sql
define foo = ""
define bar = "--"
@@tst-&foo
@@tst&bar

Then try it again in SQLcl 23.1.

I'll spare you the readout; suffice to say it looks much like an infinite loop… (which can be stopped by pressing Ctrl+C)

This may break SQL scripts which depend on @ or @@ to call the appropriate script.

SQLcl 22.4 and SQL*Plus (tested on 19.17) work as expected, e.g.:

SQLcl: Release 22.4 Production on Sat Apr 22 15:30:21 2023

Copyright (c) 1982, 2023, Oracle.  All rights reserved.

SQL> @tst-
=== tst-.sql

SQL> @tst--
=== tst--.sql

SQL> @tst
=== tst.sql
=== tst-.sql
=== tst--.sql

Remark: calling @tst-.sql, with the .sql extension being present, works as expected: only trailing hyphens (-) in the absence of the .sql extension are stripped by SQLcl 23.1.

Regards,

This post has been answered by user9540031 on Oct 25 2023
Jump to Answer
Comments
Post Details
Added on Apr 22 2023
2 comments
314 views