[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Processing postgres table

Dan Webb

10/22/2008 2:45:00 PM

I'm using the ruby-postgres gem as ruby-pg isn't installing & as there
no longer seems to be any tutorials or how-tos I thought I'd ask here.

Basically I'm trying to iterate through each row of data and assign the
values to some variables then print them out to XML (XML output's sorted
thanks to builder)
This is one set of that data, one question with 5 answers. How can I go
about finding out the number of rows that contain the same first column?


"A new question by mbr - option 3 is the correct
option";"afsdfsd";"mbr";"";FALSE;"-0.25";"1";"''"

"A new question by mbr - option 3 is the correct
option";"sdfsdf";"mbr";"";FALSE;"-0.25";"2";"''"

"A new question by mbr - option 3 is the correct
option";"sdfsdf";"mbr";"";TRUE;"1.0";"3";"''"

"A new question by mbr - option 3 is the correct
option";"sdfsdf";"mbr";"";FALSE;"-0.25";"4";"''"

"A new question by mbr - option 3 is the correct
option";"sdfsdaf";"mbr";"";FALSE;"-0.25";"5";"''"



This is the current code I'm using for postgres.
db = PGconn.connect(pghost, pgport,'','',pgtbl,dbname,'')
results = db.exec('SELECT question_stem, option_text, author_id,
module_code, correct, weighting, option_id, feedback FROM RESULTS_JOIN')
results.each do |row|
puts "by position: #{row[0]} #{row[1]} #{row[2]} #{row[3]} #{row[4]}
#{row[5]} #{row[6]} #{row[7]} "
end

any pointers would be great.
Kind Regards,
Dan
--
Posted via http://www.ruby-....

2 Answers

Robert Klemme

10/23/2008 12:04:00 PM

0

2008/10/22 Dan Webb <dbw@aber.ac.uk>:
> I'm using the ruby-postgres gem as ruby-pg isn't installing & as there
> no longer seems to be any tutorials or how-tos I thought I'd ask here.
>
> Basically I'm trying to iterate through each row of data and assign the
> values to some variables then print them out to XML (XML output's sorted
> thanks to builder)
> This is one set of that data, one question with 5 answers. How can I go
> about finding out the number of rows that contain the same first column?

SELECT question_stem, count(*)
FROM RESULTS_JOIN
group by question_stem

Cheers

robert

--
remember.guy do |as, often| as.you_can - without end

Lorne

2/16/2014 2:30:00 PM

0

On 16/02/2014 14:23, Michelle Steiner wrote:
> In article <barmar-28DF9F.02062116022014@news.eternal-september.org>,
> Barry Margolin <barmar@alum.mit.edu> wrote:
>
>> In article <150220142032389140%michelle@michelle.org>,
>> Michelle Steiner <michelle@michelle.org> wrote:
>>
>>> S deals, none vul. I was North
>>>
>>> KQJ32
>>> AJ2
>>> KJ
>>> Q64
>>>
>>> T9854
>>> K
>>> A98
>>> AKT7
>>>
>>> Our bidding:
>>>
>>> S N
>>> 1S 2NT (Jacoby)
>>> 3H 4NT
>>> 5H 6S
>>> P
>>
>> It's usually a bad idea to use Blackwood when you have a suit where
>> neither partner has shown a control. After South bid 3H, North should
>> temporize with 3S, to give South a chance to cue bid. When South bids
>> 4C, then North can bid 4NT. Or, since North is making a slam try by
>> temporizing, and South has all the side suits controlled, South can bid
>> Blackwood then.
>
> Good point. It's something I didn't think of (I was North), but I'm
> not sure that my partner would have realized what was going on if I had
> bid 3S, and would merely have bid 4S.
>
3S should show slam interest, otherwise you would have bid 4S.

It is a very important part of slam bidding that you agree that when an
auction is game forcing a jump to game is minimum for previous bids and
bidding trumps at a lower level shows interest in which controls partner
has - keeping the auction low to give maximum space to explore the hand.