BaseX GUI Command Bar Error Unknown Command - basex

I occassionally use BaseX GUI for examining XML files and trying XSL transforms. I don't know what has happened but I can no longer run one-liners in the Command/Find/XQuery bar that sits below the toolbar. I always get "Error unknown command try help". The drop down has recently used commands none of which work any longer.
I have tried upgrading BaseX from 9.3 to 9.7 and upgrading java. I'm running windows 10. My searching didn't yield any results, I hoping someone can help because I'm out of ideas.
Thanks.

The entries shown in your inputbar image are XQuery expressions, with the exception of help which is a command. So changing the mode dropdown from Command to XQuery will enable them to run.
Note: modes XQuery and Find require an open database.
It looks like your XQuery expressions are not database specific so as an alternative you could leave the mode as Command and prefix your text with the command 'XQUERY ' eg XQUERY 1+3 etc

Related

Trying to load local file in stage via Snowflake PUT command but command gets greyed out

I have a simple requirement where I have to put a file in snowflake internal stage.
put file:///Users/priya/Downloads/vistaslagos.csv #canary2022/apartments;
When I try the above, the command is getting greyed out.
I further tried putting single quotes like below but I am getting the error :-->000002 (0A000): Unsupported feature 'unsupported_requested_format:snowflake'.
put 'file:///Users/priya/Downloads/vistaslagos.csv' #canary2022/apartments;
On further checking the error, it says I need to validate the snowflake edition.
Does anyone has context in this?
It seems you are trying to run the command in worksheets(UI). When you do so and give file:///, it considers the further text in the line as comments which is why you see it as greyed out.
Put command cannot be submitted in UI which is why you see the error feature not supported.
Try using snowsql and this should work. It is also mentioned in official documentation as well. Comments and Links for your reference below.
"The command cannot be executed from the Worksheets Worksheet tab page in either Snowflake web interface; instead, use the SnowSQL client to upload data files, or check the documentation for a specific Snowflake client to verify support for this command"
https://docs.snowflake.com/en/sql-reference/sql/put.html#usage-notes
Cheers!!

SQLite Query works in DB Browser but not in VSCode

I have current VSCode and SQLite (alexcvzz) extension installed on Windows 11. Also have DB Browser installed. The following query works perfectly in DB Browser but not in VSCode. I opened DB in VSCode before attempting the query. Any thoughts as to why it's not working? Thanks for any suggestions (FYI, I'm a nooby with SQLite, VSCode and SQL - Please take that into consideration in your response!).
Query
INSERT INTO OwnerTable (UnitID,Owner,SaleDate,Price)
VALUES (10107,'Public, John Q','2022/03/19','280,000');
VSCode Error Message
[12:45:02 PM][vscode-sqlite][INFO] Activating extension vscode-sqlite v0.14.0...
[12:45:02 PM][vscode-sqlite][INFO] Extension activated.
[12:46:27 PM][vscode-sqlite][ERROR] Runtime error near line 4: unable to open database file (14)
PS: I've done numerous other queries in VSCode on same database and table and they have all worked without any issues.
Thanks forpas. I checked out your suggestion just to make sure nothing else was using the data base. Nothing was. Then, I discovered the problem.
I use Windows Ransomware Protection. Thought it might be worthwhile to check it out to see if it was blocking the insert command. It was! It was then that I realized that all the other VSCode queries I had run were information retrieval queries, not queries that wrote to the database. All I had to do was "allow" the SQLite.exe file. That was the difference. Still don't know why it worked for DB Browser but not VSCode.

Play framework evolution script error line number

I'm using evolution scripts, via Slick, using the Play Framework to update the schema for a Microsoft SQL Server database.
This largely works great, except that when something goes wrong, I just get a terse error message, with no indication which line of the script caused the error, and—for large scripts—that makes identifying the error time-consuming and challenging.
For example, consider this error:
An evolution has not been applied properly. Please check the problem and resolve it manually before marking it as resolved. -
We got the following error: , while trying to run this SQL script:
That's it.
Is there a way to get the full error message (through a log file, a configuration setting, etc.) that includes the line number and context, etc. with the evolution failure?
It took me a while, but I finally figured this out.
I edited the conf/logback.xml file to include the following:
<logger name="play.api.db.evolutions" level="DEBUG" />
Each statement in the Ups script is then written to logs/application.log as it is executed, together with its result, including detailed error messages.

How to store the result of an SQL query to an XML file in a specific folder without using cmdshel

I have an SQL Server query and I am using FOR XML PATH to generate the result as XML. I am trying to save the file result.xml to a particular folder of my computer but I do not want to use the "save as" link of SQL Server to do it, because I need to automate my process.
Unfortunately, I cannot use xp_cmdshell solution provided here because I do not have the permissions to do it. In fact I get an error
The EXECUTE permission was denied on the object 'xp_cmdshell', database 'mssqlsystemresource', schema 'sys'
each time I try to execute it.
May anyone help me with that? It would be highly appreciated!
Good day,
like always there are lot of solutions which depend on your knowledge and resources. I will try too give you some ideas here and probably others will be able to add more
Using SQLCLR you can simply create a file and save it (this will require using PERMISSION_SETUNSAFE)
Using Python (basically same as SQLCLR we can do everything with Python including external tasks).
You mentioned that you do not want to use xp_cmdshell at first but after the short discussion I understand that you simply do not succeed to use it, but this is your preferred option. Check this thread on the same topic. You should find the solution there on how to configure the permissions.
Using sp_send_dbmail you can send the result of the query to email. Not like other options this is usually open in most servers. The idea is to send simple email, and using Google Apps you can read the content of the email and create file. You can use for example the methods: GmailApp.getInboxThreads, getMessages(), getRawContent()... and in order to write the file in your Google drive you can use DriveApp.createFile
Using SSIS
Following your advice I took the time to learn how to use C# in order to solve my problem and now it works perfectly! I created a short script that executes my sql query using for xml path and then managed to save the resulting XML file in a specific repertory. Thank you again for the support. So my process is now fully automated. Always nice to learn more!

code template in management studio

Can I find in management studio the Following feature?
I want to write a specific word and that it be replaced by a statement specifies. Ex: I write "ss" and replace "select * from" or write "johnid" and is replaced by "where id = '555 '"
 
In Toad for Oracle You might still in: "option - behsvior - template code - code template"
http://www.toadworld.com/Blogs/tabid/67/EntryId/343/Customizing-Toad-Code-Templates.aspx
There is nothing I know of built into Management Studio that will behave exactly like you are suggesting. There are some shortcuts you can advantage of in Tools > Options > Environment > Keyboard > Query Shortcuts, but these run the code rather than paste them into your window, so you can't use them as partial syntax completion. For example if you assign SELECT * FROM to Ctrl+9, then open a new query window and press Ctrl+9, you have an empty query window and the following error message:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'FROM'.
Chris already mentioned templates, so I won't treat those.
In SQL Server 2012 you can use a new feature (well, an old feature recycled from Visual Studio) called Snippets, which I think is a lot more powerful than the Template feature (I wrote about them here, and someone else did a decent job here). But I still don't think it's quite what you're after - there's a menu system to go through to insert a snippet, and so far in my research I've been unable to assign a keyboard shortcut -- even though there is an empty element in the Snippet XML called <Shortcut></Shortcut>, and most of the people who talk about this feature mention it, but I've yet to see a working snippet that used it (and I have tried many variations to get it work like it does in Visual Studio with no luck).
You can also use 3rd party tools, such as Mladen Prajdic's free SSMS Tools Pack. For what you want to do, I think this is the best fit, since it allows you to do real expansions snippets where the replacement text is put into your code based on the keyword you typed ad further keystrokes. However if you're using SQL Server 2012, at the time of posting we're still waiting on a compatible release for that version of SSMS. You may also want to look into Red-Gate's SQL Prompt, but I'd try Mladen's free tool first if you can. I'm sure there are other alternatives you can turn up with a standard search.
This feature is present in these free add-ins:
SSMSBoost or SSMS Tools Pack
Use Template Explorer
SQL Server provides a variety of templates. Templates are boilerplate files containing SQL scripts that help you create objects in a database. The first time the template explorer is opened, a copy of the templates are placed in the user’s folder in C:\Users, under AppData\Roaming\Microsoft\SQL Server Management Studio\110\Templates.
You can browse the available templates in Template Explorer, then open a template to incorporate the code into a code editor window. You can also create custom templates.

Resources