in reply to Passing an Array of Attributes to SQL

Why would you assign the result of join to an array (as in @case2 = join(", ", @{$r});. Doesn't join return a scalar. I think you need a comma after "store_number" too.

Replies are listed 'Best First'.
Re^2: Passing an Array of Attributes to SQL
by cocl04 (Sexton) on Oct 07, 2009 at 14:08 UTC

    The perl script works...sql and all in the current format. The case statements are as follows:

    ,max(CASE WHEN week_end_date = '26-SEP-09' THEN rank END) AS DATE_AS_O +F_09_26_2009 ,max(CASE WHEN week_end_date = '19-SEP-09' THEN rank END) AS DATE_AS_O +F_09_19_2009

    They already have a comma in them. Since I am introducing multiple lines, it has to come in with a comma. That part works. I just want to be able to read in more than one part of the array. I want to read the entire array as a string.

      Are you saying fetchrow_arrayref returns:

      [ [',max(CASE WHEN week_end_date = '26-SEP-09' THEN rank END) AS DATE_A +S_OF_09_26_2009'], [',max(CASE WHEN week_end_date = '19-SEP-09' THEN rank END) AS DATE_A +S_OF_09_19_2009'] ]

      or show us what use Data::Dumper;print Dumper($case); outputs.

        Yes. The array reference returns the two case statements. I did

        use Data::Dumper;print Dumper($case);

        and it returns the two case statements.

        I also printed it and it returns the same thing. I am passing a case statement as an attribute / object and when I passed one to the sql statement perl sends it to sqlplus as a normal part of the query. And it works. I just want to be able to send all of them as one string to the query.