Article ID: 114787
Article Last Modified on 2/22/2005
create procedure showsales @parm1 char(4) as select * from sales where stor_id=@parm1
*****SET THE LIBRARY AND INITIALIZE VARS
IF _DOS
SET LIBRARY TO SYS(2004)+"fpsql.plb"
ELSE
SET LIBRARY TO SYS(2004)+"fpsql.fll"
ENDIF
PUBLIC errval
PUBLIC errmsg
PUBLIC handle
errval=0
errmsg=' '
sourcename= 'test'
user= 'sa'
passwd=''
********CONNECT
handle=DBConnect(sourcename,user,passwd)
IF handle > 0
WAIT WINDOW 'Successfully Connected' NOWAIT
ELSE
error=DBError(0,@errmsg,@errval)
WAIT WINDOW STR(error)+' '+STR(errval)+' '+errmsg
ENDIF
=DBSetOpt(handle,'Asynchronous',0)
=DBSetOpt(handle,'BatchMode',1)
=DBSetOpt(handle,'ConnTimeout',0)
=DBSetOpt(handle,'Transact',1)
=DBSetOpt(handle,'UseTable',0)
err=DBExec(handle,'use pubs')
DO errhand WITH err,'USE PUBS'
**********THIS PROGRAM DEMOs HOW TO IMPLEMENT SQL WITH
**********THE DBExec() FUNCTION
sqlcomm= "execute showsales '7066'"
err=DBExec(handle,sqlcomm)
DO errhand WITH err,"DBExec(handle,"+sqlcomm+")"
IF err > 0
BROWSE
ENDIF
**********DISCONNECT
err=DBDisconn(handle)
DO errhand WITH err,"DBDisconn()"
SET LIBRARY TO
CLOSE ALL
**********Error Handler Program
PROCEDURE errhand
PARAMETERS err,command
IF err > 0
WAIT WINDOW ALLTRIM(UPPER(command))+"Completed Successfully";
NOWAIT
ELSE
WAIT WINDOW UPPER(command)+"NOT Completed Successfully"
error=DBError(handle,@errmsg,@errval)
WAIT WINDOW STR(error)+" "+STR(errval)+" "+errmsg
ENDIF
RETURN
Note that the program returns the two records that have 7066 as the
stor_id.
PUBLIC errval
PUBLIC errmsg
PUBLIC handle
errval=0
errmsg=' '
sourcename= 'test'
user= 'sa'
passwd=''
********CONNECT
* Turning on error display for connections
=SQLSetProp(0,"DispWarning",.t.)
handle=SQLConnect(sourcename,user,passwd)
IF handle > 0
WAIT WINDOW 'Successfully Connected' NOWAIT
ENDIF
********Set some defaults
=SQLSetProp(handle,'Asynchronous',.f.)
=SQLSetProp(handle,'BatchMode',.t.)
=SQLSetProp(handle,'ConnectTimeOut',0)
=SQLSetProp(handle,'Transactions',1)
err=SQLExec(handle,'use pubs')
DO errhand WITH err,'USE PUBS'
**********THIS PROGRAM DEMOs HOW TO IMPLEMENT SQL WITH
**********THE SQLExec() FUNCTION
sqlcomm= "execute showsales '7066'"
err=SQLExec(handle,sqlcomm)
DO errhand WITH err,"SQLExec(handle,"+sqlcomm+")"
IF err > 0
BROWSE
ENDIF
**********DISCONNECT
err=SQLDisconnect(handle)
DO errhand WITH err,"SQLDisconnect()"
CLOSE ALL
**********Error Handler Program
PROCEDURE errhand
PARAMETERS err,command
IF err > 0
WAIT WINDOW ALLTRIM(UPPER(command))+"Completed Successfully";
NOWAIT
ELSE
WAIT WINDOW UPPER(command)+"NOT Completed Successfully"
ENDIF
RETURN
Note that the program returns the two records that have 7066 as the
stor_id.
Additional query words: CK STORED PROCEDURE ODBC
Keywords: kbhowto kbinterop kbcode KB114787