Subject | Re: [IBO] TIB_Query Update SQL |
---|---|
Author | Helen Borrie |
Post date | 2001-12-18T06:26:05Z |
At 09:47 PM 17-12-01 -0500, you wrote:
This isn't correct use of the UpdateSQL property. What you needed here in the InsertSQL property was something like a stored procedure call to which you would pass parameters from the fields edited by the user, e.g.
EXECUTE PROCEDURE UPDATEM(:name, :water, :defaultsummary)
The reason you need a SP is that you can't update multiple tables in a single statement.
Also take note of GeneratorLinks - you don't need to pull that value across yourself.
You don't have to use proc calls in UpdateSQL - any statement is possible. These UpdateSQL statements make the joined dataset "live" - you don't have to write any code. The IB_Query will pick up the parameters automatically from the columns of the same name.
As to "what else is wrong with your code", the argument for FieldByName and ParamByName is just the column name in single quotes (no colon). But, as I said, you don't need that code. Just call Insert and the SP will be executed with the parameters filled for you; or you can pass values to the parameters if you need to.
Regards,
Helen
>Hi folks,Marv,
>
>Using Delphi 5.0, IBO 3.6D and the following TIB_Query:
>
>SELECT OTTYPE.OTTID
> , OTTYPE.NAME
> , OTTYPE.WATER
> , OTTYPE.DEFAULTSUMMARY
> , SUMMARYCAT.NAME as CatName
>FROM OTTYPE
>LEFT OUTER JOIN SUMMARYCAT on OTTYPE.DEFAULTSUMMARY = SUMMARYCAT.SCID
>
>I want to update the OTTYPE table (either insert or edit a current record).
>I decided to use the UpDateSQL fields of the query and generated the SQL
>code, but could not figure out the to use the Query. I tried (among others)
>the following
>
>...
>with q do
>begin
> Insert;
> FieldByName(':OTTID').asInteger := RID; // obtained rid from a generator
> FieldByName(':NAME').asString := 'Name';
> FieldByName(':WATER').asString := 'T';
> FieldByName(':DEFAULTSUMMARY').asInteger := 99;
> Post;
>end;
>
>This did not work, but what would have?
This isn't correct use of the UpdateSQL property. What you needed here in the InsertSQL property was something like a stored procedure call to which you would pass parameters from the fields edited by the user, e.g.
EXECUTE PROCEDURE UPDATEM(:name, :water, :defaultsummary)
The reason you need a SP is that you can't update multiple tables in a single statement.
Also take note of GeneratorLinks - you don't need to pull that value across yourself.
You don't have to use proc calls in UpdateSQL - any statement is possible. These UpdateSQL statements make the joined dataset "live" - you don't have to write any code. The IB_Query will pick up the parameters automatically from the columns of the same name.
As to "what else is wrong with your code", the argument for FieldByName and ParamByName is just the column name in single quotes (no colon). But, as I said, you don't need that code. Just call Insert and the SP will be executed with the parameters filled for you; or you can pass values to the parameters if you need to.
Regards,
Helen