Solved

INSERT with PerlIsql

Posted on 2001-07-12
2
153 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PERL export multiple query results to a JSON file 1 160
pipe to sed or perl, please help 5 127
PERL variable conundrum 9 89
Move Function in Perl Script 2 65
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 …
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.

911 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

17 Experts available now in Live!

Get 1:1 Help Now