Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Changing Data Types

Changing Data Types

Changing Data Types

Hi there:
I am trying to bring together 2 completely disparate databases into one. The data is essentially similar but the data types are different; thus 'order number' is an integer in one and text in another.
I am pulling the data from one into a paradox table, ready for import into the other.
Is there any way of programatically changing the data type in the paradox table so as to allow import into the other?
i have thought about exporting to a text file, then bringing into a new table in the propoer format but is there a better way?
Thanks in advance!

RE: Changing Data Types

How about opening a tcursor on each table, the scanning the one table, inserting a record into the other and assigning the values from the one cast to the proper data type into the other.


scan tcS :
  ; handle errors

Tony McGuire
"It's not about having enough time; we have the rest of our lives.  It's about priorities."

RE: Changing Data Types


A way that I would approach it is to get one table to have the same data types as the other by actually programmatically restructuring the data types of the fields.  For example you may wish to either look for text fields and change them to numbers or look for specific named fields and change them to numbers.

I've put a bit of code below and tried to comment it.  Hopefully you get what I am trying to do.  If you get as far as enumerating the field structure then view it and all will become clear.  You will need to substitute your own names where necessary and ensure that no one is using the table etc.

Please let me know if you have any questions.



method prep()

 tcFlds      TCursor
 tbl        Table
 dynNewStru      DynArray[] Anytype

;Attach your table that you want to change
;and get its field structure

tbl.attach( ":PRIV:your_source_table.DB" )

;open a TCursor to read through the field sturcture

tcFlds.open(":Priv:__field_struct.db" )

;scan through the field sturcture
;either look for specific fields or field types
;both examples are below and make your changes

Scan tcFlds:

 if   tcFlds."Field Name"= "XXXXX"   then
      tcFlds."Type"= "Number"

Scan tcFlds:
 if    tcFlds."Type"= "Alpha"    then
       tcFlds."Type"= "Number"


;replace your source table's field sturcture with the
;revised one

dynNewStru["FIELDSTRUCT"] = ":Priv:__field_struct.db"
tbl.restructure( dynNewStru )


RE: Changing Data Types

Thanks to you both for your help.
I have applied both methods - and copying the whole lot out to text and back again.
In the end I have gone foe Bystanders approach; I need two passes to convert a memo field to  anumber but it works just fine.
Thanks again.

RE: Changing Data Types


Good point, I forgot to mention about type casting.  Glad you sorted it out and glad to have been of service.



Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close