General information
Category:
Windows API functions
yes, i am referring to stored procedures...here's my call from the query analyzer:
Sp_API_PINSALES "100112", "SOLD", 1, "120001", 64045805, "4291", "VAULT"
and here's my call from the foxpro window:
cgobject = CREATEOBJECT("pos_api_pin.table")
cg_nreturn = cgobject.PINSALES("100112", "SOLD", 1, "120001", 64045805, "4291", "VAULT")
the stored procedure is pretty long, but i'll post the first part:
CREATE Procedure Sp_API_PinSales
(
@product_sbt Varchar(6),
@pin_status as varchar(15),
@quantity int,
@custno_fk Varchar(20),
@pin_controlno float,
@invno_fk varchar(20),
@loctid_fk varchar(20)
)
As
Begin Transaction
Declare @@ErrorSave Int
Declare @_useradder Varchar(4)
Declare @_dateadded Datetime
Declare @_usereditor Varchar(4)
Declare @_dateeditor Datetime
Declare @merchant_fk as int
Declare @pin_fk as int
Declare @carrier_fk as int
Declare @pin_no as varchar(20)
Declare @pin_denomination as int
Declare @cont numeric
Declare @pin_controlno_last as float
Set @@ErrorSave = 0
Set @_useradder = 'PCS'
Set @_dateadded = GetDate()
Set @_usereditor = 'PCS'
Set @_dateeditor = GetDate()
Set @pin_controlno_last = (@pin_controlno + @quantity -1 )
-- If NOT Pin_Status = 'SOLD'
-- RETURN ERROR
If @pin_status <> 'SOLD'
Begin
/* @@ ERROR Returns the error number */
Set @@ErrorSave = -1000
End
-- If NOT existing the merchant which receives the terminal
-- RETURN ERROR
If Exists ( SELECT custno_fk
FROM pinmerchant
WHERE custno_fk = @custno_fk )
Begin
Set @merchant_fk = ( Select merchant_pk from pinmerchant
where custno_fk = @custno_fk )
End
Else
Begin
-- @@ ERROR Returns the error number
Set @@ErrorSave = -999
End
-- If NOT existing the product which receives the PINSales
-- RETURN ERROR
If NOT Exists ( SELECT product_sbt
FROM pinproducts
WHERE product_sbt = @product_sbt )
Begin
-- @@ ERROR Returns the error number
Set @@ErrorSave = -998
End
-- If NOT existing the Control Number with Pin_controlno on PinMaster Table
-- RETURN ERROR
If not Exists ( SELECT pin_controlno
FROM pinmaster
WHERE pin_controlno = @pin_controlno )
Begin
-- ERROR Returns the error number
Set @@ErrorSave = -997
EndCREATE Procedure Sp_API_PinSales
(
@product_sbt Varchar(6),
@pin_status as varchar(15),
@quantity int,
@custno_fk Varchar(20),
@pin_controlno float,
@invno_fk varchar(20),
@loctid_fk varchar(20)
)
As
Begin Transaction
Declare @@ErrorSave Int
Declare @_useradder Varchar(4)
Declare @_dateadded Datetime
Declare @_usereditor Varchar(4)
Declare @_dateeditor Datetime
Declare @merchant_fk as int
Declare @pin_fk as int
Declare @carrier_fk as int
Declare @pin_no as varchar(20)
Declare @pin_denomination as int
Declare @cont numeric
Declare @pin_controlno_last as float
Set @@ErrorSave = 0
Set @_useradder = 'PCS'
Set @_dateadded = GetDate()
Set @_usereditor = 'PCS'
Set @_dateeditor = GetDate()
Set @pin_controlno_last = (@pin_controlno + @quantity -1 )
-- If NOT Pin_Status = 'SOLD'
-- RETURN ERROR
If @pin_status <> 'SOLD'
Begin
/* @@ ERROR Returns the error number */
Set @@ErrorSave = -1000
End
-- If NOT existing the merchant which receives the terminal
-- RETURN ERROR
If Exists ( SELECT custno_fk
FROM pinmerchant
WHERE custno_fk = @custno_fk )
Begin
Set @merchant_fk = ( Select merchant_pk from pinmerchant
where custno_fk = @custno_fk )
End
Else
Begin
-- @@ ERROR Returns the error number
Set @@ErrorSave = -999
End
-- If NOT existing the product which receives the PINSales
-- RETURN ERROR
If NOT Exists ( SELECT product_sbt
FROM pinproducts
WHERE product_sbt = @product_sbt )
Begin
-- @@ ERROR Returns the error number
Set @@ErrorSave = -998
End
-- If NOT existing the Control Number with Pin_controlno on PinMaster Table
-- RETURN ERROR
If not Exists ( SELECT pin_controlno
FROM pinmaster
WHERE pin_controlno = @pin_controlno )
Begin
-- ERROR Returns the error number
Set @@ErrorSave = -997
End
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only