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.  Mutiple Select Queries

    Employee
    Posted 02-23-2017 12:38

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

    Originally posted by: glaxmikanth1

    Hello,

    I am trying to pass multiple select statements to a DBExecute node, how can I execute each of the selects and get their corresponding output.

    sqlSelect(1,str1) where "str1" is the input I am passing, let's assume str1 would have 5 rows with 5 different select statements.

    PS: I am new to this forum, don't mind if I am posting my query at the wrong place.

    Thanks.


  • 2.  RE: Mutiple Select Queries

    Employee
    Posted 02-23-2017 13:09

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

    Originally posted by: stonysmith

    Originally posted by: glaxmikanth1
    					

    I am trying to pass multiple select statements to a DBExecute node, how can I execute each of the selects and get their corresponding output.

    sqlSelect(1,str1) where "str1" is the input I am passing, let's assume str1 would have 5 rows with 5 different select statements.

    Are you changing COLUMNS between the select statements, or are you merely changing the WHERE conditions?

    Most databases will not allow you to issue multiple SELECT statements in a single session. You can do a variety of statements such as Insert, Update, Delete, but you can't do multiple Selects in the same query.

    Oracle will return an error "Query Changed" if you try to do this.
    Think of this situation:
    q1="select A as C from myTable"
    q2="select B as C from myTable"

    In this case, if A and B are different data types (A=string B=number) then the database doesn't know what you want for an output. You can't mix string and number data types in the same output column. And, even if the columns A and B are the same data type, Oracle (and other databases) won't accept it.

    Now, what you can do is this:

    q1="select A as C from myTable union all select B as C from myTable"

    You can use an AGG node to merge the records together, adding " union all " between each record.

    This is treated as a single query and the database will return the expected results.

    ==============
    If you are merely changing the value that needs to be searched for in the WHERE clause, then use the method described here:
    http://community.lavastorm.com/threa...amic-SQL-query