Solved

insert Null Strings into IBQuery Paramerters

Posted on 2004-04-23
10
471 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month6 days, 3 hours left to enroll

627 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