Uploaded image for project: 'Teiid'
  1. Teiid
  2. TEIID-5403

Support the use of variables in client SQL query

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Not a Bug
    • Icon: Major Major
    • None
    • None
    • None
    • None

      In Microsoft SQL Server, when writing SQL query, I can directly declare and set local variables, and then use it as much as I like in the rest of SQL query.

      Example:

      DECLARE @PARAM1 VARCHAR(100);
      SET @PARAM1 = ?;
      
      SELECT
      	<SOME COLUMNS>
      FROM TABLEA LEFT OUTER JOIN (
      	SELECT
      		<SOME COLUMNS>
      	FROM TABLEB
      	WHERE COLUMN1 = @PARAM1
      ) T1 ON T1.COLUMN2 = TABLEA.COLUMN3
      WHERE TABLEA.COLUMN4 = @PARAM1
      UNION ALL
      SELECT
      	<SOME COLUMNS>
      FROM TABLEC
      WHERE TABLEC.COLUMN5 = @PARAM1;
      

      In above example, "@PARAM1" is the local variable that been used multiple times in the query.

      The benefits:
      1. In programming, I only need to set the parameter for one time. For example, when using Java PreparedStatement's setString(int parameterIndex, String x) function, I only need to write "statement.setString(1, param1);" instead of writing "statement.setString(1, param1); statement.setString(2, param1); statement.setString(3, param1); ....." to set the same value.
      2. I no need to create a procedure.

      However, in Teiid, I cannot find anyway to achieve this.

      In Teiid, please implement the support of local variables in client SQL query.

            rhn-engineering-shawkins Steven Hawkins
            cshong SHI HONG CHIN (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: