Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread Udating Memo CLOB / BLOB fields via SQL
Wed, Sep 17 2008 11:27 AMPermanent Link

adam
I am just getting started, having worked for ages with DBISAM.

If I want to pass memo-fields back to the table using EDB what is the best way to do it?
Note that my memo fields might contain single-quote, double-quote or end-of-line characters.

I think the way I did it with DBISAM (roughly) was:

aQuery.SQL.Text := 'UPDATE Stories SET Memo = :Memo WHERE ID= 2134';
aParam.Create;
aParam.Value := Memo1.Text;
aQuery.ParamByName('Memo') := aParam

But I can see things work differently with EDB, especially with the addition of this new
"Engine" object

Adam
Thu, Sep 18 2008 5:46 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Adam,

<< If I want to pass memo-fields back to the table using EDB what is the
best way to do it? >>

You can do it any number of ways.

<< Note that my memo fields might contain single-quote, double-quote or
end-of-line characters. >>

EDB does not care either way. Smiley

<< I think the way I did it with DBISAM (roughly) was:

aQuery.SQL.Text := 'UPDATE Stories SET Memo = :Memo WHERE ID= 2134';
aParam.Create;
aParam.Value := Memo1.Text;
aQuery.ParamByName('Memo') := aParam >>

Do this:

with aQuery do
   begin
   SQL.Text := 'UPDATE Stories SET Memo = :Memo WHERE ID= 2134';
   ParamByName('Memo').Assign(Memo1);
   ExecSQL;
   end;

<< But I can see things work differently with EDB, especially with the
addition of this new "Engine" object >>

Actually, DBISAM also had an engine object - TDBISAMEngine.  The two are
very similar in this respect.  However, the engine has no direct bearing on
the above operation.

--
Tim Young
Elevate Software
www.elevatesoft.com

Thu, Sep 18 2008 1:32 PMPermanent Link

adam
>Do this:

>with aQuery do
>    begin
>    SQL.Text := 'UPDATE Stories SET Memo = :Memo WHERE ID= 2134';
>    ParamByName('Memo').Assign(Memo1);
>    ExecSQL;
>    end;

Thank you for this Tim.

The thing is I don't know what the CLOB fields will be until I post, so I have to
dynamically create params on the Query at run-time

I am trying to do it like this:

 Query.Close;
 Query.Unprepare;
 Query.Params.Clear;
 Query.SQL.Text := aSQLStr;
 for i := 0 to FieldCount - 1 do
   begin
     if (Fields[i].DataType=ftMemo) and (Fields[i].tag=1) then //I am using the tag
property on the field to mark if a user has edited it
       begin
         Query.Params.Add;
         Query.Params[Query.ParamCount-1].Name := Fields[i].FieldName;
         Query.ParamByName(Fields[i].FieldName).Assign(Memo1);
       end;
   end;
 ShowMessage(Query.SQL.Text);  //just using this at the moment to see what comes out
//  Query.ExecSQL;


At the moment all that comes out is

"UPDATE TableName Set Address = :Address"

The value of the memo isn't getting "in"

Adam
Fri, Sep 19 2008 2:45 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

adam


I noticed that a bit ago. I don't know wether its supposed to or not but what you're shown is the "base" sql not the sql with the parameters substituted. Try running it and you'll see it works.

Roy Lambert [Team Elevate]
Fri, Sep 19 2008 4:18 AMPermanent Link

adam
D'Oh,

Thanks Roy, I should have actually run it before posting. It does work fine!
Fri, Sep 19 2008 6:45 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Adam,

<<The thing is I don't know what the CLOB fields will be until I post, so I
have to dynamically create params on the Query at run-time >>

I'm not sure what you mean by this.  The parameters can only be set to what
matches the parameters in the SQL, therefore whatever you specify as the SQL
is going to determine what parameters are populated (ParamCheck=True), and
adding new parameters is incorrect.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image