<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    jojo's blog--快樂憂傷都與你同在
    為夢想而來,為自由而生。 性情若水,風起水興,風息水止,故時而激蕩,時又清平……
    posts - 11,  comments - 30,  trackbacks - 0
    [mdrop@authbackup5 jojo]$ cat insert_sql_statement.sql

    #!/usr/bin/perl -w

    #
    # Created by: JoJo
    # Created Date: 28 July 2009
    # Desc: To create the sql statement for Sanriotown Digital
    #

    use DateTime;
    use DBI;


    #open log file for writing, append purpose
    open(MYLOGFILE, ">> mylog");


    ######### Step 1: Create DB Connection  ################################
    #definition of variables
    $db="UserDB";
    $host="localhost";
    $socket="/var/lib/auth5-1.us4/mysql1/mysql.sock";
    $user="root";
    $password="pwd";


    #connect to MySQL database
    my $dbh   = DBI->connect ("DBI:mysql::mysql_socket=$socket;database=$db:host=$host",$user,$password)
                             or die "Can't connect to database: $DBI::errstr"n";



    ######### Step 2: Get Active User ################################

    # Get date
    my $sdt = DateTime->now;
    # Get active user ( from userdb, usertype != 8)
    print MYLOGFILE "Get all active users from cobranddb.sanriotown_com_userdb tables at  $sdt."n";
    #!`echo 'select username from cobranddb.sanriotown_com_userdb where usertype  &8 <> 8 '|mysql -uroot -ppwd --socket=/var/lib/auth5-1.us4/mysql/mysql.sock --skip-column-names >  activeuser.txt` || die print "Cannot connect to cobranddb database."n";
    # Get date
    my $edt = DateTime->now;
    print MYLOGFILE "Finish grep all active users from cobranddb.sanriotown_com_userdb tables at  $edt."n";




    ######### Step 3: Get Active UserID and Field Value, then Create Insert Statement File#############

    # Open active user file for reading
    open (USERFILE, 'activeuser.txt');
    # Get date
    my $s1dt = DateTime->now;
    # Get active userid and its field value for "country" filedname whose cobrand is "sanriotown.com"
    print MYLOGFILE "Get active userid and its field value for 'country' filedname whose cobrand is 'sanriotown.com' from UserDB.UserProfileTbl and UserDB.UserTbl tables at  $s1dt."n";
    while (<USERFILE>) {
      chomp;
      #prepare the query
      my $sql = "select  u.userid, p.fieldvalue from UserDB.UserProfileTbl p, UserDB.UserTbl u where u.cobrand='sanriotown.com' and u.username='$_' and u.userid=p.userid and p.fieldname='country' ";
      my $sth = $dbh->prepare( $sql);
      #execute the query
      $sth->execute( );

      ## Retrieve the results of a row of data and print
      my ( $userid,$fieldvalue);
      $sth->bind_columns ( undef,"$userid,"$fieldvalue );
      while ( $sth->fetch( ) )  {      
          #print MYLOGFILE  "Userid is $userid and the fieldvalue is $fieldvalue"n";
          `echo "insert UserDB.UserProfileTbl values($userid,'orignal_country', '$fieldvalue');" >> insert_sql_statement.sql`;
      }

      $sth->finish( );
    }
    # Get date
    my $e1dt = DateTime->now;
    print MYLOGFILE "Finish grep active userid and its field value for 'country' filedname whose cobrand is 'sanriotown.com' from UserDB.UserProfileTbl and UserDB.UserTbl tables at  $e1dt."n";


    ######### Step 4: Close All File and DB Connection#############

    # Close all opened file
    close (USERFILE);
    close (MYLOGFILE);
    $dbh->disconnect( );
    exit;

    posted on 2009-07-29 10:13 Blog of JoJo 閱讀(272) 評論(0)  編輯  收藏 所屬分類: 每日一記 、My Script

    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    常用鏈接

    留言簿(6)

    隨筆檔案

    文章分類

    文章檔案

    新聞分類

    新聞檔案

    相冊

    收藏夾

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲高清有码中文字| 亚洲熟妇无码爱v在线观看| 亚洲精品无码久久久久久| free哆啪啪免费永久| 亚洲精品国产成人| 嫖丰满老熟妇AAAA片免费看| 亚洲成A∨人片在线观看无码| 久九九精品免费视频| 亚洲人成欧美中文字幕| 日产乱码一卡二卡三免费| 噜噜综合亚洲AV中文无码| 免费国产a国产片高清网站| 精品在线免费视频| 国产成人高清亚洲| 黄色片免费在线观看| 亚洲视频在线免费看| 成年女人午夜毛片免费视频| 婷婷国产偷v国产偷v亚洲| 亚洲中文字幕无码爆乳av中文| 精品无码国产污污污免费网站国产| 亚洲精品乱码久久久久久自慰| 成人一区二区免费视频| 日韩亚洲AV无码一区二区不卡| A在线观看免费网站大全| 亚洲日韩看片无码电影| 亚洲精品无码成人片在线观看| 免费日本一区二区| 99999久久久久久亚洲| 国产成人免费福利网站| 两个人www免费高清视频| 亚洲春色另类小说| 免费无遮挡无码永久在线观看视频| 51午夜精品免费视频| 亚洲婷婷综合色高清在线| 欧洲美熟女乱又伦免费视频| 精品无码一级毛片免费视频观看 | 国产美女无遮挡免费视频| 美女巨胸喷奶水视频www免费| 亚洲欧洲日产专区| 亚洲国产综合久久天堂| 99视频有精品视频免费观看|