Solved

INSERT with PerlIsql

Posted on 2001-07-12
2
152 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
Comment Utility
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
Comment Utility
Thanks a lot.
Your second solution is perfect.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now