Home > OS >  How to pass multiple variables from a string into a query [duplicate]
How to pass multiple variables from a string into a query [duplicate]

Time:09-30

How do you pass multiple variables in the form of a string?

I had this issue, when trying to make a query (And I couldn't use a procedure)

SELECT 
  * 
FROM 
  xxxx
WHERE 
  id IN ( 913456,412548,1225 )

CodePudding user response:

Solution:

in_ids := '1;457;988;';

SELECT Substr(in_ids, a.pos_from, a.length) ids
FROM   (SELECT Lag(c.poscomma, 1, 0) over (ORDER BY c.poscomma)
                 1                   pos_from,
               c.poscomma            pos_to,
               Abs(Lag(c.poscomma, 1, 0) over (ORDER BY c.poscomma)
                     1 - c.poscomma) length
        FROM   (SELECT Substr(in_ids, LEVEL, 1) AS CHARACTER,
                       LEVEL                  AS poscomma
                FROM   dual
                CONNECT BY LEVEL <= Length(in_ids)) c
        WHERE  c.CHARACTER = ';') a;

CodePudding user response:

SELECT * FROM Customers
WHERE Country IN ('Germany', 'France', 'UK');

Checkout this

  • Related