Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Query Parameter Integer

Deleted user August 24, 2015

Hello,

 

I am trying out Confluence and PocketQuery.

I created a small Query with a parameter.

 

SELECT * FROM retail where customerid = 324234

customerid column is int4.

 

When I add a PocketSQL to a site and define the paramter I get the following StackTrace

 

org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT * FROM retail WHERE customerid= ?]; nested exception is org.postgresql.util.PSQLException: ERROR: operator does not exist: integer = character varying Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts

How do I tell the macro that my input is an integer?

 

 

Thank you for your help

2 answers

1 accepted

2 votes
Answer accepted
Thiago Zandona
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 24, 2015

Hi Thomas, 

Actually this is a SQL function. When you insert directly a number as parameter it will automatically convert to text. Try to use as follows:

 

SELECT * FROM retail where customerid = '324234'


More information can be found at the page below:

http://stackoverflow.com/questions/24751372/no-function-matches-the-given-name-and-argument-types

Hope this helps.

Cheers

1 vote
Felix Grund (Scandio)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 24, 2015

Hi Thomas,

As Thiago already wrote correctly, this is how the underlying Spring JDBC libraries handle "Named Parameter Statements". By default, the parameters in these statements will be replaced as strings before the statement is executed. In the current public version of PocketQuery, I believe there is no workaround for this. But: we are just a few steps away from releasing PocketQuery 2.0 which has a feature for exactly this purpose. If you're interested, I will send you a release-candidate version and tell you how the feature works smile. In that case, please write a short mail to atlassian[at]scandio.de

Regards, Felix (Scandio)

Deleted user August 24, 2015

Hello, thank you for your explanation. I couldn't answer yesterday. As per PostgreSQL documentation A numeric constant that contains neither a decimal point nor an exponent is initially presumed to be type integer. Shouldn't be this the default for Pocket also?

Felix Grund (Scandio)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 24, 2015

We're kind of dependent on how the Spring JDBC libraries handle this. It's kind of more low-level than the implementation of PocketQuery. As I said, I can provide you a release candidate version via mail that has a feature by which you can specify a type for each parameter in your statement.

Deleted user August 24, 2015

Thanks again, I will wait for the release as I still have to explore a lot in Confluence.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events