Solved

INSERT with PerlIsql

Posted on 2001-07-12
2
154 Views
Last Modified: 2012-06-21
Hi gals and guys,

I got the following error with the script described below :

load_eur_selection.pl DEV9_DS ARBOR_DB arborad arborad 3
Can't find string terminator "EOF;" anywhere before EOF at
        load_eur_selection.pl line 38 (#1)
   
    (F) Perl strings can stretch over multiple lines.  This message means that
    the closing delimiter was omitted.  Because bracketed quotes count nesting
    levels, the following is missing its final parenthesis:
   
        print q(The character '(' starts a side comment.);
   
    If you're getting this error from a here-document, you may have
    included unseen whitespace before or after your closing tag. A good
    programmer's editor will have a way to help you find these characters.
   
Uncaught exception from user code:
        Can't find string terminator "EOF;" anywhere before EOF at load_eur_selection.pl line 38.


Code :

#Retrieve accounts defined with the currency FF
$base->send_query(<<"EOF;");
SELECT account_no, currency_code FROM CMF
WHERE account_no NOT IN (SELECT ncu_account_no FROM EUR_SELECTION)
AND currency_code IN (1, 2)
go
EOF;

$base->get_result(\%result);

foreach $row (@{$result{data}})
{
     if (!exists($accounts{@$row[0]})) { $accounts{@$row[0]} = @$row[1]; }
}

foreach $account_no (sort keys %accounts)
{
     if (($account_no == 2) || ($account_no == 20))
     {
          print "account_no = $account_no, currency = $accounts{$account_no}\n";
          $base->send_query(<<"EOF;");
          INSERT INTO EUR_SELECTION ($account_no, '20011001', 'eur05', 0, NULL, '', 0)
          go
          EOF;
     }
}

It failed with the INSERT query.

Thanks in advance
0
Comment
Question by:Richard Coffre
2 Comments
 
LVL 5

Accepted Solution

by:
amandeep earned 50 total points
ID: 6278684
pyxos,

Ur code should be :

#Retrieve accounts defined with the currency FF
$base->send_query(<<"EOF;");
SELECT account_no, currency_code FROM CMF
WHERE account_no NOT IN (SELECT ncu_account_no FROM EUR_SELECTION)
AND currency_code IN (1, 2)
go
EOF;

$base->get_result(\%result);

foreach $row (@{$result{data}})
{
    if (!exists($accounts{@$row[0]})) { $accounts{@$row[0]} = @$row[1]; }
}

foreach $account_no (sort keys %accounts)
{
    if (($account_no == 2) || ($account_no == 20))
    {
         print "account_no = $account_no, currency = $accounts{$account_no}\n";
         $base->send_query(<<"EOF;");
         INSERT INTO EUR_SELECTION ($account_no, '20011001', 'eur05', 0, NULL, '', 0)
         go
EOF;
    }
}

-------- OR U can also write as ----------------

#Retrieve accounts defined with the currency FF
$query=qq{
SELECT account_no, currency_code FROM CMF
WHERE account_no NOT IN (SELECT ncu_account_no FROM EUR_SELECTION)
AND currency_code IN (1, 2)
go
};

$base->send_query($query);

$base->get_result(\%result);

foreach $row (@{$result{data}})
{
    if (!exists($accounts{@$row[0]})) { $accounts{@$row[0]} = @$row[1]; }
}

foreach $account_no (sort keys %accounts)
{
    if (($account_no == 2) || ($account_no == 20))
    {
         print "account_no = $account_no, currency = $accounts{$account_no}\n";
         $query=qq{
         INSERT INTO EUR_SELECTION ($account_no, '20011001', 'eur05', 0, NULL, '', 0)
         go
         };
         $base->send_query($query);
    }
}


0
 
LVL 1

Author Comment

by:Richard Coffre
ID: 6279792
Thanks a lot.
Your second solution is perfect.
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question