Subject | Re: [IBO] How to pass parameter for the SP in the InsertSQL statement of TIBOQuery |
---|---|
Author | Helen Borrie |
Post date | 2004-10-29T00:46:10Z |
At 10:46 PM 28/10/2004 +0000, you wrote:
statement of the InsertSQL match the name and type of those in the fields
you want to pass. The same rule applies to the other parameters: make sure
the names of the parameters all match. IBO will do the rest.
More comments in-line:
that you set the properties of these params properly. Open the Params
editor and assign the proper ft* value to the DataType property.
table HOLIDAYS based on data inserted into the dataset buffer in dsInsert
mode. As a minimum, the SP would need input parameters for each of the
database columns that you have in the dataset's SELECT statement. I can't
guess what those fields would be, since your SELECT statement doesn't
provide a field list. Guessing from your EditSQL statement, you would need
a SP that started something like this:
create procedure NEW_HOL_SP (
HOLDID sometype,
HOLGRPID sometype,
HOLDATE sometype,
HOLNAME sometype,
AUTOEXPIRE sometype)
as
begin
......
end
Your InsertSQL would then be:
EXECUTE PROCEDURE NEW_HOL_SP(:HOLID, :HOLGRPID, :HOLDATE, :HOLNAME,
:AUTOEXPIRE)
and IBO would pick up the values from the Insert buffer.
statement object that is not bound to the dataset..
Helen
>Hi,Just make sure that the input parameters for the EXECUTE PROCEDURE
>
>I would like to know how do I pass parameter for the SP I am calling
>in the InsertSQL statement a TIBOQuery.
statement of the InsertSQL match the name and type of those in the fields
you want to pass. The same rule applies to the other parameters: make sure
the names of the parameters all match. IBO will do the rest.
More comments in-line:
>Here is my TIBOQuery object,Make sure you that, if you are going to instantiate any TParam objects,
>
>object HolQry: TIBOQuery
> Params = <
> item
> DataType = ftUnknown
that you set the properties of these params properly. Open the Params
editor and assign the proper ft* value to the DataType property.
> Name = 'HOLGRPID'This does not look like a procedure that could insert a new record into the
> ParamType = ptInput
> end>
> AutoCalcFields = False
> AutoFetchAll = True
> BufferSynchroFlags = [bsBeforeEdit, bsAfterEdit, bsAfterInsert]
> DatabaseName = 'NDSERVER_1'
> DeleteSQL.Strings = (
> 'UPDATE HOLIDAYS SET'
> 'IN_USE = 0'
> 'WHERE HOLID = :HOLID')
> EditSQL.Strings = (
> 'UPDATE HOLIDAYS SET'
> 'HOLDATE = :HOLDATE,'
> 'HOLNAME = :HOLNAME,'
> 'AUTOEXPIRE = :AUTOEXPIRE'
> 'WHERE HOLID = :HOLID')
> IB_Connection = HolConn
> InsertSQL.Strings = (
> 'EXECUTE PROCEDURE NEW_HOL_SP(:HOLGRPID)')
table HOLIDAYS based on data inserted into the dataset buffer in dsInsert
mode. As a minimum, the SP would need input parameters for each of the
database columns that you have in the dataset's SELECT statement. I can't
guess what those fields would be, since your SELECT statement doesn't
provide a field list. Guessing from your EditSQL statement, you would need
a SP that started something like this:
create procedure NEW_HOL_SP (
HOLDID sometype,
HOLGRPID sometype,
HOLDATE sometype,
HOLNAME sometype,
AUTOEXPIRE sometype)
as
begin
......
end
Your InsertSQL would then be:
EXECUTE PROCEDURE NEW_HOL_SP(:HOLID, :HOLGRPID, :HOLDATE, :HOLNAME,
:AUTOEXPIRE)
and IBO would pick up the values from the Insert buffer.
> KeyLinks.Strings = (No. You would do something like this if you were using a separate
> 'HOLID')
> KeyLinksAutoDefine = False
> PreparedInserts = True
> RecordCountAccurate = True
> OnError = HolQryError
> AfterInsert = HolQryAfterInsert
> BeforePost = HolQryBeforePost
> AfterPost = HolQryAfterPost
> OnNewRecord = HolQryNewRecord
> SQL.Strings = (
> 'select * from HOLIDAYS where HOLGRPID = :HOLGRPID and IN_USE =
>1')
> FieldOptions = []
> Left = 93
> Top = 272
>end
>
>So I want to call NEW_HOL_SP in the InsertSQL. This Stored Procedure
>NEW_HOL_SP takes one parameter HOLGRPID. I've tried to use
>
>HolQry->ParamByName("HOLGRPID")->AsInteger = 1;
>
>in the BeforePost() event. It doesn't seem to work.
statement object that is not bound to the dataset..
Helen