I'm trying to define a list of values (id numbers) and pass them to SQL that's querying Oracle tables.
This code works as long as I only include one id.
named_params = {'ids':'123456548'}
query = """
select PEBEMPL_ECLS_CODE
from PEBEMPL
inner join SPRIDEN on spriden_pidm = pebempl_pidm
where SPRIDEN_CHANGE_IND is null
and SPRIDEN_ID in :ids
"""
df = pd.read_sql(query, connection, params=named_params)
What's the correct syntax for doing the same but passing a list of ids?
This code, for example, doesn't work:
idlist = ['123456548','546465464']
named_params = {'ids':idlist}
query = """
select PEBEMPL_ECLS_CODE
from PEBEMPL
inner join SPRIDEN on spriden_pidm = pebempl_pidm
where SPRIDEN_CHANGE_IND is null
and SPRIDEN_ID in :ids
"""
df = pd.read_sql(query, connection, params=named_params)
Error Returned:
': ORA-01484: arrays can only be bound to PL/SQL statements