LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  JDBC Execute Node Alter Query Error

    Employee
    Posted 08-12-2014 03:45

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: abhisek

    I want to alter the table for adding column with JDBC execute node.

    				ALTER TABLE statistic ADD COLUMN ? Double Null
    			
    
    I had passed the parameter SqlQueryFieldBinding for the marker.

    I am getting an error

    			
    				Exited with non zero status
    2014-08-12 07:01:56.000; ERROR: error on row 0. com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorEx ception: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''Col1' Double Null' at line 1
    id: 0 chain: 0 group: 0
    cppDetail: context: nodeMain SQLRunner.java@236

    2014-08-12 07:01:56.000; ERROR: Exited with non zero status
    id: 0 chain: 0 group: 0
    cppDetail: context: Salmon::NED::NodeMain::errorMsg() .\NodeMain.cpp@28
    Please help with a solution.
    Thanks,
    AD


  • 2.  RE: JDBC Execute Node Alter Query Error

    Employee
    Posted 08-12-2014 13:37

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: xathras

    syntax is a little off. Should look like this:

    ALTER TABLE contacts ADD email VARCHAR(60); - example


  • 3.  RE: JDBC Execute Node Alter Query Error

    Employee
    Posted 08-12-2014 14:10

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ejones

    You cannot use a bind variable to reference a table or a column in an SQL statement. And I don't believe there are any DDL statements like the one in your example, where you can use bind variables. This is a limitation imposed by JDBC. And I'm thinking that the reasoning behind this is that the table structure in a database will be relatively stable so there would be no need for dynamic column names. (I'm not saying I agree though, I think you should be able to do exactly what I think you are attempting to do. Because there are sometimes where you might want to create generic code that works where the exact column names are not always the same. Or sometimes it could be a time saver to maybe add 40 columns to an existing table quickly using LAE)

    Depending on what you need to do, you might be able to use a parameter for the column name and it might look something like this assuming that the rest of the syntax of the SQL statement is correct.
    ALTER TABLE statistic ADD COLUMN {{^TheColumnName^}} Double Null

    If this guess at an answer doesn't help, please provide more context about what you are doing and we might be able to help more. Maybe explain why this answer isn't working for you if it isn't.


  • 4.  RE: JDBC Execute Node Alter Query Error

    Employee
    Posted 08-13-2014 01:16

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: xathras

    Originally posted by: ejones
    					

    You cannot use a bind variable to reference a table or a column in an SQL statement. And I don't believe there are any DDL statements like the one in your example, where you can use bind variables. This is a limitation imposed by JDBC. And I'm thinking that the reasoning behind this is that the table structure in a database will be relatively stable so there would be no need for dynamic column names. (I'm not saying I agree though, I think you should be able to do exactly what I think you are attempting to do. Because there are sometimes where you might want to create generic code that works where the exact column names are not always the same. Or sometimes it could be a time saver to maybe add 40 columns to an existing table quickly using LAE)

    Depending on what you need to do, you might be able to use a parameter for the column name and it might look something like this assuming that the rest of the syntax of the SQL statement is correct.
    ALTER TABLE statistic ADD COLUMN {{^TheColumnName^}} Double Null

    If this guess at an answer doesn't help, please provide more context about what you are doing and we might be able to help more. Maybe explain why this answer isn't working for you if it isn't.
    The SQL Syntax is wrong too ;-). You'd need to replace with DBExecute I believe to get the achieved result