Solved

insert Null Strings into IBQuery Paramerters

Posted on 2004-04-23
10
467 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Simple Delphi Question 9 90
Delphi: how to implement a User Shortcut mapper? 1 110
Performance of SQL statement 37 113
Unique identifier on a terminal server (rdp) 4 57
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

825 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