Solved

insert Null Strings into IBQuery Paramerters

Posted on 2004-04-23
10
466 Views
Last Modified: 2010-04-05
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;
0
Comment
Question by:MorpheusQ
  • 5
  • 3
  • 2
10 Comments
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10897423
 
   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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 10897512
IBQuery.ParamByName('Desc').Clear;
 is enough

don't play with the bound-property

meikl ;-)
0
 

Author Comment

by:MorpheusQ
ID: 10897763
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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 10897777
what delphi-version do you use?
0
 

Author Comment

by:MorpheusQ
ID: 10897788
6
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 12

Accepted Solution

by:
Ivanov_G earned 125 total points
ID: 10897843
IBQuery.ParamByName(ParmString).Value := null
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 10897872
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
 

Author Comment

by:MorpheusQ
ID: 10897873
doesnt work ider
Keep Geting incorect values in SQLDA structure errors
0
 

Author Comment

by:MorpheusQ
ID: 10897885
i ll try the TIBSQL
0
 

Author Comment

by:MorpheusQ
ID: 10898033
It turns out  
IBQuery.ParamByName(ParmString).Value := null
did work, Our Company’s Derived IBKylixQuery Class has a bug
Thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now