Flylib.com

Books Software

 
 
 

RUNSQLSTM


RUNSQLSTM

IBM now includes the RUNSQLSTM command, shown in Figure 25.40, within the base operating system for i5 and iSeries. In earlier releases of the operating system, this command was provided through a licensed program product. Similar to the GUI Run SQL Scripts application discussed earlier in this chapter, this command executes the SQL statement stored in a source file on the i5 server. Use the editor of your choice to enter the statements.

image from book
Figure 25.40: RUNSQLSTM Command.

If you are not using commitment control, be sure to change the commitment control parameter to *NONE when performing any database updates. Otherwise, the SQL updates will fail. The Naming parameter of *SYS indicates that file and library names are separated by a ‘/’ *SQL changes the separator to a period (‘.’).

The Source file and member reference a prewritten SQL statement, such as that shown in Figure 25.41.

image from book
Figure 25.41: MYSQLCMD opened using LPEX Editor in WDSC.

The code in the MYSQLCMD source member actually includes two separate SQL statements. Just as with the Run SQL Script wizard, multiple SQL statements may be entered with a semi- colon (‘;’) ending each statement. The RUNSQLSTM command will execute every statement in the source file. If an error occurs, the command will abort and issue the message RUNSQLSTM command failed.

If this message is sent, see the job log for more information on the specific cause of the failure. The RUNSQLSTM command is a useful tool when you have a series of static SQL statements to execute. With no convenient method for passing parameters to the statement, its usefulness remains somewhat limited.



Summary

SQL is a new and exciting frontier for many i5 developers. If you have not already begun your journey into this new world of database management, get started soon. As the demand for web enablement and client integration increases , SQL becomes an increasingly valuable tool. Virtually the only database option that spans all the various platforms and languages involved in todays IT world, SQL is a defining skill set. You must choose to be a "Have" or a "Have Not"



Chapter 26: JAVA on i5 and iSeries

Java is a relatively new language on the iSeries. Many people talk about it, but few i5 veterans know much about Java. This chapter is devoted to "demystifying" Java. It covers the very bare bones basics of the Java language, not enough to enable you to crank out Java applications. The complexities involved in developing and deploying full Java applications are beyond the scope of what we can do in this chapter. Instead, we will focus on introducing the basics so that, when you do take on the challenge of developing your first Java application, the foundation of the language will already be set, and you can focus on the application rather than the syntax.

What Is Java?

Java is a powerful new programming language resembling C++. In 1995, James Gosling of Sun Microsystems worked on a project to develop a language for programming smart home appliances. While doing so, he became frustrated with the C++ language and he decided to come up with something better. He removed all the things he did not like from C++, and the result was Java. Even though the project failed, Java found a home in programming for web browsers. It received a lot of media attention and its popularity quickly grew. What makes Java so popular? What gives Java its great potential?

  • Java is platform-neutral.

  • Java is object-oriented.

  • Java has no pointers.

  • Java is simple (compared to C++).

  • Java has automatic garbage collection.

The Java compiler does not create machine-executable code. Rather, it creates Java Class objects (programs) containing Java Byte Code. This symbolic form represents a generic task with no specific instructions for performing that task on any particular computer system. Each operating system that supports Java has its own Java Virtual Machine (JVM). As illustrated in Figure 26.1, the JVM interprets the byte code of each Java class object and translates that into the specific instructions needed on that particular computer system. This makes Java platform-independent and allows developers to use Java to create applications that run on virtually any platform.

image from book
Figure 26.1: JVM architecture.

Procedural languages such as RPG and COBOL make up the majority of the traditional applications on the i5 platform. These languages focus on providing instructions to the computer. Object-oriented languages, such as Java, focus on creating structures that reflect the real-world behavior of whatever they model.

Modeling uses the class objects mentioned earlier. Class objects represent a single real-world object. This could be anything: a person, a document, or even a vehicle. Figure 26.2 demonstrates that each class has properties that describe its attributes and methods that describe its actions. In addition, each class can inherit the properties and methods of another class.

image from book
Figure 26.2: Object orientation and inheritance.

One of the key differences between Java and C++, its predecessor, is that Java does not allow direct manipulation of memory pointers. Allowing programmers to work directly with pointers is both a powerful and dangerous technique. Java avoids pointers to make it safer and easier to use.

Another complex aspect of C++ that Java omits is polymorphism. In C++, polymorphism allows objects to inherit properties and methods from multiple parent objects. Managing this and resolving conflicts can be a challenge, so Java uses a simpler single inheritance model. Each class object may inherit properties and methods from only one parent class.

Memory management is challenge for most programmers. Applications often have "memory leaks," meaning that memory was allocated for some task and not released when the task was complete. Over time, this slows down the computer and eventually forces a reboot. Java assists programs deal with the unneeded objects through a process called garbage collection. Periodically, the JVM will identify unneeded classes and clean them up.