VS Code for IBM i — Tips and Extras
Visual Studio Code is a widely used IDE in the non-IBM i world. Recently we released Code for IBM i, a freely available extension for VS Code that supports RPGLE and COBOL development for IBM i. You can read about the basics of Code for IBM i and about code coverage functionality in my previous posts.
Today I’m going to cover three additional tips for using Code for IBM i. Of course, for any of this to work, you need to install Code for IBM i.
Tip #1: Viewing SQL results inline
This is such a nifty one. Did you know you can run SQL statements and view the results inline?
- Create or open a member (or streamfile!) with the .sql extension
- Write an SQL statement:
select * from sample.org
- Highlight the statement in the editor and press Control+R (or Command+R on Mac)
- The result should appear in a new tab in a pretty table
Note: The library list is not used when running SQL statements when using this method. You should make sure you are specifying the schemas when accessing SQL objects.
Tip #2: Comparing two sources
It is possible to compare two different sources with Code for IBM i—no matter if they are members, stream files, or a mix.
When you right-click on a source member or a stream file, you will see options to ‘Select for Comparison’ and ‘Compare with Selected’.
- Chose the first source you want to compare. Right-click on it and choose ‘Select for Comparison’
- Chose the source you want to compare it with. Right-click on it and choose ‘Compare with Selected’
- The diff will appear
Note: This works on any source/text documents. Whether it’s RPGLE, COBOL, PHP, JavaScript, etc… it works!
Tip #3: Search contents of source files
Are you looking for something in your source code but forget where it is? Why not search for it with Code for IBM i!
- Right-click on a source file you want to search in from the Member Browser
- A box will appear where you can enter your search term. Enter the term and press enter
- Results will appear when the search is done. The results appear in a new text document with hyperlinks to the member, which when control+clicked on, will open the member in a new tab
Note: This also works for IFS directories.
These are just three ways that Code for IBM i helps you boost your productivity. See Visual Studio Code for IBM i: A Resource Guide for additional information.
As always, for training related to this or any other IBM i development technology, contact us.
What is best way to copy a source member to another library using Code for i?
I also tried below as mentioned by another reader:
“Is it possible to compare source members from two different IBM i systems? Or do they have to be on the same IBM”
For me, it only worked when it was done in one IBMi connection.
When I tried to compare source members from two different IBMi connections,
it did not work.
Hope someone can post a way to do that.
Source member comparison only works within a single IBM i system.
It seems it can’t handle the SQL with more than one SQL statements.
I have two SQL statements in a source member, I only highlighted one of them and press CTRL+R, it highlighted both statements automatically with an error message
SQL0199] Keyword SELECT not expected. Valid tokens: FOR USE SKIP WAIT WITH FETCH LIMIT ORDER UNION EXCEPT OFFSET., 42601, -199
Hello,
Is it possible to compare source members from two different IBM i systems? Or do they have to be on the same IBM i?
We will find out if there is a way to compare from two different IBM i systems.
Source member comparison only works within a single IBM i system.
Hello,
I wonder to learn how to link Code for i and Client Acess to combine for example, sql scripts executions and 5250 terminal.
Thanks for your support.
Best Regards,
I don’t understand the question, but Code for i does support a 5250 terminal (tn5250).