Subject Re: [IBO] TIBOQuery ParamsByName SQL Error -804 data
Author Helen Borrie (TeamIBO)
At 08:25 PM 17-02-02 +0200, you wrote:
>Hello, i find out that the problem is a float param instead of the date.
>when i use query.params.parambyname and not query.parambyname

Perhaps you need to tell us more about how you are collecting user inputs. If you are using non-data-aware controls to collect parameters, then you must parse and cast the inputs in most cases.

>i got the error later when i set the parameter
>query.params.parambyname('MyFloat').asFloat := MyFloatVar;
>
>the first problem is that when i look in parm...text there is
>"1,1" instead of "1.0" (comma instead of point)
>in german the decimal separator is comma not point

If you use data-aware controls you can set display attributes and edit masks to handle format problems.


>so i try a simple integer value
>query.params.parambyname('MyInt').asInteger := StrToInt(edit1.text);
>and the statement
>"select nr, nr * :MyInt as MultiNr from MyTable where nr = 2"
>produced error -601 array/blob/data type no allowed in arithmetik

This problem is due to bad SQL syntax. Parameters to dynamic SQL statements "stand in place" of a column value (in the case of tables) or an input argument (in the case of stored procedures). The colon-prefix in SQL marks an array element (although this statement wouldn't work for an array element either...)

To achieve what you wanted to do you would need to pass your Delphi variable value into your statement as a constant:

MyInt := Edit1.Text;
(* Make sure you test to make sure there is a value *)
MyQuery.SQL.Add('select nr, nr * ' + StrToInt(MyInt) + ' as MultiNr from MyTable');
MyQuery.SQL.Add('where nr = 2');

>i donĀ“t know how to go on.

A good place to start would be to study the SQL language. It is not "free-form" - it adheres to very tight syntax rules. Because FB/IB is highly compliant with the SQL-92 level 0 and level 1 standards, any good "starter" book would be useful. There are some recommendations on the IBO bookstore page ( http://www.ibobjects.com/ibo_books.html ); alternatively, you could search on "SQL" at the www.amazon.de website and read some of titles and reviews there. The Data Definition Guide (DataDef.pdf) and the Language Reference (LangRef.pdf) also provide basic syntax and examples.

If you are going to use non-data-aware controls, you also need to study the IB/FB data types so that you understand how Delphi performs conversions from string inputs. In many cases you will have to cast them yourself as there is not 1:1 correspondence between Delphi and IB datatypes.

Good luck, keep asking. Oh, and please would you trim your replies...

regards,
Helen Borrie (TeamIBO Support)

** Please don't email your support questions privately **
Ask on the list and everyone benefits
Don't forget the IB Objects online FAQ - link from any page at www.ibobjects.com