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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:14:40+00:00 2026-06-01T23:14:40+00:00

I am retrieving the following sql statement from a table and then using bind

  • 0

I am retrieving the following sql statement from a table and then using bind variables to substitute the values in. I get a syntax error when running the statement. It seems to be occurring as a result of the lower() function however I believe I am using this correctly. I have tried running the statement manually via psql and it works fine with the values I provide. Does anyone have any ideas on this one? I have tried switching the ‘ for $$ but this had no effect.

statement

SELECT column_name 
FROM information_schema.columns 
WHERE table_name=lower(':1') 
  and column_name=lower(':2')

expected basic statement with substituted values

SELECT column_name 
FROM information_schema.columns 
WHERE table_name=lower('MyTableName') 
  and column_name=lower('MyColumnName')

statement run by postgresql

SELECT column_name 
FROM information_schema.columns 
WHERE table_name=lower('((E'RWOL_TMA_ROADWORKS'))') 
and column_name=lower('((E'TPHS_CWAY_RESTRICT_TYPE'))')

Error in C#

ERROR: 42601: syntax error at or near \"MyTableName\"

Error in PostgreSQL log file

2012-04-16 11:36:15 BST ERROR:  syntax error at or near "RWOL_TMA_ROADWORKS" at character 80
2012-04-16 11:36:15 BST STATEMENT:  SELECT column_name FROM information_schema.columns WHERE table_name=lower('((E'RWOL_TMA_ROADWORKS'))') and column_name=lower('((E'TPHS_CWAY_RESTRICT_TYPE'))')

EDIT: Retrieval and implementation code is written in C#. I use the database connection base classes and the npgsql provider factory in order to make connections, run queries and retrieve the data. This method works for all other queries that use this method of binding variables etc apart from this one where I try to use the lower() function.

EDIT: I have tried removing the quotes altogether to let the binding agent deal with quoting the values and this provided the same syntax error.

EDIT: Have now enabled logging and added the actual statement that postgresql is running.

  • 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-01T23:14:41+00:00Added an answer on June 1, 2026 at 11:14 pm

    I think vyegorov is on the right path – there’s something funny with your placeholders.

    I don’t think your second example is the actual query after substition because that doesn’t contain any errors. Where did it come from and why aren’t you providing the actual query – do you have statement logging turned on in PostgreSQL?

    Also, I’m suspicious of the syntax error – what’s going on with the escaped double-quotes? Are they actually double-quotes and not doubled-up single quotes?

    1. Are you sure you need single-quotes around your placeholders? Usually the drivers manage that for you.

    2. Are you sure you aren’t double-quoting the values anywhere?

    Get the actual SQL and look at the quoting and the problem will be obvious I suspect.

    UPDATE: now have SQL

    Here’s the error in the posted statement:

    lower('((E'RWOL_TMA_ROADWORKS'))')
    

    You’ve got two levels of quotes here. Remove the ones you’ve added and we should end up with something like:

    lower((E'RWOL_TMA_ROADWORKS'))
    

    Ignoring the repeated brackets that’s valid (The E’…’ is the syntax for a c-style escaped string – google around standard_conforming_strings).

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

Sidebar

Related Questions

I'm currently using the following SQL for retrieving the last seven days worth of
Using the following code, I'm retrieving a list of Integers from a DB and
I am retrieving data from a SQL table so I can display the result
In the following code for retrieving data via a SQL query from the db,
I am retrieving results from twitter using jQuery using the following code: $(document).ready(function(){ var
I created the following method for retrieving stored settings from the database: public String
Hey I got the following ps for retrieving the site template from SharePoint,but I
I have the following function in ruby for retrieving certain information from a database.
Can anybody help me with retrieving some elements from the following example text: sdfaasdflj
I am using durpal 6. while retrieving data i got the following output: |

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.