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 6981869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:12:49+00:00 2026-05-27T18:12:49+00:00

Is it somehow possible to use named placeholders where DBI allows @bind_values? E. g.,

  • 0

Is it somehow possible to use named placeholders where DBI allows @bind_values? E. g., I would like to make statements like:

my $s = $DB->selectcol_arrayref ("SELECT a FROM b
                                  WHERE c = ? OR d = ? OR e = ?;",
                                  {},
                                  $par1, $par2, $par1) or
        die ($DB->errstr ());

less prone to mistakes. I’m using DBD::Pg and DBD::SQLite.

  • 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-05-27T18:12:49+00:00Added an answer on May 27, 2026 at 6:12 pm

    What sorts of placeholders (if any) are supported depends on the driver:

    Placeholders and Bind Values

    Some drivers support placeholders and bind values.
    […]
    Some drivers also allow placeholders like :name and :N (e.g., :1, :2, and so on) in addition to ?, but their use is not portable.

    But you’re in luck, the PostgreSQL driver supports named or numbered parameters:

    There are three types of placeholders that can be used in DBD::Pg. The first is the “question mark” type, in which each placeholder is represented by a single question mark character.
    […]
    The method second type of placeholder is “dollar sign numbers”.
    […]
    The final placeholder type is “named parameters” in the format “:foo”.

    And the SQLite driver also supports them:

    SQLite supports several placeholder expressions, including ? and :AAAA.

    The downside is that you’ll end up using bind_param a lot with the named parameters so you won’t be able to use conveniences like selectcol_arrayref and $sth->execute(1,2,3) (Note: If anyone knows how to use named placeholders with execute I’d appreciate some pointers in a comment, I’ve never figured out how to do it). However, you can use the various forms of number placeholders (such as select c from t where x = $1 for PostgreSQL or select c from t where x = ?1 for SQLite).

    Also be aware that PostgreSQL uses colons for array slices and question marks for some operators so sometimes the standard ? placeholders and :name named placeholders can cause problems. I’ve never had any problems with ? but I’ve never used the geometric operators either; I suspect that sensible use of whitespace would avoid any problems with ?. If you’re not using PostgreSQL arrays, then you probably don’t have to worry about array slices fighting with your :name named placeholders.


    Executive Summary: You can’t use named placeholders with selectcol_arrayref or similar methods that work with @bind_params. However, with SQLite and Postgresql, you can use numbered placeholders ($1, $2, … for Postgresql or ?1, ?2, … for SQLite) with the methods that work with @bind_params or you can use named placeholders (:name for both PostgreSQL and SQLite) if you’re happy using the longer prepare/bind_param/execute/fetch sequence of methods and you’ll have to be careful if you use PostgreSQL arrays in your queries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it somehow possible to use the 'With' keyword on an existing object? I
Is it possible to somehow use a .bat file to script the schema and/or
Is it possible somehow to close StreamReader after calling ReadToEnd method in construction like
is it possible somehow to use the NOW() function or something similar in MYSQL
My situation is somehow interesting. I am trying to use Ant to make a
As I understand from the question below it should be possible to use different
In Make it's possible to compute variable names in runtime using double-evaluation, like $($(var))
is it somehow possible to call a rails function or to access a rails
Is it somehow possible on Swing to set a TitledBorder transparent so that a
Is it somehow possible to customize or subclass System.Windows.Forms.ColorDialog to add a few buttons?

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.