Access Plan and Bind File Options

Embedded SQL for C and SQL Server

Embedded SQL for C and SQL Server

Access Plan and Bind File Options

By using the /DB and /PASS options with the nsqlprep precompiler, you can connect to a specified server and database and create an access plan (set of stored procedures) for each separately compiled program module (compilation unit). With the /DB and /PASS options, nsqlprep makes a connection using the specified server name, database name, login ID, and password. The access plan consists of a separate stored procedure for each static SQL statement in each compiled program module.

By default, the stored procedure names consist of the following:

  • Name of the program module

  • A date/timestamp converted to eight printable ASCII characters

  • A dollar sign ($)

  • The access plan section number

The date/timestamp provides for re-creating stored procedures for the access plan with identical program module names each time the program is compiled. However, if you use the /PLAN option and specify a nondefault plan name that ends with an underscore (_), nsqlprep does not include the date/timestamp in the stored procedure names. In that case, you can reuse stored procedures created from a previous precompile.

If the database you need to connect to is unavailable or you do not want to use it when you are ready to compile, you can use the /BIND option in the nsqlprep precompiler command line to create a bind file. The bind file is a Transact-SQL script used to create stored procedures for access plans. You can later use the Microsoft® SQL Server™ 2000 isql utility to apply the bind file to the database. However, to run a bind file as an SQL script, each line must contain no more than 1,000 characters if you want to use the isql utility. If one or more lines contain more than 1,000 characters, use the isqlw utility (SQL Query Analyzer). You must apply the bind file to the database before you can run the corresponding C application.

If you do not specify the /DB and /PASS options or the /BIND option, both static and dynamic SQL statements are issued at run time.