12 – Embedded SQL
暂无分享,去创建一个
Publisher Summary
This chapter provides an overview of embedded SQL. Although a knowledgeable SQL user can accomplish a great deal with an interactive command processor, much interaction with a database is through application programs that provide a predictable interface for non-technologically sophisticated users. The chapter focuses on the preparation of programs that contain SQL statements and the special things that should be done to fit SQL within a host programming language. SQL statements can be embedded in a wide variety of languages (host languages). The way of handling source code depends on the type of host language being used. Programs in which SQL is embedded need to be able to intercept the error codes returned by the DBMS and to handle them before the errors reach the end user. When the WHERE predicate in a SELECT statement contains a primary key expression, the result table will contain at most one row. SELECT statements that may return more than one row present a bit of a problem when they are embedded in a program: host language variables can hold only one value at a time and the SQL command processor cannot work with host language arrays. Although many of today's database development environments make it easy to create forms for data entry and modification, situations still arise where data modification has to be included in an underlying application program.