Data Manipulation 
Author Message
 Data Manipulation


Quote:
>Question:

>Using one table of data. i wish to perform mutliple mathematical
>equations to. I wrote the mathematical equations in a script.
>How do I apply that script to the table and use the results of it?
>Will the result be directed to an ANSWER.DB?

Hi Randy -

Not knowing more about what exactly you're doing, I offer this short
script which should steer you in the right direction.

This scripts assumes two existing tables:

        YOURDATA.db
        ------ field one:        Record #
        -------field two:         Data 1
        -------field three:      Data 2

        NEW_DATA.db
        -------field one:       Record #
        -------field two:        New 1
        -------field three:     New 2

Note that NEW_DATA.db should be emptied before running the script,
just for neatness sake. Or, more elegantly, you can empty the table at
the beginning of the script.   Alternately, you could just create a
*new* NEW_DATA.db with your script and it would naturally be empty.

Anyway, Randy, I hope this gets you where you want to go.

--------------------------------------------------------------------------------------

;### DECLARE YOUR VARIABLES                     ###
var
        num1VAR,
        num2VAR,        Number
        recVAR          LongInt
        tcGET,
        tcPUT           TCursor
endVar

method run(var eventInfo Event)

;### OPEN THE TWO TABLES WITH THE TCURSORS      ###
tcGET.open("YOURDATA")
tcPUT.open("NEW_DATA")

;### PUT NEW_DATA.db INTO EDIT MODE             ###
tcPUT.edit()

;### NOT KNOWING WHAT YOU REALLY WANT TO        ###
;### DO, FOR NOW WE'LL JUST DO THIS:            ###
;### WE'LL JUST SCAN ALL THE RECORDS IN         ###
;### IN YOURDATA.db SO WE HIT EVERY ONE ###
SCAN tcGET :
        recVAR = tcGET."Record #"
        num1VAR = tcGET."Data 1"
        ;### AND WE'LL SUBJECT THAT NUMBER TO ###
        ;### A FANCY CALCULATION
###
        num1VAR = num1VAR * 2
        ;### AND REPEAT THE PROCESS FOR THE    ###
        ;### SECOND FIELD IN THE TABLE            ###
        num2VAR = tcGET."Data 2"
        num2VAR = num2VAR/2
        ;### OKAY, NOW WE'LL POKE THE RESULTS  ###
        ;### INTO THE *EMPTY* NEW_DATA.db         ###
        tcPUT.insertRecord()
        tcPUT."Record #" = recVAR
        tcPUT."New 1" = num1VAR
        tcPUT."New 2" = num2VAR
        tcPUT.postRecord()
;### AND THE LOOP WILL RUN UNTIL ALL THE        ###
;### RECORDS IN YOURDATA.db HAVE BEEN   ###
;### PROCESSED WITH THE RESULTS INSERTED        ###
;### INTO THE NEW_DATA.db                       ###
ENDSCAN

;### CLEAN UP ###
tcPUT.endEdit()
tcPUT.close()
tcGET.close()

endmethod



Wed, 27 Oct 1999 03:00:00 GMT
 Data Manipulation

Quote:
> Using one table of data. i wish to perform mutliple mathematical
> equations to. I wrote the mathematical equations in a script.
> How do I apply that script to the table and use the results of it?
> Will the result be directed to an ANSWER.DB?

You need to open a tCursor to perform the manipulations. Something like:

var
   tc   tCursor
endVar

tc.open(":PRIV:answer.db")
tc.edit()

; put your code here using the tCursor to address specific fields in the
; format tc."FIELD_NAME" = someValue

tc.endEdit()
tc.close()

Daniel A. Morgan



Wed, 27 Oct 1999 03:00:00 GMT
 Data Manipulation

Question:

Using one table of data. i wish to perform mutliple mathematical
equations to. I wrote the mathematical equations in a script.
How do I apply that script to the table and use the results of it?
Will the result be directed to an ANSWER.DB?



Wed, 27 Oct 1999 03:00:00 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. Data manipulation of Japanese data

2. Sql server 2000 data manipulation utility

3. Sql server 2000 data manipulation utility

4. data manipulation in sql server 2000

5. Easy data manipulation from VB or other

6. Two-way data manipulation (Excel to ODBC SQL Server)

7. Data manipulation while a merge synchronisation is running

8. Two-way Data Manipulation (Excel 2 ODBC SqlServer)

9. Data manipulation using Stored Procedures

10. Data Manipulation in 4.21

11. Sql server 2000 data manipulation utility

12. SQL data manipulation


 
Powered by phpBB® Forum Software