LONGCHAR in Temp-Tables

Posted by Ken Ward on 13-Jun-2017 10:55

So I was wondering why I can't use a LONGCHAR in a TEMP-TABLE.

I have a temp table that has a log value as a field. There is an independent log for each record. Naturally, I would like to use a LONGCHAR here, but I just found out I can't do it. I'll use a CHAR in its place with its 32k limit, but I was just trying to avoid potential future overflow errors.

Posted by Ken McIntosh on 13-Jun-2017 11:35

Hi Ken,

LONGCHAR is a data-type that can only be used for program variables, class members, return types and parameters.

CLOB was provided to store the same data in a DATABASE tables and TEMP-TABLEs.

Cheers,

Ken

All Replies

Posted by gdb390 on 13-Jun-2017 10:57

instead of longchar , use CLOB

Posted by Ken McIntosh on 13-Jun-2017 11:35

Hi Ken,

LONGCHAR is a data-type that can only be used for program variables, class members, return types and parameters.

CLOB was provided to store the same data in a DATABASE tables and TEMP-TABLEs.

Cheers,

Ken

Posted by Patrick Tingen on 14-Jun-2017 01:23

The question that remains is then: why are there two seemingly identical terms for what - in essence - is the same? Why not let the compiler handle it, allow LONGCHAR as type and convert it behind the scenes to a CLOB.

After all, what is the difference between a LONGCHAR and a CLOB anyway?

Posted by Mike Fechner on 14-Jun-2017 01:29

Don't know the answer to Patrick's question.

But as a word of warning: LONGCHAR's are passed by value, temp-tables may be passed by reference. So with large Text values this may make a difference in Performance. Unless you pass you own LONGCHAR holder objects around.

Posted by marian.edu on 14-Jun-2017 01:58

or simply use memptr and have fun with malloc (unmanaged resources for .net aficionados)


Marian Edu

Acorn IT 
+40 740 036 212

Posted by Ken Ward on 14-Jun-2017 08:29

We don't pass temp-tables as parameters in our system, so that shouldn't be an issue.

According to the documentation, a LONGCHAR is an actual string whereas a CLOB is a pointer to a string.

I suppose its the difference between char[100] and char*

and thanks, but I'll bass on the MEMPTR, lol

Thanks for all your responses

Posted by Peter Judge on 14-Jun-2017 09:00

The word “fun” and “memptr” shouldn’t be used in the same sentence :)
 
In more recent version there are wrappers around longchars (OpenEdge.Core.String) and memptr (OpenEdge.Core.Memptr) that can help with by-value passing (since they’re obejcts they’re always passed by-value).
 
If you want to follow Mike’s approach of using a holder object, there are a number of interfaces defined by the CCS project that are included in 11.6.3 onwards. You can (should) use these to define variables and parameters. The String object referenced above implements the Ccs.Common.Support.ILongcharHolder interface and the Memptr the IMemptrHolder interface.
 

Posted by Peter Judge on 14-Jun-2017 09:02

+1  (FWIW)
 
 

This thread is closed