insert Null Strings into IBQuery Paramerters

I have a parameterized query that looks something like this
"Insert into Table ('ID','Key','Desc') values (:id,:key,:desc);"

//desc is some times null
ID and Key is integer
Desc is String
eg.
IBQuery.ParamByName('Desc').asString := 'Value';
or
IBQuery.ParamByName('Desc').asString := null;

//the folowing does not work
IBQuery.ParamByName('Desc').bound := False;
IBQuery.ParamByName('Desc').Clear;
IBQuery.ParamByName('Desc').bound := True;
MorpheusQAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Ivanov_GConnect With a Mentor Commented:
IBQuery.ParamByName(ParmString).Value := null
0
 
Ivanov_GCommented:
 
   Bound is automatically set when you assign value for the parameter. Set Bound to False to undo the setting of a value.

   Your code is wrong.

   IBQuery.ParamByName('Desc').asString := 'Value';
   IBQuery.ParamByName('Desc').bound := False;

   now the parameter is cleared... You can not set bound = True without assigning value.

   In my opinion is is logical error of Borland - this have to be read-only property ... Anyway - the problem is in your code.
0
 
kretzschmarCommented:
IBQuery.ParamByName('Desc').Clear;
 is enough

don't play with the bound-property

meikl ;-)
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
MorpheusQAuthor Commented:
im trying to do this but clear doesnt work

procedure SetPosebleNull(ParmString,Desc : String);
begin
  if Desc <> '' then
    IBQuery.ParamByName(ParmString).AsString := Desc
  else
    IBQuery.ParamByName(ParmString).Clear;
end;

anything else i can try
0
 
kretzschmarCommented:
what delphi-version do you use?
0
 
MorpheusQAuthor Commented:
6
0
 
kretzschmarCommented:
recherched a bit and it points out that the TIBQuery is just
a compatibility component with a view bugs
(maybe also the NULL-assignment)

if possible replace TIBQuery with the TIBSQL-component

meikl ;-)
0
 
MorpheusQAuthor Commented:
doesnt work ider
Keep Geting incorect values in SQLDA structure errors
0
 
MorpheusQAuthor Commented:
i ll try the TIBSQL
0
 
MorpheusQAuthor Commented:
It turns out  
IBQuery.ParamByName(ParmString).Value := null
did work, Our Company’s Derived IBKylixQuery Class has a bug
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.