Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

use sqlldr with perl

by gary16 (Novice)
on Jan 28, 2015 at 06:41 UTC ( [id://1114707]=perlquestion: print w/replies, xml ) Need Help??

gary16 has asked for the wisdom of the Perl Monks concerning the following question:

hi,everybody I m from China.And I now have a strange problem.This day I have imported the oracle data with sqlldr. AND I used the system() to call the sqlldr.The data text is encoded by GB2312;The title of the data text also is .When I run the perl script,The perl create a new data text encoded by utf8 and replace the old one.Here is my code.Have anybody figured out what is happened??

#!/usr/bin/perl -w use strict; use Net::FTP; use Date::Calc qw(:all); use Encode qw(:all); $filename="测试文本"; if($filename){ system(" sqlldr test1/123456 data=$filename control=importwz.ctl"); + }

Replies are listed 'Best First'.
Re: use sqlldr with perl
by CountZero (Bishop) on Jan 28, 2015 at 07:29 UTC
    Since all the work is done by sqlldr, Perl has absolutely nothing to do with this problem.

    Please check your control file and see if it contains perhaps a "CHARACTERSET UTF8" line.

    Also, both the control file CHARACTERSET definition, the import-file data and the database itself must all have the same (or at least compatible) characterset definitions. If one of them is out-of-sync then you will indeed get strange results.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics
      This times because I need to pretreatment the data text,use system() to call the sqlldr.I have imported the data with sqlldr in microsoft's cmd several times successfully.So I Dont't think the mistake are from the sqlldr.
        Unless I am really mistaken, sqlldr will import external data into an Oracle database. The Perl system command will just start sqlldr for you and then sqlldr takes over. The data doesn't pass through your perl-script at all.

        CountZero

        A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

        My blog: Imperial Deltronics
        What do you mean with "pre-treatment" of the data text? The perl part of your program does not do anything with the data-file.

        CountZero

        A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

        My blog: Imperial Deltronics
Re: use sqlldr with perl
by Utilitarian (Vicar) on Jan 28, 2015 at 11:23 UTC
    sqlldr uses the NLS_LANG environment variable to define language_location.charset Try setting it to "SIMPLIFIED CHINESE_CHINA.ZHS16GBK"

    print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."
Re: use sqlldr with perl
by Anonymous Monk on Jan 28, 2015 at 07:51 UTC
    What operating system are you using? You might need systemW from Win32::Unicode
      really?? MY os is win7 and windows server 2008

        really?? MY os is win7 and windows server 2008

        Yes really

Re: use sqlldr with perl
by soonix (Canon) on Jan 28, 2015 at 10:22 UTC
    possibly has nothing to do with your problem, but this
    if($filename){
    only checks for "not-emptyness" of the filename.
    You probably intended one of the -X functions (probably one or more of -e -r -f -s -T).

    From the rest of the discussion, my guess is that the problem is in fact the encoding of the filename, as our Anonymous brother seems to hint

      only checks for "not-emptyness" of the filename.

      truthiness of the filename :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1114707]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-04-25 13:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found