lib/sdb/right_sdb_interface.rb
# Perform SQL-like select and fetch attributes.
# Attribute values must be quoted with a single or double quote. If a quote appears within the attribute value, it must be escaped with the same quote symbol as shown in the following example.
# (Use array to pass select_expression params to avoid manual escaping).
#
#  sdb.select(["select * from my_domain where gender=?", 'female']) #=>
#    {:request_id =>"8241b843-0fb9-4d66-9100-effae12249ec",
#     :items =>
#      [ { "035f1ba8-dbd8-11dd-80bd-001bfc466dd7"=>
#          {"hobby"   => ["cooking", "flowers", "cats"],
#           "name"    => ["Mary"],
#           "country" => ["Russia"],
#           "gender"  => ["female"],
#           "id"      => ["035f1ba8-dbd8-11dd-80bd-001bfc466dd7"]}},
#        { "0327614a-dbd8-11dd-80bd-001bfc466dd7"=>
#          {"hobby"   => ["patchwork", "bundle jumping"],
#           "name"    => ["Mary"],
#           "country" => ["USA"],
#           "gender"  => ["female"],
#           "id"      => ["0327614a-dbd8-11dd-80bd-001bfc466dd7"]}}, ... ]
#     :box_usage =>"0.0000506197"}
#
#   sdb.select('select country, name from my_domain') #=>
#    {:request_id=>"b1600198-c317-413f-a8dc-4e7f864a940a",
#     :items=>
#      [ { "035f1ba8-dbd8-11dd-80bd-001bfc466dd7"=> {"name"=>["Mary"],     "country"=>["Russia"]} },
#        { "376d2e00-75b0-11dd-9557-001bfc466dd7"=> {"name"=>["Putin"],    "country"=>["Russia"]} },
#        { "0327614a-dbd8-11dd-80bd-001bfc466dd7"=> {"name"=>["Mary"],     "country"=>["USA"]}    },
#        { "372ebbd4-75b0-11dd-9557-001bfc466dd7"=> {"name"=>["Bush"],     "country"=>["USA"]}    },
#        { "37a4e552-75b0-11dd-9557-001bfc466dd7"=> {"name"=>["Medvedev"], "country"=>["Russia"]} },
#        { "38278dfe-75b0-11dd-9557-001bfc466dd7"=> {"name"=>["Mary"],     "country"=>["Russia"]} },
#        { "37df6c36-75b0-11dd-9557-001bfc466dd7"=> {"name"=>["Mary"],     "country"=>["USA"]}    } ],
#     :box_usage=>"0.0000777663"}
#
# see: http://docs.amazonwebservices.com/AmazonSimpleDB/2007-11-07/DeveloperGuide/index.html?SDB_API_Select.html
#      http://docs.amazonwebservices.com/AmazonSimpleDB/2007-11-07/DeveloperGuide/index.html?UsingSelect.html
#      http://docs.amazonwebservices.com/AmazonSimpleDB/2007-11-07/DeveloperGuide/index.html?SDBLimits.html
#
Perform SQL-like select and fetch attributes.
Attribute values must be quoted with a single or double quote. If a quote appears within the attribute value, it must be escaped with the same quote symbol as shown in the following example.
(Use array to pass select_expression params to avoid manual escaping).






Perform SQL - like select and fetch attributes . Attribute values must be quoted with a single or double quote . If a quote appears within the attribute value it must be escaped with the same quote symbol as shown in the following example . ( Use array to pass select_expression params to avoid manual escaping ) .
def select(select_expression, next_token = nil)
      select_expression      = query_expression_from_array(select_expression) if select_expression.is_a?(Array)
      @last_query_expression = select_expression
      request_params = { 'SelectExpression' => select_expression,
                         'NextToken'        => next_token }
      link   = generate_request("Select", request_params)
      result = select_response_to_ruby(request_info( link, QSdbSelectParser.new ))
      return result unless block_given?
       loop if block if given
      begin
         the block must return true if it wanna continue
        break unless yield(result) && result[:next_token]
         make new request
        request_params['NextToken'] = result[:next_token]
        link   = generate_request("Select", request_params)
        result = select_response_to_ruby(request_info( link, QSdbSelectParser.new ))
      end while true
    rescue Exception
      on_exception
    end
def select ( select_expression , next_token = nil ) select_expression = query_expression_from_array ( select_expression ) if select_expression . is_a? ( Array ) @last_query_expression = select_expression request_params = { 'SelectExpression' => select_expression , 'NextToken' => next_token } link = generate_request ( "Select" , request_params ) result = select_response_to_ruby ( request_info ( link , QSdbSelectParser . new ) ) return result unless block_given? begin break unless yield ( result ) && result [ :next_token ] request_params [ 'NextToken' ] = result [ :next_token ] link = generate_request ( "Select" , request_params ) result = select_response_to_ruby ( request_info ( link , QSdbSelectParser . new ) ) end while true rescue Exception on_exception end
Perform SQL-like select and fetch attributes.
Perform SQL - like select and fetch attributes .
# # loop if block if given # the block must return true if it wanna continue # make new request
select_expression
<not_specific>
next_token
<not_specific>