Important: The information in this document is obsolete and should not be used for new development.
DBStartQuery
Use theDBStartQueryfunction to initiate the process of sending a query to a data server.
FUNCTION DBStartQuery (VAR sessID: LongInt; query: QueryHandle; statusProc: ProcPtr; asyncPB: DBAsyncParmBlkPtr): OSErr;
sessID- A session ID that identifies a session with the data server. If you specify 0 for this parameter, then the
DBStartQueryfunction initiates a session and returns the session ID in thesessIDparameter.query- A handle to a query record.
statusProc- A pointer to a status routine that your application can use to update its windows after the query definition function has completed execution. (The
DBStartQueryfunction does not attempt to update your application's windows.) TheDBStartQueryfunction also calls your status routine before it initiates a session with a data server, after it calls theDBInitfunction, after it calls theDBSendfunction, and after it calls theDBExecfunction. Status routines are discussed in "Writing a Status Routine for High-Level Functions" beginning on page 12-22.asyncPB- A pointer to an asynchronous parameter block. When specified, the
DBStartQueryfunction calls theDBInit,DBSend, andDBExecfunctions asynchronously. As soon as theDBInitfunction has started execution, it returns control to your application. Your application must then call the Event Manager'sWaitNextEventfunction periodically to allow these asynchronous routines to run, and it must check theresultfield of the asynchronous parameter block to determine when each routine has completed execution.DESCRIPTION
TheDBStartQueryfunction performs the following tasks, in the order specified:
- It calls the query definition function (if any) pointed to by the query record. The query definition function modifies the query record and the query, usually by asking the user for input. The query definition function can display a dialog box that gives the user the option of canceling the query; if the user does cancel the query, the
DBStartQueryfunction returns theuserCanceledErrresult code.- If you specify a nonzero value for the
statusProcparameter, theDBStartQueryfunction calls your status routine with thekDBUpdateWindconstant in themessageparameter so that your application can update its windows.- If you specify a nonzero value for the
statusProcparameter, theDBStartQueryfunction calls your status routine with thekDBAboutToInitconstant in themessageparameter so that your application can display a dialog box informing the user that a session is about to be initiated with a data server, and giving the user the option of canceling execution of the function.- If the
sessIDparameter is 0, theDBStartQueryfunction calls theDBInitfunction to initiate a session, and returns a session ID.- If you specify a nonzero value for the
statusProcparameter and theDBStartQueryfunction calls theDBInitfunction, theDBStartQueryfunction calls your status routine with thekDBInitCompleteconstant in themessageparameter and the result of theDBInitfunction in the function result.- The
DBStartQueryfunction calls theDBSendfunction to send the query to the data server.- If you specify a nonzero value for the
statusProcparameter, theDBStartQueryfunction calls your status routine with thekDBSendCompleteconstant in themessageparameter and the result of theDBSendfunction in theresultparameter.- The
DBStartQueryfunction calls theDBExecfunction to execute the query.- If you specify a nonzero value for the
statusProcparameter, theDBStartQueryfunction calls your status routine with thekDBExecCompleteconstant in themessageparameter and the result of theDBExecfunction in theresultparameter.- If you specify a nonzero value for the
statusProcparameter, theDBStartQueryfunction calls your status routine with thekDBStartQueryCompleteconstant in themessageparameter and the result of theDBStartQueryfunction in theresultparameter.
SPECIAL CONSIDERATIONS
TheDBStartQueryfunction may move or purge memory. You should not call this routine from within an interrupt, such as in a completion routine or a VBL task.ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for theDBStartQueryfunction are
Trap macro Selector _DBStartQuery $0811 RESULT CODES
noErr 0 No error userCanceledErr -128 User canceled the query rcDBError -802 Error initiating session, sending text, or executing query rcDBBadSessID -806 Session ID is invalid rcDBBadDDev -808 Couldn't find the specified database extension, or error occurred in opening database extension rcDBAsyncNotSupp -809 The database extension does not support asynchronous calls rcDBPackNotInited -813 The InitDBPackfunction has not yet been calledSEE ALSO
See "Using the High-Level Interface" beginning on page 12-14 for a general description of how theDBStartQueryfunction works in conjunction with other Data Access Manager routines. See Listing 12-1 beginning on page 12-18 for an example of the use of theDBStartQueryfunction. For a description of the query record, see page 12-57. For information on how to write a query definition function or status routine, see "Writing a Query Definition Function" beginning on page 12-52 and "Writing a Status Routine for High-Level Functions" beginning on page 12-22, respectively. Descriptions of theDBInit,DBSend, andDBExecfunctions begin on page 12-69, page 12-77, and page 12-79, respectively.