Wednesday 11 December 2019

HANA Studio – Convenient code snippet storage

This is a quick blog post to show a nifty place to store code snippets in HANA Studio. I’m thinking of snippets that you execute often and lose somewhere in your HANA Studio tabs, the ones where you haven’t been super diligent about saving as sql files. (Confession time, this is me, I have useful code snippets stored in lots of random places that seemed like a good place at the time.)

Note: I know HANA Studio is “dead” with HANA 2.0, however many people are still using it and are still using HANA XS Classic, so perhaps this tip will help someone have a nicer experience in the client tool.

This is also the same spot where you can upload the helpful sql zip file that SAP provides as per “SAP Note 1969700 – SQL statement collection for SAP HANA”.

Using the same concept we’re also able to store our own SQL snippets, here are the steps:

Step 1: Double-click on any system in HANA Studio and then navigate to the “System Information” tab

SAP HANA Studio, SAP HANA Learning, SAP HANA Certifications, SAP HANA Guides, SAP HANA Online Exam, SAP HANA Prep Exam

Step 2. Right-click in the open area and select “New SQL Statement”

SAP HANA Studio, SAP HANA Learning, SAP HANA Certifications, SAP HANA Guides, SAP HANA Online Exam, SAP HANA Prep Exam

Step 3: Give your script a name and description and paste your code in. It must start with SELECT or WITH.

SAP HANA Studio, SAP HANA Learning, SAP HANA Certifications, SAP HANA Guides, SAP HANA Online Exam, SAP HANA Prep Exam

Step 4: You can save using top menu, it will then be available on all systems you’ve configured in HANA Studio and you do not have to repeat the steps per system

SAP HANA Studio, SAP HANA Learning, SAP HANA Certifications, SAP HANA Guides, SAP HANA Online Exam, SAP HANA Prep Exam

Step 5: Your script will now be available on the “System Information” tab.

SAP HANA Studio, SAP HANA Learning, SAP HANA Certifications, SAP HANA Guides, SAP HANA Online Exam, SAP HANA Prep Exam

Step 6: Right-click and select “Execute” to run it

SAP HANA Studio, SAP HANA Learning, SAP HANA Certifications, SAP HANA Guides, SAP HANA Online Exam, SAP HANA Prep Exam

Step 7: The results will be displayed in a data preview screen

SAP HANA Studio, SAP HANA Learning, SAP HANA Certifications, SAP HANA Guides, SAP HANA Online Exam, SAP HANA Prep Exam

Step 8: You can also open the script in the SQL Console by right-clicking and selecting “Open in SQL Console”, perhaps if you want to edit it before executing

SAP HANA Studio, SAP HANA Learning, SAP HANA Certifications, SAP HANA Guides, SAP HANA Online Exam, SAP HANA Prep Exam

SAP HANA Studio, SAP HANA Learning, SAP HANA Certifications, SAP HANA Guides, SAP HANA Online Exam, SAP HANA Prep Exam

Tip: If you perhaps want to store script that doesn’t start with SELECT or WITH :

SAP HANA Studio, SAP HANA Learning, SAP HANA Certifications, SAP HANA Guides, SAP HANA Online Exam, SAP HANA Prep Exam

Then you can just fool it with a dummy select statement followed by your script. It won’t execute if you call the “Execute” function as this is expecting a single result, however you can still open it with SQL Console and execute from there

SAP HANA Studio, SAP HANA Learning, SAP HANA Certifications, SAP HANA Guides, SAP HANA Online Exam, SAP HANA Prep Exam

No comments:

Post a Comment