<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 閱讀(280) 評論(0)  編輯  收藏 所屬分類: 每日一記My Script

    <2025年7月>
    293012345
    6789101112
    13141516171819
    20212223242526
    272829303112
    3456789

    常用鏈接

    留言簿(6)

    隨筆檔案

    文章分類

    文章檔案

    新聞分類

    新聞檔案

    相冊

    收藏夾

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 手机在线免费视频| 国产情侣久久久久aⅴ免费| 美女视频黄是免费的网址| 久久精品国产精品亚洲艾草网| 国产成人无码精品久久久免费| 亚洲精品无码AV中文字幕电影网站| 亚州**色毛片免费观看| 免费看大美女大黄大色| 亚洲精品无码久久久久久| 特级淫片国产免费高清视频| 亚洲国产成人精品无码区花野真一| 成人在线免费观看| 亚洲第一se情网站| 亚洲爽爽一区二区三区| 韩日电影在线播放免费版| 亚洲国产精品va在线播放| 日韩精品无码一区二区三区免费| 亚洲伊人tv综合网色| 日韩精品无码区免费专区| 亚洲成a人片在线观看天堂无码 | 77777亚洲午夜久久多喷| 久久久久久99av无码免费网站| 中国china体内裑精亚洲日本| 精品国产免费观看久久久| 一级毛片高清免费播放| 久久精品国产亚洲av成人| 免费看污成人午夜网站| 国产精品成人亚洲| 久久精品亚洲日本佐佐木明希| 51视频精品全部免费最新| 亚洲国产精品无码久久98| 中文字幕亚洲不卡在线亚瑟| 99在线免费观看视频| 亚洲人片在线观看天堂无码| 国产亚洲欧洲Aⅴ综合一区| 91麻豆国产免费观看| 亚洲AV日韩AV一区二区三曲| 亚洲欧洲日产国码av系列天堂 | 久久精品免费全国观看国产| 日韩国产欧美亚洲v片| 亚洲av午夜成人片精品网站|