Change datatype at runtime

Discussion forum about all things Team Developer 5.x and 6.x
EwaldP
Austria
Posts: 363
Joined: 07 Mar 2017, 08:00
Location: Austria

Change datatype at runtime

Post by EwaldP » 14 May 2020, 05:04

Hi,

is there a possibility to change the datatype from a datafield or table/grid column at runtime. Like SalSetDataType....

Thx.

Ewald
Ewald P. Palmetshofer
EDV-Hausleitner GmbH
4020 Linz
www.edv-hausleitner.at

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 2869
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: change datatype at runtime

Post by Dave Rabelink » 14 May 2020, 07:46

Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

EwaldP
Austria
Posts: 363
Joined: 07 Mar 2017, 08:00
Location: Austria

Re: change datatype at runtime

Post by EwaldP » 14 May 2020, 08:33

Thanks Dave,

unfortunately these approaches don't work in my case. I have here an old source code where child tables are filled with SalTblPopulate and the same source should work against SQLBase and SQLServer. There I have the problem with varchar fields > 254 characters. If you fetch data from SQLBase column, e.g. varchar(400), the variable or datafield/column has to defined as string. If you fetch it from SQLServer the variable or datafield/column has to be defined as long string. If I could change the datatype of the column on sam_create, would be nice.
Ewald P. Palmetshofer
EDV-Hausleitner GmbH
4020 Linz
www.edv-hausleitner.at

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 2869
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: Change datatype at runtime

Post by Dave Rabelink » 14 May 2020, 08:56

I'm not a "SalTblPopulate" user, I avoid this at any cost, so maybe others can respond with any tips.

But what I could imagine that you define 2 table columns, one for string and one for long string.
Because you know when you use SqlBase or SqlServer, you can fire a different SQL statement where you swap the select column sequence.
(one column in the statement always returns NULL and the other returns the column value).

For instance:
You define 2 columns in the table as string (colValue1) and long string (colValue2)

The SQL statement would be something like this:

Code: Select all

(when SqlBase)
SELECT COLVALUE, NULL
FROM TABLE
INTO :colValue1, :colValue2

(when SqlServer)
SELECT NULL, COLVALUE
FROM TABLE
INTO :colValue1, :colValue2
You can then hide/show the correct column.
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

EwaldP
Austria
Posts: 363
Joined: 07 Mar 2017, 08:00
Location: Austria

Re: Change datatype at runtime

Post by EwaldP » 14 May 2020, 09:00

Yes, SalTblPopulate is a nightmare :-).
Ewald P. Palmetshofer
EDV-Hausleitner GmbH
4020 Linz
www.edv-hausleitner.at

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 2869
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: Change datatype at runtime

Post by Dave Rabelink » 14 May 2020, 09:02

I edited my response
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 0 guests