New topic: Pervasive SQL Column Name problem.
<http://forums.realsoftware.com/viewtopic.php?t=43969> Page 1 of 1 [ 7 posts ] Previous topic | Next topic Author Message tseyfarth Post subject: Pervasive SQL Column Name problem.Posted: Fri May 11, 2012 3:17 pm Joined: Sat Dec 04, 2010 9:14 pm Posts: 620 Hello all, I am trying to retrieve data from an existing Pervasive SQL database. Some of the columns have names that contain [ 1], [ 2] and so on. What it is the correct method to code for this? This is what I have tried, and it does not work. Telephone = RsPBKARCUST.Field("BKAR_TELEPHONE[ 1]").StringValue Email = RsPBKARCUST.Field("BKAR_EMAIL[ 1]").StringValue Thank you Tim Top npalardy Post subject: Re: Pervasive SQL Column Name problem.Posted: Fri May 11, 2012 5:13 pm Real Software Engineer Joined: Sat Dec 24, 2005 8:18 pm Posts: 7236 Location: Canada, Alberta, Near Red Deer Are they arrays ? _________________ My web site Great White Software RBLibrary.com REALbasic learning Top tseyfarth Post subject: Re: Pervasive SQL Column Name problem.Posted: Fri May 11, 2012 5:55 pm Joined: Sat Dec 04, 2010 9:14 pm Posts: 620 It appears that they are. This is the C structure: char BKAR_TELEPHONE[ 1][25]; // String char BKAR_TELEPHONE[ 2][25]; // String char BKAR_TELEPHONE[ 3][25]; // String char BKAR_TELEPHONE[ 4][25]; // String char BKAR_TELEPHONE[ 5][25]; // String Tim Top npalardy Post subject: Re: Pervasive SQL Column Name problem.Posted: Fri May 11, 2012 7:02 pm Real Software Engineer Joined: Sat Dec 24, 2005 8:18 pm Posts: 7236 Location: Canada, Alberta, Near Red Deer I've worked with some other languages that permitted this in the database & quite honestly they are truly a pain in the ass (and quite easy to model in a truly relational way that doesn't waste space. Ie EVERY row has 5 values not just as many as it needs. For instance the "column" when you retrieve it is ALL the values - not any single one. The database API has no clue about columns that can hold arrays. I'm not sure if ODBC has a way for you to even say "get me the first value from this array of items" I'd use the debugger and just look in the values in the recordset for that column when you are debugging - and try and grab one record that has multiple entries in that column. _________________ My web site Great White Software RBLibrary.com REALbasic learning Top tseyfarth Post subject: Re: Pervasive SQL Column Name problem.Posted: Fri May 11, 2012 7:18 pm Joined: Sat Dec 04, 2010 9:14 pm Posts: 620 OK. Thanks for the tips. I did not realize they might be held in "one" field... will take a look at this, the approach will help to solve the problem. Thanks again! Tim Top tseyfarth Post subject: Re: Pervasive SQL Column Name problem.Posted: Fri May 11, 2012 7:49 pm Joined: Sat Dec 04, 2010 9:14 pm Posts: 620 Take a look at the picture please. Note the editor shows similar field naming as I presented. And the IDE stops in error on the code without a designator for the array number (if that is what it is). Tim Top timhare Post subject: Re: Pervasive SQL Column Name problem.Posted: Sat May 12, 2012 1:14 am Joined: Fri Jan 06, 2006 3:21 pm Posts: 11283 Location: Portland, OR USA Since RecordSet.Field() doesn't like the name, either because of the brackets or more likely the space, why not pull the field names into an array, then look up the field you want in the array and use RecordSet.IdxField() to get it by number. for i = 1 to rs.FieldCount fieldnames.append rs.IdxField(i).Name next .. .. n = fieldnames.IndexOf("BKAR_CONTACT[ 1]") s = rs.IdxField(n+1).StringValue Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 7 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
