prepare command not working with DBI using perl

95 views Asked by At
$sth = $dbh->prepare("select  CODE_ID,NAME_CODE,SUM(INR_COL + OUT_COL) AS "TOTAL SUM" from nwsa where CODE_ID='L01A' OR CODE_ID='L01B'OR CODE_ID='L01C' OR CODE_ID='L01D' OR CODE_ID='L01DA' OR CODE_ID='L01E' OR CODE_ID='L02A' OR CODE_ID='L02B' OR CODE_ID='L02C' OR CODE_ID='L02E' OR CODE_ID='L02N'  group by  CODE_ID,NAME_CODE  ");  # your query here
$sth->execute( );
$out = DBIx::Dump->new('format' => csv,   # excel or csv
                       'output' => $FILENAME, # file to save as
                       'sth'    => $sth);

error coming as bareword found near "TOTAL SUM" .. what is the error..?

1

There are 1 answers

1
Toto On BEST ANSWER

Escape the quotes:

$sth = $dbh->prepare("select  CODE_ID,NAME_CODE,SUM(INR_COL + OUT_COL) AS \"TOTAL SUM\" ........

or use single quotes:

$sth = $dbh->prepare('select  CODE_ID,NAME_CODE,SUM(INR_COL + OUT_COL) AS "TOTAL SUM" ........');