Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

insert Null Strings into IBQuery Paramerters

Posted on 2004-04-23
10
Medium Priority
?
473 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

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

Author Comment

by:MorpheusQ
ID: 10897788
6
0
 
LVL 12

Accepted Solution

by:
Ivanov_G earned 500 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 Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

660 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