Re: Stuck on native database functions

2021-07-13 Thread Bob Sneidar via use-livecode
Thanks for the confirmation. On the bright side, I am not likely to forget that 
again. :-)

Bob S


> On Jul 13, 2021, at 08:12 , R.H. via use-livecode 
>  wrote:
> 
> @Bob Sneidar
> 
> Hello Bob
> 
> The documentation bug was resolved in the latest version:
> https://quality.livecode.com/show_bug.cgi?id=23074
> 
> It was also tricky for me until I found out how to quote variables and
> arrays that point to data when sending data to my mySQL database as the
> documentation was not quite up to the point.
> 
> Hope you solved your problem.
> 
> Roland
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stuck on native database functions

2021-07-13 Thread R.H. via use-livecode
@Bob Sneidar

Hello Bob

The documentation bug was resolved in the latest version:
https://quality.livecode.com/show_bug.cgi?id=23074

It was also tricky for me until I found out how to quote variables and
arrays that point to data when sending data to my mySQL database as the
documentation was not quite up to the point.

Hope you solved your problem.

Roland
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stuck on native database functions

2021-07-09 Thread Bob Sneidar via use-livecode
Okay, so here's an updated version of my ArrayToSQLITE function. It takes an 
array, and as the name suggests, converts it to an sqLite database and returns 
the Database ID. Of note is that it now works with EMBEDDED ARRAYS! If it 
detects that a key is an array in the supplied array, it will create a BLOB 
column, otherwise it will create a VARCHAR column. (This is largely for syntax 
compatibility as sqLITE does not have data type constraints, but anything 
larger than 255 characters will need to be a BLOB [I think]. 

Then when building the insert statement, it will arrayEncode the value. 

I have not tested this yet, as I have no need of it, but if anyone wants to 
try, feel free and let me know if you find any issues. 

FUNCTION arrayToSQLite pArrayDataA, pDBFile, pDBName
   put the keys of pArrayDataA into tArrayKeys
   sort tArrayKeys numeric ascending
   IF pDBFile is empty THEN put ":memory:" into pDBFile
   IF pDBName is empty THEN put "arraydata" into pDBName
   
   TRY
  put revOpenDatabase("sqlite", pDBFile) into tDBID
  
  IF "Error" is in tDBID THEN
 throw tDBID
 return empty
  END IF
  
  put "drop table " & pDBName into tDropSQL
  revExecuteSQL tDBID, tDropSQL
  put  the result into tResult
   CATCH tError
  answer tError
  IF the environment is "development" THEN exit to top ELSE quit
   END TRY
   
   -- create the table
   put "create table" && quote & pDBName & quote \
 & cr into tCreateCommand
   put "(" & quote & "recordid" & quote && "NUMERIC PRIMARY KEY UNIQUE, " \
 & cr AFTER tCreateCommand
   
   put the keys of pArrayDataA [1] into tRecordKeyList
   
   REPEAT for each line tRecordKey in tRecordKeyList
  if pArrayDataA [1] [tRecordKey] is an array then 
 put "BLOB" into tColumnType
  else
 put VARCHAR into tColumnType
  end if
  
  put quote & tRecordKey & quote && tColumnType & "," && cr AFTER 
tCreateCommand
   END REPEAT
   
   delete char -3 to -1 of tCreateCommand
   put ")" AFTER tCreateCommand
   
   TRY
  revExecuteSQL tDBID, tCreateCommand
  put the result into tResult
  IF tResult is not 0 THEN breakpoint
   CATCH tError
  breakpoint
   END TRY
   
   put 1 into tRecordCounter
   put "recordid" & cr & tRecordKeyList into tColumns
   
   repeat with i = 1 to the number of lines of tColumns
  put ":" & i into item i of tColumnList
   end repeat
   
   put "(" & tColumnList & ")" into tColumnList
   
   -- insert data
   REPEAT for each line tKey in tArrayKeys
  put 1 into tColumnCounter
  put pArrayDataA [tKey] into tRecordDataA
  put tRecordCounter into tQueryDataA [1]
  
  REPEAT for each line tRecordKey in tRecordKeyList
 add 1 to tColumnCounter
 
 if tRecordDataA [tRecordKey] is an array then
put arrayEncode(tRecordDataA [tRecordKey]) into tValue
 else
put tRecordDataA [tRecordKey] into tValue
 end if
 
 put tValue into tQueryDataA [tColumnCounter]
  END REPEAT
  
  put "insert into" && pDBName &&  "VALUES" && tColumnList into tInsertSQL
  
  TRY
 revExecuteSQL tDBID, tInsertSQL, "tQueryDataA"
 put the result into tResult
 if the result is not a number then breakpoint
  CATCH tError
 breakpoint
  END TRY
  
  add 1 to tRecordCounter
   END REPEAT
   
   return tDBID
END arrayToSQLite


> On Jul 9, 2021, at 08:09 , Bob Sneidar via use-livecode 
>  wrote:
> 
> Okay I found out what I did wrong. The array variable needs to be enclosed in 
> quotes. I remember now some time in the past looking at that and saying, "Why 
> are their quotes around the array variable? That won't work!" So I removed 
> them and subsequently shot myself in the foot. 
> 
> For the record, having a parameter that can be either a string or an array, 
> and then having to enclose the name of the array in quotes to keep the 
> handler from confusing it as a string, strikes me as a really odd way to do 
> things. But hey, it is what it is. 
> 
> Bob S


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stuck on native database functions

2021-07-09 Thread Bob Sneidar via use-livecode
Okay I found out what I did wrong. The array variable needs to be enclosed in 
quotes. I remember now some time in the past looking at that and saying, "Why 
are their quotes around the array variable? That won't work!" So I removed them 
and subsequently shot myself in the foot. 

For the record, having a parameter that can be either a string or an array, and 
then having to enclose the name of the array in quotes to keep the handler from 
confusing it as a string, strikes me as a really odd way to do things. But hey, 
it is what it is. 

Bob S


> On Jul 7, 2021, at 09:52 , Mark Smith via use-livecode 
>  wrote:
> 
> Yes, using the numeric placeholders will do that for you. 
> 
>> On Jul 7, 2021, at 4:43 PM, Terence Heaford via use-livecode 
>>  wrote:
>> 
>> It also seems to do the escaping for you as it handled text containing 
>> commas in the description
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stuck on native database functions

2021-07-07 Thread Mark Smith via use-livecode
Yes, using the numeric placeholders will do that for you. 

> On Jul 7, 2021, at 4:43 PM, Terence Heaford via use-livecode 
>  wrote:
> 
> It also seems to do the escaping for you as it handled text containing commas 
> in the description

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stuck on native database functions

2021-07-07 Thread Terence Heaford via use-livecode
It also seems to do the escaping for you as it handled text containing commas 
in the description

All the best

Terry


> On 7 Jul 2021, at 16:40, Terence Heaford via use-livecode 
>  wrote:
> 
> The routine I have working is
> 
> put "uniqueID,date,type,description,amount,balance,category" into tFields
> 
> put merge("INSERT INTO [[tAccountName]] ([[tFields]]) 
> VALUES(:1,:2,:3,:4,:5,:6,:7)") into tSQL
> 
> revExecuteSQL dbGetID(), tSQL, "tValues[uniqueID]", "tValues[date]", 
> "tValues[type]", "tValues[description]", "tValues[amount]", 
> "tValues[balance]","tValues[category]"
> 
> put the result into tErr
> 
> return tErr
> 
> 
> It resolves the error I was getting relating to autoincrement.

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stuck on native database functions

2021-07-07 Thread Terence Heaford via use-livecode
Mark, it certainly helps me.

The routine I have working is

put "uniqueID,date,type,description,amount,balance,category" into tFields

put merge("INSERT INTO [[tAccountName]] ([[tFields]]) 
VALUES(:1,:2,:3,:4,:5,:6,:7)") into tSQL

revExecuteSQL dbGetID(), tSQL, "tValues[uniqueID]", "tValues[date]", 
"tValues[type]", "tValues[description]", "tValues[amount]", 
"tValues[balance]","tValues[category]"

put the result into tErr

return tErr


It resolves the error I was getting relating to autoincrement.

Thanks

Terry


> On 7 Jul 2021, at 11:29, Mark Smith via use-livecode 
>  wrote:
> 
> Currently I have this working
> 
> (Content of tSQL :)
> INSERT into TABLE1 ("complete", "todo", "itemDate", "category", "purgeDate", 
> "dgOrder") values(:1, :2, :3, :4, :5, :6)
> 
> 
> revExecuteSQL gConnectID, tSQL, "ptheRowA[complete]", "ptheRowA[todo]", 
> "ptheRowA[itemDate]", "ptheRowA[category]", "ptheRowA[purgeDate]", 
> "ptheRowA[dgOrder]”
> 
> I am not passing the entire array because there are some array elements that 
> I am not saving. If I did want to save/insert the whole array then I would 
> write something like:
> 
> revExecuteSQL gConnectID, tSQL, “ptheRowA”
> 
> Hope that helps,
> Mark

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stuck on native database functions

2021-07-07 Thread Mark Smith via use-livecode
Currently I have this working

(Content of tSQL :)
INSERT into TABLE1 ("complete", "todo", "itemDate", "category", "purgeDate", 
"dgOrder") values(:1, :2, :3, :4, :5, :6)


revExecuteSQL gConnectID, tSQL, "ptheRowA[complete]", "ptheRowA[todo]", 
"ptheRowA[itemDate]", "ptheRowA[category]", "ptheRowA[purgeDate]", 
"ptheRowA[dgOrder]”

I am not passing the entire array because there are some array elements that I 
am not saving. If I did want to save/insert the whole array then I would write 
something like:

revExecuteSQL gConnectID, tSQL, “ptheRowA”

Hope that helps,
Mark



> On Jul 7, 2021, at 12:06 AM, Bob Sneidar via use-livecode 
>  wrote:
> 
> Hi all. 
> 
> I assemble an SQL statement that looks like this: 
> 
> insert into ObjectProperties (recordid,rect,controlname,owner,visible) VALUES 
> (:1,:2,:3,:4,:5)
> 
> I then execute this statement: 
> 
> revExecuteSQL tDBID, tInsertSQL, aRecordData
> 
> I get records but with no data in them. I checked aRecordData and it has all 
> 5 columns as keys and data in each of them. 
> 
> I am at a complete loss. I was sure this was working before, now it is not. 
> 
> Bob S
> 
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stuck on native database functions

2021-07-07 Thread Terence Heaford via use-livecode
Out of interest and not sure if it is relevant but I have received this error:

"table myTable has 8 columns but 7 values were supplied"

Yes the table has 8 columns in total but the first column is

recID integer primary key autoincrement

Surely it should not give this error because I do not provide the value as this 
is autoincrement

All the best

Terry



> On 7 Jul 2021, at 08:50, Terence Heaford via use-livecode 
>  wrote:
> 
> Not sure what to try next

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stuck on native database functions

2021-07-07 Thread Terence Heaford via use-livecode
Just tried this method

revExecuteSQL myID, "insert into mytable values(:1,:2,:1)", "valueX",”valueY"

It did not work

put 
merge("[[quote]][[tUniqueID]][[quote]],[[quote]][[tDate]][[quote]],[[quote]][[tType]][[quote]],[[quote]][[tDescription]][[quote]],[[quote]][[tAmount]][[quote]],[[quote]][[tBalance]][[quote]],[[quote]][[tCategory]][[quote]]")into
 tValues

put ":1,:2,:3,:4,:5,:6,:7" into tPlaceHolders

put merge("INSERT INTO [[tAccountName]] VALUES([[tPlaceHolders]])") into tSQL

put tSQL & " " & tValues

revExecuteSQL dbGetID(),tSQL,tValues


Not sure what to try next


All the best

Terry

> On 7 Jul 2021, at 08:28, Terence Heaford  wrote:
> 
> I have now tried your method with the tValues array directly and by 
> deconstructing the array as below and it does not work. I have a recollection 
> of not being able to get this to work with an array which is why I did the 
> way I did.
> 
> 
> All the best
> 
> Terry
> 
> put q(tAccountName) into tAccountName
> 
> put q(tValues["uniqueID"]) into tUniqueID
> 
> put q(tValues["date"]) into tDate
> 
> put q(tValues["type"]) into tType
> 
> put q(tValues["description"]) into tDescription
> 
> put q(tValues["amount"]) into tAmount
> 
> put q(tValues["balance"]) into tBalance
> 
> put q(tValues["category"]) into tCategory
> 
> put 
> merge("[[tUniqueID]],[[tDate]],[[tType]],[[tDescription]],[[tAmount]],[[tBalance]],[[tCategory]]”)
>  into tValues
> 
> 
> put ":1,:2,:3,:4,:5,:6,:7" into tPlaceHolders
> 
> put merge("INSERT INTO [[tAccountName]] VALUES([[tPlaceHolders]])") into tSQL
> 
> put tSQL & " " & tValues
> 
> revExecuteSQL dbGetID(),tSQL,tValues
> 
> 
> 
> 
> 
>> On 7 Jul 2021, at 07:52, Terence Heaford via use-livecode 
>> mailto:use-livecode@lists.runrev.com>> wrote:
>> 
>> Here’s an example I have been using, not sure whether it will help:
>> 
>> function dbAddTransaction tAccountName,tValues
>> 
>> put q(tAccountName) into tAccountName
>> 
>> put q(tValues["uniqueID"]) into tUniqueID
>> 
>> put q(tValues["date"]) into tDate
>> 
>> put q(tValues["type"]) into tType
>> 
>> put q(tValues["description"]) into tDescription
>> 
>> put q(tValues["amount"]) into tAmount
>> 
>> put q(tValues["balance"]) into tBalance
>> 
>> put q(tValues["category"]) into tCategory
>> 
>> put "uniqueID,date,type,description,amount,balance,category" into tFields
>> 
>> put 
>> merge("[[tUniqueID]],[[tDate]],[[tType]],[[tDescription]],[[tAmount]],[[tBalance]],[[tCategory]]")into
>>  tValues
>> 
>> put merge("INSERT INTO [[tAccountName]] ([[tFields]]) VALUES([[tValues]])") 
>> into tSQL
>> 
>> revExecuteSQL dbGetID(), tSQL
>> 
>> put the result into tErr
>> 
>> return tErr
>> 
>> end dbAddTransaction
>> 
>> -
>> 
>> function dbEscapeSqlite tText
>> 
>> replace "'" with "''" in tText
>> 
>> return tText
>> 
>> end dbEscapeSqlite
>> 
>> ---
>> 
>> function q tText
>> 
>> return "'" & dbEscapeSqlite(tText) & "'"
>> 
>> end q
>> 
>> ---
>> 
>> 
>> 
>> 
>>> On 7 Jul 2021, at 00:06, Bob Sneidar via use-livecode 
>>> mailto:use-livecode@lists.runrev.com>> 
>>> wrote:
>>> 
>>> Hi all. 
>>> 
>>> I assemble an SQL statement that looks like this: 
>>> 
>>> insert into ObjectProperties (recordid,rect,controlname,owner,visible) 
>>> VALUES (:1,:2,:3,:4,:5)
>>> 
>>> I then execute this statement: 
>>> 
>>> revExecuteSQL tDBID, tInsertSQL, aRecordData
>>> 
>>> I get records but with no data in them. I checked aRecordData and it has 
>>> all 5 columns as keys and data in each of them. 
>>> 
>>> I am at a complete loss. I was sure this was working before, now it is not. 
>>> 
>>> Bob S
>>> 
>>> 
>>> ___
>>> use-livecode mailing list
>>> use-livecode@lists.runrev.com 
>>> Please visit this url to subscribe, unsubscribe and manage your 
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
>> ___
>> use-livecode mailing list
>> use-livecode@lists.runrev.com 
>> Please visit this url to subscribe, unsubscribe and manage your subscription 
>> preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> 

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stuck on native database functions

2021-07-07 Thread Terence Heaford via use-livecode
I have now tried your method with the tValues array directly and by 
deconstructing the array as below and it does not work. I have a recollection 
of not being able to get this to work with an array which is why I did the way 
I did.


All the best

Terry

put q(tAccountName) into tAccountName

put q(tValues["uniqueID"]) into tUniqueID

put q(tValues["date"]) into tDate

put q(tValues["type"]) into tType

put q(tValues["description"]) into tDescription

put q(tValues["amount"]) into tAmount

put q(tValues["balance"]) into tBalance

put q(tValues["category"]) into tCategory

put 
merge("[[tUniqueID]],[[tDate]],[[tType]],[[tDescription]],[[tAmount]],[[tBalance]],[[tCategory]]”)
 into tValues


put ":1,:2,:3,:4,:5,:6,:7" into tPlaceHolders

put merge("INSERT INTO [[tAccountName]] VALUES([[tPlaceHolders]])") into tSQL

put tSQL & " " & tValues

revExecuteSQL dbGetID(),tSQL,tValues





> On 7 Jul 2021, at 07:52, Terence Heaford via use-livecode 
>  wrote:
> 
> Here’s an example I have been using, not sure whether it will help:
> 
> function dbAddTransaction tAccountName,tValues
> 
> put q(tAccountName) into tAccountName
> 
> put q(tValues["uniqueID"]) into tUniqueID
> 
> put q(tValues["date"]) into tDate
> 
> put q(tValues["type"]) into tType
> 
> put q(tValues["description"]) into tDescription
> 
> put q(tValues["amount"]) into tAmount
> 
> put q(tValues["balance"]) into tBalance
> 
> put q(tValues["category"]) into tCategory
> 
> put "uniqueID,date,type,description,amount,balance,category" into tFields
> 
> put 
> merge("[[tUniqueID]],[[tDate]],[[tType]],[[tDescription]],[[tAmount]],[[tBalance]],[[tCategory]]")into
>  tValues
> 
> put merge("INSERT INTO [[tAccountName]] ([[tFields]]) VALUES([[tValues]])") 
> into tSQL
> 
> revExecuteSQL dbGetID(), tSQL
> 
> put the result into tErr
> 
> return tErr
> 
> end dbAddTransaction
> 
> -
> 
> function dbEscapeSqlite tText
> 
> replace "'" with "''" in tText
> 
> return tText
> 
> end dbEscapeSqlite
> 
> ---
> 
> function q tText
> 
> return "'" & dbEscapeSqlite(tText) & "'"
> 
> end q
> 
> ---
> 
> 
> 
> 
>> On 7 Jul 2021, at 00:06, Bob Sneidar via use-livecode 
>>  wrote:
>> 
>> Hi all. 
>> 
>> I assemble an SQL statement that looks like this: 
>> 
>> insert into ObjectProperties (recordid,rect,controlname,owner,visible) 
>> VALUES (:1,:2,:3,:4,:5)
>> 
>> I then execute this statement: 
>> 
>> revExecuteSQL tDBID, tInsertSQL, aRecordData
>> 
>> I get records but with no data in them. I checked aRecordData and it has all 
>> 5 columns as keys and data in each of them. 
>> 
>> I am at a complete loss. I was sure this was working before, now it is not. 
>> 
>> Bob S
>> 
>> 
>> ___
>> use-livecode mailing list
>> use-livecode@lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription 
>> preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stuck on native database functions

2021-07-06 Thread Terence Heaford via use-livecode
Here’s an example I have been using, not sure whether it will help:

function dbAddTransaction tAccountName,tValues

put q(tAccountName) into tAccountName

put q(tValues["uniqueID"]) into tUniqueID

put q(tValues["date"]) into tDate

put q(tValues["type"]) into tType

put q(tValues["description"]) into tDescription

put q(tValues["amount"]) into tAmount

put q(tValues["balance"]) into tBalance

put q(tValues["category"]) into tCategory

put "uniqueID,date,type,description,amount,balance,category" into tFields

put 
merge("[[tUniqueID]],[[tDate]],[[tType]],[[tDescription]],[[tAmount]],[[tBalance]],[[tCategory]]")into
 tValues

put merge("INSERT INTO [[tAccountName]] ([[tFields]]) VALUES([[tValues]])") 
into tSQL

revExecuteSQL dbGetID(), tSQL

put the result into tErr

return tErr

end dbAddTransaction

-

function dbEscapeSqlite tText

replace "'" with "''" in tText

return tText

end dbEscapeSqlite

---

function q tText

return "'" & dbEscapeSqlite(tText) & "'"

end q

---




> On 7 Jul 2021, at 00:06, Bob Sneidar via use-livecode 
>  wrote:
> 
> Hi all. 
> 
> I assemble an SQL statement that looks like this: 
> 
> insert into ObjectProperties (recordid,rect,controlname,owner,visible) VALUES 
> (:1,:2,:3,:4,:5)
> 
> I then execute this statement: 
> 
> revExecuteSQL tDBID, tInsertSQL, aRecordData
> 
> I get records but with no data in them. I checked aRecordData and it has all 
> 5 columns as keys and data in each of them. 
> 
> I am at a complete loss. I was sure this was working before, now it is not. 
> 
> Bob S
> 
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stuck on native database functions

2021-07-06 Thread Rick Harrison via use-livecode
Hi Bob,

Some quick questions:

1. What version of LiveCode are you using?
2. Are you on Mac or Windows or Linux?
3. Are you using MySQL or PostgreSQL?

Have you ever tried using the free version of Valentina Studio
to help you with managing your databases?  It’s quite nice!

Let us know!

Rick

> On Jul 6, 2021, at 7:51 PM, Bob Sneidar via use-livecode 
>  wrote:
> 
> So I checked out the lessons. I do not find anything there for using 
> substitutions like :1, :2. I am getting records inserted but with empty data. 
> Really frustrating. 
> 
> I could use literal data, which I tested, and which works, but my real data 
> contains commas, and in the future may contain any number of special 
> characters that I will have to escape. Not my idea of fun. 
> 
> I was hoping to do a "quickie" implementation but it seems I will have to run 
> this through sqlYoga like everything else I do these days. 
> 
> Bob S
> 


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stuck on native database functions

2021-07-06 Thread Bob Sneidar via use-livecode
So I checked out the lessons. I do not find anything there for using 
substitutions like :1, :2. I am getting records inserted but with empty data. 
Really frustrating. 

I could use literal data, which I tested, and which works, but my real data 
contains commas, and in the future may contain any number of special characters 
that I will have to escape. Not my idea of fun. 

I was hoping to do a "quickie" implementation but it seems I will have to run 
this through sqlYoga like everything else I do these days. 

Bob S


> On Jul 6, 2021, at 16:26 , Bob Sneidar via use-livecode 
>  wrote:
> 
> Well that won't work. How does it know I want to insert the data in 
> aRecordData? Also I put quotes around the column names but got the same 
> results. 
> 
> Bob S
> 
> 
>> On Jul 6, 2021, at 16:14 , Devin Asay via use-livecode 
>>  wrote:
>> 
>> revExecuteSQL “aRecordData”
>> 
>> Not tested, but I’m pretty sure if you sort these things it will start to 
>> work for you.
>> 
>> - Devin
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stuck on native database functions

2021-07-06 Thread Bob Sneidar via use-livecode
Well that won't work. How does it know I want to insert the data in 
aRecordData? Also I put quotes around the column names but got the same 
results. 

Bob S


> On Jul 6, 2021, at 16:14 , Devin Asay via use-livecode 
>  wrote:
> 
> revExecuteSQL “aRecordData”
> 
> Not tested, but I’m pretty sure if you sort these things it will start to 
> work for you.
> 
> - Devin

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stuck on native database functions

2021-07-06 Thread Devin Asay via use-livecode
Bob,

A couple of things: You should either be passing variable names, not variable 
contents, so put your variable names in quotes.

revExecuteSQL “tDBID", “tInsertSQL", “tControlName”, etc

OR  you should be passing the name of an array variable, whose keys are numeric:


revExecuteSQL “aRecordData”

Not tested, but I’m pretty sure if you sort these things it will start to work 
for you.

- Devin



> On Jul 6, 2021, at 5:06 PM, Bob Sneidar via use-livecode 
>  wrote:
> 
> Hi all. 
> 
> I assemble an SQL statement that looks like this: 
> 
> insert into ObjectProperties (recordid,rect,controlname,owner,visible) VALUES 
> (:1,:2,:3,:4,:5)
> 
> I then execute this statement: 
> 
> revExecuteSQL tDBID, tInsertSQL, aRecordData
> 
> I get records but with no data in them. I checked aRecordData and it has all 
> 5 columns as keys and data in each of them. 
> 
> I am at a complete loss. I was sure this was working before, now it is not. 
> 
> Bob S
> 
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

Devin Asay
Director
Office of Digital Humanities
Brigham Young University

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Stuck on native database functions

2021-07-06 Thread Bob Sneidar via use-livecode
Hi all. 

I assemble an SQL statement that looks like this: 

insert into ObjectProperties (recordid,rect,controlname,owner,visible) VALUES 
(:1,:2,:3,:4,:5)

I then execute this statement: 

revExecuteSQL tDBID, tInsertSQL, aRecordData

I get records but with no data in them. I checked aRecordData and it has all 5 
columns as keys and data in each of them. 

I am at a complete loss. I was sure this was working before, now it is not. 

Bob S


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode