Passing column name as parameter to the prepared statemnt

Analytics

Passing column name as parameter to the prepared statemnt

[font=Tahoma]Hi ,

I am trying to pass the format like 'DDMMYYYY' as parameter to the prepared statement from Java .

SELECT (created_date(TIMESTAMP, FORMAT ?) (VARCHAR(10))) from tableA

I get the following error .

com.teradata.jdbc.jdbc_4.util.JDBCException: [Teradata Database] [TeraJDBC 13.00.00.07] [Error 3707] [SQLState 42000] Syntax error, expected something like a string or a Unicode character literal between the 'FORMAT' keyword and '?'.

Any Help on is appreciated .

Regards.[font=Arial][/font][/font]
2 REPLIES

Re: Passing column name as parameter to the prepared statemnt

Construct your SQL statement from inside the SP and use EXEC command to run it. Suppose you have parameters @ColumnName, @TableName and @number, the SP is like this:

_________
N/A

Re: Passing column name as parameter to the prepared statemnt

Hi,

sel cast(cast(current_timestamp(0) as char(10)) as date format 'yyyy/mm/dd');

sel cast(cast(columnname as char(10)) as date format 'yyyy/mm/dd');

Try this it may help you.....

Chandra Paul