From: David Hamilton on
I'm trying to pass a list of identifiers to a sql IN(...) statement, and I'm having trouble with getting the quotes and commas correct.

Here's the relevant part I'm having trouble with:

List=['' '115CCB', '27CBJG', '3AB549', '3I68EE', '49ACF8', '4A88DE', '4AB951', '4AB951', '4B818G', '4G5656', '5F06AJ', '7AA999', '7FB37H', '7I343A', '8B9825', '8CA965', '9A17DE', '9A18EC', '9A3AAA', '9J0135', 'MS999I', 'PP7D7E', 'QS973P' ''];

sql=['SELECT data_date, red_code, spread FROM DataBase where data_date>=''' StartDate ''' AND red_code IN(' List ')'];

As you can see, the list consists of alphanumeric identifiers. The way I have it written above (and in my previous attempts to re-write it), the variable list turns out as:

115CCB27CBJG3AB5493I68EE49ACF84A88DE4AB9514AB9514B818G4G56565F06AJ7AA9997FB37H7I343A8B98258CA9659A17DE9A18EC9A3AAA9J0135MS999IPP7D7EQS973P

Which is clearly not what I'm trying for here.

Although not obvious to me, I'm sure the answer is straightforward. Any help greatly appreciated. Thanks in advance.
From: David Hamilton on
I figured it out:

List='''115CCB'', ''27CBJG'', ''3AB549'', ''3I68EE'', ''49ACF8'', ''4A88DE'', ''4AB951'', ''4AB951'', ''4B818G'', ''4G5656'', ''5F06AJ'', ''7AA999'', ''7FB37H'', ''7I343A'', ''8B9825'', ''8CA965'', ''9A17DE'', ''9A18EC'', ''9A3AAA'', ''9J0135'', ''MS999I'', ''PP7D7E'', ''QS973P''';

sql=['SELECT data_date, red_code, edf1 FROM FIRM.FIRM_CDSIEDF_HIST where data_date>=''' StartDate ''' AND red_code IN(' List ')'];

Thanks anyway.


"David Hamilton" <d.hamilton(a)moodys.com> wrote in message <i0db7j$jkn$1(a)fred.mathworks.com>...
> I'm trying to pass a list of identifiers to a sql IN(...) statement, and I'm having trouble with getting the quotes and commas correct.
>
> Here's the relevant part I'm having trouble with:
>
> List=['' '115CCB', '27CBJG', '3AB549', '3I68EE', '49ACF8', '4A88DE', '4AB951', '4AB951', '4B818G', '4G5656', '5F06AJ', '7AA999', '7FB37H', '7I343A', '8B9825', '8CA965', '9A17DE', '9A18EC', '9A3AAA', '9J0135', 'MS999I', 'PP7D7E', 'QS973P' ''];
>
> sql=['SELECT data_date, red_code, spread FROM DataBase where data_date>=''' StartDate ''' AND red_code IN(' List ')'];
>
> As you can see, the list consists of alphanumeric identifiers. The way I have it written above (and in my previous attempts to re-write it), the variable list turns out as:
>
> 115CCB27CBJG3AB5493I68EE49ACF84A88DE4AB9514AB9514B818G4G56565F06AJ7AA9997FB37H7I343A8B98258CA9659A17DE9A18EC9A3AAA9J0135MS999IPP7D7EQS973P
>
> Which is clearly not what I'm trying for here.
>
> Although not obvious to me, I'm sure the answer is straightforward. Any help greatly appreciated. Thanks in advance.