Skip to main content

Related Articles

How To Create Stored Procedures Using iSeries Navigator

In conventional method it is not very straight forward to write stored procedures with DB2 in AS400 environment. You might need to remember lot of syntax or might need to refer books to find syntax to code the procedures. This is very inefficient method for today's database programming context. iSeries Navigator has been provided very cool feature to develop your stored procedures from the iSeries Navigator graphical UI. You don't need to remember all the syntax to write database coding and the tool itself given you all the syntax which are required to write your coding. Only you have to do is insert them into your coding and make necessary modifications.



Login to your iSeries Navigator and browse your database that you want to create new stored procedure and select "Procedures" section.

Fig 1: Select you database and Procedures in iSeries Navigator pane
Right click on Procedures and select "New" to create new stored procedure. There are two options to select either "SQL" or "External" type procedure to create. If you select ""SQL" you can write your new procedure using SQL syntax. Also you can use separate external program written using C, C++, CL, COBOL, COBOLLE, PLI, REXX, RPG, RPGLE and Java by selecting "External" option. This is very flexible method since high level programming languages are provided much more freedom to code complex coding than SQL language. This article is focus on develop a procedure using SQL language.

Fig 2: Create new SQL type procedure
Provide procedure name, description, maximum number of result set, data access and specific name in General tab of "New SQL Procedure" window.
Fig 3: New SQL Procedure General Tab

In Parameters tab you can specify what are parameters for the procedure. Click on "Insert" button to add new parameter, once you added new parameter you can change its name, data type, length and In/Out option.
Fig 4: New SQL Procedure Parameters Tab

Next step is develop SQL logic for the procedure. For that select "SQL Statements" tab in New SQL Procedure window. In SQL Statements tab you will have "SQL Statements examples" drop down list, Insert button and Statements section. From drop down list select what is the syntax that you want to insert into your code. This drow down list will show all the required SQL syntax to develop your SQL code. Once you select the statement, click on Insert button to enter selected statement into your code. After inserting default statement you can modify as you wish. For example you can change variable names, data types etc. Advantage here is you don't need familiar with all the syntax, but you can simply insert them and modify according to your requirement. You can put any number of statements to build up your SQL code.
Fig 5: New SQL Procedure SQL Statements Tab
In the above example I have inserted variable initialization and alter table SQL code. You can modify this inserted default code like below example.
SET myCounter= 4;
ALTER TABLE Customer ADD COLUMN Age INTEGER;
In first line I have initialized the variable called "myCounter" to 4. In second line I have alter the Customer table and add Age column.
In this way very easily you can develop your SQL program for your stored procedure. This is very efficient method and very time saving. But initially you might need to get little familiar with tool. Good luck and happy coding !

Comments

  1. Were you able to return result sets this way?

    ReplyDelete
  2. If you want to return result set of select command, you can define a cursor for select command and open that cursor at the end of the SP. If you are planing to get a result using parameter you can define them as out parameters. You can do this when you create new SP using parameters tab and change In/Out value to OUT. Assign this OUT variable inside in the SP. You can directly read OUT parameter when you call your SP.

    ReplyDelete

Post a Comment

Popular posts from this blog

Angular PrimeNG checkboxes styling and events handling

  Getting Started With PrimeNG Styling in Angular App This chapter I am planning to show how you can handle events of the checkboxes. For that I will use checkbox for every card to place the order.  To use PrimeNG checkboxes you have to import checkbox module in app.module.ts file. import {CheckboxModule} from 'primeng/checkbox'; import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { LandingComponent } from './modules/landing/landing.component'; import { HomeComponent } from './modules/home/home.component'; import { CardModule } from 'primeng/card'; import {CheckboxModule} from 'primeng/checkbox'; @NgModule({ declarations: [ AppComponent, LandingComponent, HomeComponent ], imports: [ BrowserModule, AppRoutingModule, CardModu

The Power of ChatGPT and Whisper Models

A Deep Dive into Natural Language Processing Natural Language Processing (NLP) has seen a significant boost in recent years due to advancements in artificial intelligence and machine learning. Two models that have shown remarkable success in NLP are ChatGPT and Whisper. In this article, we will delve into the power of these models and their applications in the field of NLP. ChatGPT is a transformer-based language model developed by OpenAI that uses unsupervised learning to predict the next word in a sentence based on the context of previous words. ChatGPT is a generative model that is trained on large datasets of text, such as books and articles, and can be fine-tuned for specific tasks, such as question-answering or dialogue generation. ChatGPT is known for its ability to produce human-like text, making it an ideal tool for applications such as chatbots, content creation, and language translation. Whisper, on the other hand, is a paraphrasing model developed by Google that is based on

Getting Started With PrimeNG Styling in Angular App

  This chapter I am going to explain how you can do the styling to our flower store app. There are different kind of CSS frameworks you can use to style you app. Such as: 1.        Angular Material 2.        ngx-bootstrap 3.        NG bootstrap 4.        Prime NG   I am planning to use PrimeNG styling framework to style our flower store app. PrimeNG has more than 80 UI component and it is a collection of rich UI components for Angular. All widgets are open source and free to use under MIT License.   How to Install Prime NG 1.     Run   npm install primeng –save  inside your root folder.                    2.        Run npm install primeicons –save to install prime icons. 3.        Run npm install font-awesome --save to Install Font Awesome 4.        Run npm install @angular/cdk –save to install angular  component dev kit. Now we are done with installing Prime NG to out flower store app. If you check your package json you will see below list of libraries.