Unwanted linebreaks in result of database query

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
redfield
Posts: 95
Joined: Thu Apr 04, 2019 1:41 pm

Unwanted linebreaks in result of database query

Post by redfield » Sat Apr 23, 2022 10:39 am

Hi Guys,

after a loooong time I have begun to play with Livecode again. So here is my question :) :

The result of

Code: Select all

put "SELECT * FROM table1" into resultTable
put revDataFromQuery(, , gConID, resultTable) into tmpResult
comes with linebreaks in tmpResult, which split each record of the table into two lines. What I mean is something like this:

answer tmpResult
R1Value1 R1Value2 R1Value3
R1Value4 R1Value5
R2Value1 R2Value2 ...
This way I can't really work with repeat for each line l in tmpResult. Is there a way to prevent the linebreak within a record from a database table?

Or alternatively, if I throw each value of each record into an own variable, would this be insufficient regarding performance?

Code: Select all

put "SELECT qty FROM table1" into rQty
put "SELECT type FROM table1" into rType
put "SELECT symbol FROM table1" into rSymbol
   
put revDataFromQuery(, , gConID, rQty) into tmpQty
put revDataFromQuery(, , gConID, rType) into tmpType
put revDataFromQuery(, , gConID, rSymbol) into tmpSymbol

Klaus
Posts: 13821
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Unwanted linebreaks in result of database query

Post by Klaus » Sat Apr 23, 2022 10:50 am

Hi redfield,

welcome back! :-)

Well, the default field delimiter is TAB and the default ROW delimiter is CR,
and if you leave these two parameters empty, the default delimiters will be used:

Code: Select all

put revDataFromQuery(, , gConID, resultTable) into tmpResult
## =
put revDataFromQuery(TAB,CR, gConID, resultTable) into tmpResult
So fill in something else that is likely not in the returned data like e.g. "|||":

Code: Select all

put revDataFromQuery(,"|||", gConID, resultTable) into tmpResult
Then you can later:

Code: Select all

...
set linedelimiter to "|||"
repeat for each line tLine in tmpResult
...
Best

Klaus

redfield
Posts: 95
Joined: Thu Apr 04, 2019 1:41 pm

Re: Unwanted linebreaks in result of database query

Post by redfield » Sat Apr 23, 2022 12:57 pm

Well thanks a lot Klaus. I did not know that
revDataFromQuery(, ,
is equal to
revDataFromQuery(TAB,CR,
and also linedelimiter is new to me. Up to now I have only played with itemdelimiter :oops: .

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”