{"id":912,"date":"2024-06-11T10:51:54","date_gmt":"2024-06-11T08:51:54","guid":{"rendered":"https:\/\/anjo.pt\/keyword-oracle\/?p=912"},"modified":"2024-06-02T11:16:07","modified_gmt":"2024-06-02T09:16:07","slug":"change-language-and-prompt-in-sqlcl-for-vs-code","status":"publish","type":"post","link":"https:\/\/anjo.pt\/keyword-oracle\/2024\/06\/11\/change-language-and-prompt-in-sqlcl-for-vs-code\/","title":{"rendered":"Change language and prompt in SQLcl for VS Code"},"content":{"rendered":"\n<p>Windows and language settings is a common problem for users outside English speaking countries. The windows language on my laptop is English, but time to time I use another laptop in Portugal with the same Microsoft account as login. This laptop is configured in Portuguese. My work laptop&#8217;s keyboard is Swiss, locale also set for Switzerland. Windows just gets confused and shows some applications in English, others in German, others in Portuguese.<\/p>\n\n\n\n<p>Today I was testing SQLcl inside VS Code. I tried the help function and get answers in German, plus with the \u00f6\u00e4\u00fc signs wrong. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/06\/image.png\"><img loading=\"lazy\" decoding=\"async\" width=\"976\" height=\"219\" src=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/06\/image.png\" alt=\"\" class=\"wp-image-913\" srcset=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/06\/image.png 976w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/06\/image-300x67.png 300w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/06\/image-768x172.png 768w\" sizes=\"auto, (max-width: 976px) 100vw, 976px\" \/><\/a><\/figure>\n\n\n\n<p>So I needed to change it to English. Based on <a href=\"https:\/\/docs.oracle.com\/en\/database\/oracle\/sql-developer-command-line\/23.2\/sqcug\/starting-and-leaving-sqlcl.html\" data-type=\"link\" data-id=\"https:\/\/docs.oracle.com\/en\/database\/oracle\/sql-developer-command-line\/23.2\/sqcug\/starting-and-leaving-sqlcl.html\" target=\"_blank\" rel=\"noreferrer noopener\">SQLcl documentation<\/a> it reads a file startup.sql once when it starts. And on VS Code, to know where it is currently running, you just have to run the &#8216;pwd&#8217; command:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nSQL&gt; pwd\nC:\\Users\\migue\\\n<\/pre><\/div>\n\n\n<p>Then, on this path, you can create a startup.sql file and change the prompt, and language. My startup.sql starts by changing the display language, then the SQLcl layout and the prompt:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nset feedb off termout off\n-- changes the display language\nalter session set nls_language=american;\n\n-- Changes SQLcl to have word highlight and statusbar\nset highlighting on\nset highlighting keyword foreground green\nset highlighting identifier background blue\nset highlighting string foreground yellow\nset highlighting number foreground cyan\nset highlighting comment foreground white\nset statusbar on\nset statusbar add editmode\nset statusbar add txn\nset statusbar add timing\n\n-- Changes prompt to show the instance and pdb name\nDEFINE prompt=&quot;SQL&quot;\nCOLUMN col_prompt NEW_VALUE prompt\nSELECT UPPER(USER || &#039;@&#039; || SYS_CONTEXT(&#039;userenv&#039;, &#039;instance_name&#039;)) ||&#039;.&#039;|| SYS_CONTEXT(&#039;userenv&#039;, &#039;con_name&#039;) col_prompt FROM dual;\nset sqlprompt &quot;&amp;amp;prompt&gt; &quot; ;\nset termout on feed on\n<\/pre><\/div>\n\n\n<p>At the ends it looks like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/06\/image-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"972\" height=\"347\" src=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/06\/image-1.png\" alt=\"\" class=\"wp-image-914\" srcset=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/06\/image-1.png 972w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/06\/image-1-300x107.png 300w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/06\/image-1-768x274.png 768w\" sizes=\"auto, (max-width: 972px) 100vw, 972px\" \/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Windows and language settings is a common problem for users outside English speaking countries. The windows language on my laptop is English, but time to time I use another laptop in Portugal with the same Microsoft account as login. This laptop is configured in Portuguese. My work laptop&#8217;s keyboard is Swiss, locale also set for [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[79,80],"tags":[],"class_list":{"0":"post-912","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-sqlcl","7":"category-vscode","8":"czr-hentry"},"_links":{"self":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts\/912","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/comments?post=912"}],"version-history":[{"count":2,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts\/912\/revisions"}],"predecessor-version":[{"id":916,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts\/912\/revisions\/916"}],"wp:attachment":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/media?parent=912"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/categories?post=912"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/tags?post=912"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}