25
Mon, Nov
1 New Articles

Empowering Your Database

Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

I come from a long line of application programmers who were data-driven procedural programmers. For years, I exclaimed, “There ought to be a file.” Then I quickly slapped together a database file and began to maintain it with an ever-growing number of application programs. Soon, that file, which my fellow programmers and I created in our self-described brilliance, became unwieldy and unmanageable because it is maintained in dozens, or even hundreds, of procedural programs. Yet I, as well as that long line of application programmers that preceded me, knew of techniques that resolved the problems of unmanageable database files. Those techniques were proper database design and modular programming. What my fellow programmers and I needed to was develop active databases. So let me explain how you can use techniques that you are already familiar with to create an active database.

The Normal Way

You’ve all heard about database normalization techniques. You know that while fourth- normal form is academically correct, third-normal form works best for real-world applications. So, I’m not going to preach normalization, but I must mention normalization because an active database must be truly relational. A recent database technique to also consider is the use of user-defined fields, which are known as distinct types. With the use of distinct types, the database developer gains complete control over what types of operations are supported by columns declared as distinct types.

The next step to building an active database is to create constraints and triggers to ensure the integrity of your data. Constraints are rules about how data values can change. Verify and validate data values with such things as column defaults, value checks, data ranges, NOT NULL clauses, and unique constraints. Constraints are also used to ensure referential integrity of associated records from subordinate files using primary and foreign key relationships.

With the database defined, the next step is to add triggers. Triggers are processes that are invoked by the database before and after certain events such as inserts, updates, and deletes. I’m know I’m not telling you anything new, but I want to reiterate what Midrange Computing has said for years: Triggers are a powerful facility for ensuring database integrity.

One of the most optimal ways to implement modular programming is through the use of user-defined functions. Just like constraints and triggers, user-defined functions


should be created during the construction of the database. User-defined functions are invoked from SQL statements from within application programs, thus decreasing the requirement for procedure code within those applications.

Stored Procedures

The final technique used in the construction of an active database is stored procedures. Because stored procedures can be implemented in languages like RPG, COBOL, CL, and C, stored procedures allow your shop to leverage the use of your existing applications and application programmers. In addition to creating stored procedures with a legacy language, I also want to recommend the use of the SQL Stored Procedure Language (SSPL). Along with the file capabilities of SQL, you also have conditional logic, powerful cursor control, error handling, and local variables. SQL works on IBM’s DB2 UDB everywhere, and SSPL is also very close syntactically to the SSPL of Oracle, Sybase, Microsoft’s SQL Server, and Informix.

SSPL is a combination of the strength of standard SQL and a number of procedural commands: CASE, IF, ITERATE/LOOP, FOR, LEAVE, REPEAT WHILE, and BEGIN/END. Your SSPL programs can create variables with DECLARE and modify them with SET. SQL experts will also tell you of the performance benefits of SSPL's dynamic SQL with PREPARE, EXECUTE, and EXECUTE IMMEDIATE.

I've trained several groups of RPG programmers in SSPL programming and many of them are amazed at how quickly they can create powerful programs with SSPL. One trainee in particular mentioned "It seems you really should attempt to write a program first in SSPL before resorting to RPG. And if you do opt for the RPG, the SSPL acts as well- developed psuedo-code."

You can create a SSPL program in a number of ways:

• You can key the SSPL source to an AS/400 source file member and use the Run SQL Statements (RUNSQLSTM) commands to compile the SSPL program.

• You can key the SSPL into OS/400’s interactive SQL, which has the added advantage of interactive syntax checking.

• Or, you can use Operations Navigator.

Regardless of the method, the SSPL source is converted into a C program with embedded SQL and then compiled; with the current version of OS/400 (V4R5), this means your OS/400 machine will have to have a C compiler. (Note that future OS/400 versions may remove the requirement of the C-compiler licensed program.)

Empowerment

You probably already know most of the techniques that I’ve covered. But I think that many of you, like me, are so used to procedural programming that you haven’t taken the time to design active databases. Howard F. Arner, Jr., one of MC’s database experts, once told me that “code moves to data,” which means that algorithms, over time, are replaced with active databases. The most optimal application design is one that has the least amount of code.


Don Denoncourt

Don Denoncourt is a freelance consultant. He can be reached at This email address is being protected from spambots. You need JavaScript enabled to view it..


MC Press books written by Don Denoncourt available now on the MC Press Bookstore.

Java Application Strategies for iSeries and AS/400 Java Application Strategies for iSeries and AS/400
Explore the realities of using Java to develop real-world OS/400 applications.
List Price $89.00

Now On Sale

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: