DB2 uses the PL-SQL command as standard in creating procedures resembles other DBMS like SQL Server and MySQL, as we can see in the syntax below:

CREATE PROCEDURE [Procedure Name] ([Parameters])

LANGUAGE SQL

BEGIN

[Commands]

END

The command structure is very simple, but watch it is necessary to inform which a default language that is being used to perform the command.

As a practical example we will create a simple procedure that returns a query table products.

CREATE PROCEDURE product_list

LANGUAGE SQL

BEGIN

SELECT Name, Price

FROM Product

END

You even have the option of using parameters that can be worked in conjunction with command procedure.

CREATE PROCEDURE product_search (IN vcod_prod BIGINT)

LANGUAGE SQL

BEGIN

SELECT Name, Price

FROM Product

WHERE cod_product = vcod_prod

END

In the above example will be returned only with the product code indicated.

ibm-db2

DB2 has been highlighted in web environments and because it is essential to understand their operation, learn about DB2 on PHP environments on our official site.

You might also like…

PROCESAMIENTO AJAX EN SCRIPTCASE

Ajax en los formularios de Scriptcase puede usarse para recargar un campo de tipo de select basado e...

IMPORTAR IMAGENES DE LA BASE DE DATOS Y UTILIZAR CLASES DE BOOSTRAP

Como muchas personas ya saben, Bootstrap es una biblioteca de front-end libre y de código abierto p...

TENDENCIAS DE DESARROLLO WEB PARA 2017

Usted verá en este post tendencias para 2017 en Diseño Web, en el medio digital y en el desarrollo...

Comment this post

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at sales@scriptcase.net. Learn more about our Privacy Police.