# PosgreSQL Text data type, what Clarion type to use?

**URL:** <https://clarionhub.com/t/posgresql-text-data-type-what-clarion-type-to-use/4769>\
**Category:** questions\
**Tags:** postgresql\
**Created:** [January 10, 2022, 12:55pm UTC](https://clarionhub.com/t/posgresql-text-data-type-what-clarion-type-to-use/4769 "2022-01-10T12:55:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![blue](https://clarionhub.com/letter_avatar_proxy/v4/letter/b/3bc359/32.png) [@blue](https://clarionhub.com/u/blue)\
**Post date:** [January 10, 2022, 12:55pm UTC](https://clarionhub.com/t/posgresql-text-data-type-what-clarion-type-to-use/4769/1 "2022-01-10T12:55:08Z")

</div>

Hello,

What is a equivalent of PostgreSQL Text data type in Clarion? I assume it is BLOB?

---

<div class="post-metadata">

**Author:** ![totalhip](https://clarionhub.com/user_avatar/clarionhub.com/totalhip/32/1477_2.png) [@totalhip](https://clarionhub.com/u/totalhip)\
**Post date:** [January 10, 2022, 2:16pm UTC](https://clarionhub.com/t/posgresql-text-data-type-what-clarion-type-to-use/4769/2 "2022-01-10T14:16:38Z")

</div>

Perhaps depends upon the data being stored. I typically use CSTRING( large#) for comment type fields. Because PG does not have auto type conversion, you often will find TEXT being used where one typically might expect a VARCHAR. This is especially true for columns used with some type of string processing (a concatenation for example) so that a cast::operator is not always required.

---

<div class="post-metadata">

**Author:** ![seanh](https://clarionhub.com/letter_avatar_proxy/v4/letter/s/4af34b/32.png) [@seanh](https://clarionhub.com/u/seanh)\
**Post date:** [January 10, 2022, 10:48pm UTC](https://clarionhub.com/t/posgresql-text-data-type-what-clarion-type-to-use/4769/3 "2022-01-10T22:48:49Z")

</div>

It really depends, I’ve used String and Cstring on the clarion side and TEXT on the SQL side.  
I’m uncertain if MEMO works? Might be worth a try.

---

<div class="post-metadata">

**Author:** ![totalhip](https://clarionhub.com/user_avatar/clarionhub.com/totalhip/32/1477_2.png) [@totalhip](https://clarionhub.com/u/totalhip)\
**Post date:** [January 10, 2022, 11:20pm UTC](https://clarionhub.com/t/posgresql-text-data-type-what-clarion-type-to-use/4769/4 "2022-01-10T23:20:55Z")

</div>

When I first converted, I had STRINGs in the Clarion Dct with TEXT or VARCHAR in PG.  
I quickly discovered this was a recipe for frequently storing empty strings in PG which in turn created unexpected problems in PG defined views. I finally decided to bite the bullet and change to CSTRINGs in the Dct. Clarion be damned, a NULL string needs to be a NULL string in PG.

---

<div class="post-metadata">

**Author:** ![blue](https://clarionhub.com/letter_avatar_proxy/v4/letter/b/3bc359/32.png) [@blue](https://clarionhub.com/u/blue)\
**Post date:** [January 13, 2022, 4:14pm UTC](https://clarionhub.com/t/posgresql-text-data-type-what-clarion-type-to-use/4769/5 "2022-01-13T16:14:01Z")

</div>

Thank you all for replying.

I know that I can use `STRING` and `CSTRING` for queries. But I am wondering what to use when you have a `TEXT` type column in the database? Where you can have some long text. Since it can be variable length, it does not have defined length as `CHAR` or `VARCHAR`, and it can have a greater size than Clarion variables.

Also, the documentation states that there is no performance advantage for `CHAR` over `VARCHAR` or `TEXT` data type, like in other databases.

Quote from [https://www.postgresql.org/docs/current/datatype-character.html:](https://www.postgresql.org/docs/current/datatype-character.html:)

### Tip

There is no performance difference among these three types, apart from increased storage space when using the blank-padded type, and a few extra CPU cycles to check the length when storing into a length-constrained column. While `character(n)` has performance advantages in some other database systems, there is no such advantage in PostgreSQL; in fact `character(n)` is usually the slowest of the three because of its additional storage costs. In most situations `text` or `character varying` should be used instead.

---

<div class="post-metadata">

**Author:** ![totalhip](https://clarionhub.com/user_avatar/clarionhub.com/totalhip/32/1477_2.png) [@totalhip](https://clarionhub.com/u/totalhip)\
**Post date:** [January 13, 2022, 6:01pm UTC](https://clarionhub.com/t/posgresql-text-data-type-what-clarion-type-to-use/4769/6 "2022-01-13T18:01:15Z")

</div>

I have always used CSTRING(Large#) in the Dct for PG TEXT fields.  
Large# = Up to 4MB unless extended using NEW (see docs)

Have never tried MEMO. Using STRING = headaches (for me).
