Results 1 to 3 of 3

Thread: database variables calculation in ruby

  1. #1
    Join Date
    Nov 2011
    Posts
    4

    database variables calculation in ruby

    Hi everybody, in my database, am trying to print the value of total and then add it to the price,
    i was able to fetch the value of total but when i tried to add it to to price so as to get value of sum in this line
    of code

    Code:
        sum = price + %s, row[0]  
        puts "sum"
    nothing happens. where am i supposed to perform the operations, is outside the loop. below is the code, any help please

    Code:
        #!/Ruby19/bin/ruby 
        require 'cgi'
    
        cgi = CGI.new
        puts cgi.header
    
        require "dbi"
    
    
    
         price = '100'
        begin
           # connect to the MySQL server
             conn = DBI.connect("DBI:Mysql:db:localhost", 
        	                    "root", "root566")
    
            rs = con.query("SELECT total from product where product_id = '20'")
    
           row = stmt.fetch do
              
           end
           puts "<font color=green size=4><b>get total values</b></font><br><br>"
    
         printf '<b>total:</b> %s<br>', row[0]
    
         sum = price + %s, row[0]  
        puts "sum"
         
           
                 
        rescue Mysql::Error => e
            puts e.errno
            puts e.error
            
        ensure
            con.close if con
        end

  2. #2
    Join Date
    May 2011
    Posts
    105

    Re: database variables calculation in ruby

    I found a help guide on ruby that can help you for this. The programming guide linked below has in detail information about ruby programming and its Classes, Objects, and Variables. I will recommend you to refer it once and then check back.


    Ruby Guide

  3. #3
    Join Date
    Nov 2011
    Posts
    4

    Re: database variables calculation in ruby

    it seems the values for total is not printed well or retrieve from database. any help on how to do that properly
    thanks

Similar Threads

  1. What is the calculation behind PMT and IPMT function
    By GuruT in forum MS Office Support
    Replies: 5
    Last Post: 18-01-2012, 06:48 PM
  2. MS Project calculation of end date
    By kerryger in forum Windows Software
    Replies: 1
    Last Post: 15-04-2011, 08:11 PM
  3. I need help on age calculation java programme
    By dream night in forum Software Development
    Replies: 1
    Last Post: 15-12-2010, 04:06 PM
  4. How to use Ruby application and benefits of ruby application
    By FlayoFish in forum Windows Software
    Replies: 3
    Last Post: 30-07-2009, 11:17 AM
  5. Replies: 3
    Last Post: 03-02-2009, 10:59 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,240,729.53794 seconds with 17 queries