Skip to content

How to specify the parameter type? #677

Answered by lovasoa
BlueHtml asked this question in Q&A
Discussion options

You must be logged in to vote

Hi !
HTTP URL parameters do not have a type. When you load /order.sql?id=1000, there is no way to know whether the URL parameter id is intended to be a number, or a string that just happens to only contains digits in this case. So SQLPage handles all parameters as strings by default. However, it's easy to convert the parameter to an integer in SQL when you need it. Just replace your SQL query with

select *
from Order
where Id = CAST($id AS INTEGER)

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@BlueHtml
Comment options

@lovasoa
Comment options

Answer selected by lovasoa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants