Valentina Script Problem

Jan Schenkel janschenkel at yahoo.com
Thu Feb 5 04:02:39 EST 2004


--- Brian Maher <plsntbreez at mac.com> wrote:
> Hi Folks,
> 
> As a test I have the following script to insert
> 1,000,000 records into 
> a Valentina database.  The script works without
> error (although I had 
> to use revdb_commit since revCommitDatabase returns
> an error that the 
> command is not understood) but when I close the db
> in rev then open it 
> in the Valentina application there are no records in
> the database.  
> Does anyone have any idea what is going on?
> 
> Thanks, Brian
> 
> global theDB
> 
> on mouseUp
> 
>    put the ticks into time1
> 
>    repeat for 1000000 times
>      put the random of 100000 into x
>      revExecuteSQL theDB, "INSERT INTO RandomTable
> (ID, StringData) 
> VALUES (" & x & "'String Value " & x & "')"
>    end repeat
> 
>    revCommitDatabase theDB
> 
>    put the ticks into time2
> 
>    answer (time2 - time1)
> 
> end mouseUp
> 

Hi Bryan,

It's always good to check 'the result' right after
executing a command ; so I'd suggest you change your
repeat loop to :
--
   repeat for 1000000 times
     put the random of 100000 into x
     revExecuteSQL theDB, \
         "INSERT INTO RandomTable " & \
         "(ID, StringData) VALUES (" & \
         x & ",'String Value " & x & "')"
     if the result is not empty then
       answer error (the result)
       exit to top
     end if
   end repeat
--

In this case, it would have given you some sort of
warning that the SQL statement was incorrect. There
was no comma between x and the stringdata.

In using Revoltuoon  with databases, the 'merge'
function has become my best friend to build sql-
queries and spot errors :
--
  put merge("INSERT INTO RandomTable (ID,StringData)
VALUES ([[x]],'String Value [[x]]')") into tSQLQuery
  revExecuteSQL theDB, tSQLQuery
--

If you look at its entry in the Transcript Dictionary,
you'll see that it will evaluate expressions between
[[ and ]], as well as execute code between <? and ?>
The end result is, at least IMHO, a combination of
readable queries and scripts.

Hope this helped,

Jan Schenkel.

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)

__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html


More information about the use-livecode mailing list