Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9155701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:38:36+00:00 2026-06-17T12:38:36+00:00

I was previously using sqlite3 for my ruby code and it worked fine for

  • 0

I was previously using sqlite3 for my ruby code and it worked fine for the following code

def existsCheck( db, id )
    temp = db.exec( 'SELECT 1 WHERE EXISTS(
        SELECT 1
        FROM Products
        WHERE promoID = ?
    ) ', [id] ).length > 0
end


def writeDB( db, product )
    db.exec( 'INSERT INTO Products ( promoID, name, price, shipping, condition, grade, included, not_included, image, time_added )
                        VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [product.promoID, product.name, product.price, product.shipping, product.condition, product.grade, product.included, product.notIncluded, product.image, product.time] )
end

Does Postgresql not support the idea of “?” or am I doing something wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:38:38+00:00Added an answer on June 17, 2026 at 12:38 pm

    From the fine PG::Connection manual:

    - (PG::Result) exec(sql[, params, result_format ])
    - (Object) exec(sql[, params, result_format ]) {|pg_result| ... }
    […]
    PostgreSQL bind parameters are represented as $1, $1, $2, etc., inside the SQL query. The 0th element of the params array is bound to $1, the 1st element is bound to $2, etc. nil is treated as NULL.

    So you want to use numbered placeholders with PostgreSQL:

    def existsCheck( db, id )
        temp = db.exec( 'SELECT 1 WHERE EXISTS(
            SELECT 1
            FROM Products
            WHERE promoID = $1
        ) ', [id] ).to_a.length > 0
        # You'll also need to .to_a the result before you can
        # treat it as an array...
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on some code that previously was using a cfquery, and is
Previously when I browsed source code files using Xcode's file browser (located on left
I am trying to use a previously created database following the tutorial: http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/ I
I'm looking to implement a REST client in PHP, and have previously been using
previously i was using picture box and its built in utilities to draw some
I have deployed a PHP application on my tomcat server(Tomcat 6.0).Previously I was using
I'm developing a graph control in WPF. I have previously developed it using GDI
Previously within my Fitnesse fixture I was specifying an expected WCF exception using: exception[FaultException]
Previously, I am using STL map to perform the mentioned task. struct ltstr {
I previously had a table that is created using hibernate entities. I am using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.