FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Getting the length value from a Row

 
Post new topic   Reply to topic     Forum Index -> DDBI
View previous topic :: View next topic  
Author Message
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Sat Jan 27, 2007 1:37 pm    Post subject: Getting the length value from a Row Reply with quote

Greetings.

how do I read the contents of a Row? I mean, I know that I could do, row[0], row[2], etc. But, there is no length property or count. For example, I have sent this command to an sqlite db,

Code:
Rows = db.queryFetchAll("SELECT * FROM sqlite_master WHERE type='table' AND name='LSOpenJobs'");


to read the column headers. When I do,
Code:

    Rows = db.queryFetchAll("SELECT * FROM sqlite_master WHERE type='table' AND name='LSOpenJobs'");
    foreach(Row row; Rows)
      foreach (char str; row)
          writefln(str);

I get,
Code:
OpenJobs.d(903): Error: no property 'opApply' for type 'dbi.Row.Row'
OpenJobs.d(903): Error: function expected before (), not 1 of type int


but when I do,
Code:

    foreach(Row row; Rows)
      for (int i=0; i<6; i++)
        writefln(row[i]);

that prints the values, but then I run out of with,
Quote:

ArrayBoundsError Row(81)


Yes, I know we are working on the Row future, but right now, how do I know what is the last value of a Row or what size is the row?

thanks.
Back to top
View user's profile Send private message
jpelcis



Joined: 09 Mar 2006
Posts: 40

PostPosted: Fri Feb 02, 2007 8:09 pm    Post subject: Re: Getting the length value from a Row Reply with quote

Hello.

jicman wrote:
how do I read the contents of a Row? I mean, I know that I could do, row[0], row[2], etc. But, there is no length property or count. For example, I have sent this command to an sqlite db,

[snip]

Yes, I know we are working on the Row future, but right now, how do I know what is the last value of a Row or what size is the row?


There currently is no way to do so, but putting

Code:
size_t length () {
        return fieldTypes.length;
}


somewhere in the class should solve the problem for you in the short term.
Back to top
View user's profile Send private message
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Tue Aug 28, 2007 3:11 pm    Post subject: Reply with quote

thanks.
Back to top
View user's profile Send private message
stonecobra



Joined: 25 May 2004
Posts: 48
Location: Rough and Ready, CA

PostPosted: Sun Sep 09, 2007 12:12 pm    Post subject: Re: Getting the length value from a Row Reply with quote

jicman wrote:
When I do,
Code:

    Rows = db.queryFetchAll("SELECT * FROM sqlite_master WHERE type='table' AND name='LSOpenJobs'");
    foreach(Row row; Rows)
      foreach (char str; row)
          writefln(str);

I get,
Code:
OpenJobs.d(903): Error: no property 'opApply' for type 'dbi.Row.Row'
OpenJobs.d(903): Error: function expected before (), not 1 of type int



This is now supported in svn trunk. Simple foreach of a row will give you each field in turn.
Back to top
View user's profile Send private message
stonecobra



Joined: 25 May 2004
Posts: 48
Location: Rough and Ready, CA

PostPosted: Sun Sep 09, 2007 12:20 pm    Post subject: Re: Getting the length value from a Row Reply with quote

jpelcis wrote:

There currently is no way to do so, but putting

Code:
size_t length () {
        return fieldTypes.length;
}


somewhere in the class should solve the problem for you in the short term.


This has been added to trunk in revision 73.
Back to top
View user's profile Send private message
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Sun Sep 09, 2007 5:02 pm    Post subject: Re: Getting the length value from a Row Reply with quote

stonecobra wrote:

This has been added to trunk in revision 73.


Wow, from r62 to r73. Woowoowoowoowooo! What has been added in between?

thanks,

jic
Back to top
View user's profile Send private message
stonecobra



Joined: 25 May 2004
Posts: 48
Location: Rough and Ready, CA

PostPosted: Mon Sep 10, 2007 12:52 pm    Post subject: Re: Getting the length value from a Row Reply with quote

jicman wrote:
Wow, from r62 to r73. Woowoowoowoowooo! What has been added in between?


http://www.dsource.org/projects/ddbi/wiki/ChangeLog Check out the current trunk changes at the top Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DDBI All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group