"Reading DB in the middle of a process to get a new attribute"

adaman
adaman New Altair Community Member
edited November 5 in Community Q&A
Hey together,

i would like to call the DB in the middle of a process to get new informations out of a DB-table. Therefor i would like to send a SQL-query through which i can send an attribute of my example set as a parameter.

Example:
Let a example set  look like this:

ROLE          NAME      TYPE
attribute      id              integer
attribute      number    real

Example of a sql Statement i would like to execute:
          Select c from TABLE where ? BETWEEN 'a' AND 'b';

I would like the Parameter ? be the number of the example set and i would like to store the result in my example set afterward.

Is this possible because i can´t find any Operator. As far as i understand the Execute SQL operator cannot load data from the DB but this is what i need

Greetings and thanks for your help in advance

Answers

  • colo
    colo New Altair Community Member
    Hi adaman,

    if you use the "Extract Macro" operator on the number attribute value, you can use this macro in your query like "... WHERE %{number} BETWEEN...". But in my opinion this query doesn't make much sense, WHERE should be followed by a column name, not by a number.

    If you want to use the response from this query, I would suggest the "Read Database" operator. You will receive a new example set fulfilling the SQL query. If you want to store the result in your example set you have to look for a proper way to combine both sets. Since your intention isn't clear to me, I cannot make any suggestions on this one. You will probably receive multiple lines (since you are using the BETWEEN operator, although your query will certainly result in zero lines) and you can't simply add them to a single example in your existing example set. Perhaps you can give a bit more details on your problem to make things clearer (at least to me).

    Regards
    Matthias