sql - timestamp() do not take function parameter as input? -


I am using sql in postgresql

  cast (timestamp ($ 1) / Code>  

This error returns the parameter around

When I give a straight line, SQL works:

 < Code> cast (call as timestamp (1))  

does not take timestamp function parameter?

This is a part of the name type and should not be parameterized in plain SQL Could. This is not a function, even though the syntax looks similar to the bracket.

You will need dynamic SQL for this. The statement in the form of a string in the PL / PGSLL function is created and runs it with the EXECUTE . Something like this:

EXECUTE 'SELECT col :: timestamp (' $ 1 || ') in' my_var;

$ 1 type integer is happening. There is no string type like text , or you have the possible SQL injection hole.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -