Is there a way to change the field type of a query in Delphi without having to exclude and include?

Asked

Viewed 541 times

1

I have the following situation, I use Postgresql and Zeos in Delphixe, I needed to update the component to better support LATIN1 x UTF-8, now I can work with every type of character, blz.

But another problem arose, some fields that were type Memo the new version of the component treats as String so Delphi "shouts" in the conversion.

The solution is simple, just delete the Dataset field and include again and it takes the new type, but my application has almost 400 forms, imagine opening one by one and keep checking the components.

I have the Gexperts installed which gives many treatment options in the project but I haven’t found if it makes this type change in Fields.

Looking at the Fields that Delphi complains about, they’re like Tstringfield, but when I try to open the query it gives the message:

---------------------------
Error
---------------------------
zqrClientes: Type mismatch for field 'end_cid', expecting: String actual: Memo.
---------------------------
OK   
---------------------------

If he’s already like Tstringfield, then he shouldn’t yell, but you know how it is... things only happen beyond that, so I went there in the Form code to see how it is, he’s like this:

object zqrClientesend_cid: TStringField
      DisplayWidth = 255
      FieldName = 'end_cid'
      ReadOnly = True
      Size = 255
    end

The problem seems to be the size of the field, which at the base is 40 and at the component is 255, but changing only the size of the field does not help.

This field was a varchar with no size specification in Postgres (error in creating the field), the old component worked normal even after changing the size to 40 character, but now changing the version of the Zeos component, it screams.

Where Delphi stores information that the component is Memo and not String?

I’ve already ruled out Ducs and recompiled and nothing.

In short the question is:

How to exchange Querys Fields types in Delphi without having to exclude and include again, as this action also breaks many links of Fields related components that will be deleted.

1 answer

2

I had to do this a short time ago, remember, there is .pas and .dfm one of them is not as it should be.

Here I have developed a similar solution with another Sopt user.

"The idea is simple, "find an occurrence and replace. One detail is that there was a pattern.

object zqrClientesend_cid: TStringField
      DisplayWidth = 255
      FieldName = 'end_cid'
      ReadOnly = True
      Size = 255
    end

Just use the example of the answer that Linkei and look for this and exchange for what you want!

One, detail on your question is that it says it is simple by deleting the fields and adding them again, but beware of the event link...

  • Is I cited the links, delete turns off a lot of component

  • Exactly, and Type mismatch for field 'end_cid', expecting: String actual: Memo. was exactly my problem what differs are the types, changed from Float for Extended, I resolved with link that I passed in reply!

  • You know something interesting Junior, the field in Delphi is already like String, and he says that it’s like Memo, see in the Form section that Voce copied

  • Junior found the problem here, a programmer created a function in postgres that returns Character Varying, postgres allows you to create a varchar field without specifying the size, the correct one would be Character Varying(size), I consider this a bug, but who am I to say this, rs, I changed the function to return text, and Delphi was able to understand the memo type and no longer error. Look, I lost a lot of time to figure this out, :( now I’m scanning the base to see if there are more fields or functions created this way.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.