Board index » delphi » TQuery: TMemoField for an Oracle function returning a varchar2 result

TQuery: TMemoField for an Oracle function returning a varchar2 result

Hi everybody!
I have a little problem with query fields.

I have an Oracle(8.1.6) function which returns a varchar2
e.g. :
create or replace function TrueFalse(X: Number) return varchar2
as
Temp: varchar2(10);
begin
     IF X = 0 then
        temp:= 'False';
     ELSIF X=1 then
        temp:= 'True';
     ELSE
        temp:= 'XXX';
     END IF;
     RETURN TEMP;
end;

If I create a Tquery component with the SQL property :
select TrueFalse(0) TorF from dual;

If I add the TorF Field in the Tquery component I will have a TmemoFieldType instead of a TstringField.

And the value isn't shown in a DBgrid, instead, I have the string "(memo)" in the column associated to the field.

Maybe someone can give me an idea in order to make the query identify the function result as a TStringField instead of TMemoField?

Thanx.

Abdelhamid

 

Re:TQuery: TMemoField for an Oracle function returning a varchar2 result


 substr(TrueFalse, 1, 5) will get you a string.

John Pierce

Re:TQuery: TMemoField for an Oracle function returning a varchar2 result


Re:TQuery: TMemoField for an Oracle function returning a varchar2 result


Thanks John,
I've tried to use, in the SQL string, substr but the TQuery component has identified the result as a TMemofield.

In design time:
query1.SQL:
select substr(TrueFalse(0),1,5) TorF from dual;

I have the following field when I add it from the query:
query1TorF: TMemoField;

Delphi 5.0 (Build 6.18) Update Pack 1
BDE 5.01
Oracle 8.1.6

Quote
John Pierce <jpie...@healthplanning.com> wrote:
> substr(TrueFalse, 1, 5) will get you a string.

>John Pierce

Re:TQuery: TMemoField for an Oracle function returning a varchar2 result


Re:TQuery: TMemoField for an Oracle function returning a varchar2 result


if you just want to display it in the dbgrid,create a calc field then
display the calc field in the field or you can use 3rd party dbgrid which
can display memo as string in the grid.
Quote
Abdelhamid <abdelhamid.guet...@socgen.com> wrote in message

news:3b94b94a$1_2@dnews...
Quote

> Hi everybody!
> I have a little problem with query fields.

> I have an Oracle(8.1.6) function which returns a varchar2
> e.g. :
> create or replace function TrueFalse(X: Number) return varchar2
> as
> Temp: varchar2(10);
> begin
>      IF X = 0 then
>         temp:= 'False';
>      ELSIF X=1 then
>         temp:= 'True';
>      ELSE
>         temp:= 'XXX';
>      END IF;
>      RETURN TEMP;
> end;

> If I create a Tquery component with the SQL property :
> select TrueFalse(0) TorF from dual;

> If I add the TorF Field in the Tquery component I will have a

TmemoFieldType instead of a TstringField.
Quote

> And the value isn't shown in a DBgrid, instead, I have the string "(memo)"

in the column associated to the field.
Quote

> Maybe someone can give me an idea in order to make the query identify the

function result as a TStringField instead of TMemoField?

- Show quoted text -

Quote

> Thanx.

> Abdelhamid

Other Threads