Posts

sql - Rename a table used as reference in a another table -

sql - Rename a table used as reference in a another table - i have created 2 postgresql tables tables (the code originates django app): create table "app_book" ( "id" serial not null primary key, "title" varchar(256) ); create table "app_author" ( "book_ptr_id" integer not null primary key references "app_book" ("id") deferrable deferred, "name" varchar(128) not null ); i want rename table app_book app_item . next line sufficient, or have update references in app_author ? if so, how can that? alter table app_book rename app_item; looking @ this page, guess not. page not explain how update reference. see http://sqlfiddle.com/#!15/0dd1f/5 the problem described in link refers problems when using slony. if can live fact sequence "behind" id column not reflect name alter fine. if bothers you, need rename sequence well. note get_serial_sequence() still wo...

How to convert day/mon/year hour:min:sec to format to be inserted into mysql php -

How to convert day/mon/year hour:min:sec to format to be inserted into mysql php - i getting 5/10/2014 18:12:22 datetime in $_post['start'] , 19/10/2014 18:12:22 datetime in $_post['end'] . on using code if(isset($_post['start'])) if(!empty($_post['start'])) $start1=mysqli_real_escape_string($con,$_post['start']); if(isset($_post['end'])) if(!empty($_post['end'])) $end1=mysqli_real_escape_string($con,$_post['end']); echo $start = date('y-m-d h:i:s', strtotime($start1)); //returns 2014-05-10 18:12:22 echo '<br>'; echo $end = date('y-m-d h:i:s', strtotime($end1)); //returns 1970-01-01 00:00:00 die(); i don't no i'm doing wrongly please help help appreciated. if pertinent column datetime/timestamp in table, alternatively utilize datetime class reformat dates before insertion: simple example: $start1 = '5/10/2014 18:12:22'; // $_post['start']...

Storage manager function to implement read operations on a file -

Storage manager function to implement read operations on a file - how adapt programme perform next operations: 1.to read first block of file 2.to read current block of file 3.to read previous block of file 4.to read next block of file 5.to read lastly block of file next code written me read info file using file pointer , want implement above operations void main() { file *fptr; char filename[15]; char ch; printf("enter filename opened \n"); scanf("%s", filename); /* open file reading */ fptr = fopen(filename, "r"); if (fptr == null) { printf("cannot open file \n"); exit(0); } ch = fgetc(fptr); while (ch != eof) { printf ("%c", ch); ch = fgetc(fptr); } fclose(fptr); } any suggestions helpful. file storage fread filehandle fseek

java - Why is the sql connection getting created in new thread? -

java - Why is the sql connection getting created in new thread? - i have couple of question on class below. public class test { public void run() throws sqlexception { connection conn = getconnection(); dslcontext create = dsl.using(conn, sqldialect.mysql); // query books author named 'selena' result<record2<long, string>> result = create .select(book.id, book.title).from(book).join(book_author_rel) .on(book_author_rel.bookid.equal(book.id)).join(author) .on(book_author_rel.authorid.equal(author.id)) .where(author.name.equal("selena")) .orderby(book.title.asc(), book.id.asc()).fetch(); result.foreach((r) -> { system.out.println(string.format("%s (id: %s)", r.getvalue(book.title), r.getvalue(book.id))); }); conn.close(); system.exit(0); } public sta...

c# - I'm checking if my application is already running or not and it's saying running even if i stopped the application why? -

c# - I'm checking if my application is already running or not and it's saying running even if i stopped the application why? - inside program.cs did: using system; using system.collections.generic; using system.linq; using system.windows.forms; using system.diagnostics; using dannygeneral; namespace mws { static class programme { /// <summary> /// main entry point application. /// </summary> [stathread] static void main() { seek { if (isapplicationalreadyrunning() == true) { messagebox.show("the application running"); } else { application.enablevisualstyles(); application.setcompatibletextrenderingdefault(false); application.run(new form1()); } } grab (exception err) ...

javascript - JSONP angular js displaying multiple objects -

javascript - JSONP angular js displaying multiple objects - similar question posted i'm having issue grabbing weather week , allocating different rows. format want is: mon tues wed thurs sydney 25 21 21 22 melbourne 26 18 21 24 etc unfortunatly grabbing first part of array , coppying areas. here js : app.controller('forecastctrl',function($scope, $http){ $scope.weatherdatasydney = null; $scope.weatherdatabrisbane = null; $scope.weatherdataperth = null; $scope.weatherdatamelbourne = null; $scope.weatherdataadelaide = null; $scope.weatherdatadarwin = null; $http.jsonp('http://api.wunderground.com/api/5ad0204df4bdbeff/forecast/q/australia/sydney.json?callback=json_callback').success(function(data){ $scope.weatherdatasydney=data; }); $http.jsonp('http://api.wunderground.com/api/5ad0204df4bdbeff/forecast/q/australia/...

java - Read from array and calculate average -

java - Read from array and calculate average - i trying write code reads row of characters array, assign characters integer , average integers of row, every row in array. here have far : scanner in = new scanner(new file("grades.txt")); while(in.hasnextline()) { int gp = 0; double gpa = 0; string line = in.nextline(); if(line.length() == 0) { continue; } line = line.substring(line.length()-15, line.length()); string[] letters = line.split(" "); (int = 0; < letters.length; i++) { if (letters[i].equals("h")) { gp += 7; } else if (letters[i].equals("d")) { gp += 6; } else if (letters[i].equals("c")) { gp += 5; } else if (letters[i].equals("p")) { gp += 4; } else if (letters[i].equals("f")) { gp += 0; } } gpa = gp / letters.length; system.out.println(gpa); } here array ...