Monday, March 14, 2011

Oracle PHP returning clause statement

If you just want to retrieve an auto-increment field like an integer, you don't have to use the oci_new_descriptor function:

   $dbh = ociplogon("username","pw","sid");

   $query = "INSERT INTO employees (name) VALUES ('Jones') RETURNING employee_no INTO :employee_no";
   $stmt = oci_parse($dbh, $query);

   // oci_new_descriptor not necessary...

   // Bind the variable to the parsed statement.
   // I used '8' as the minimum length - otherwise it was setting the default length to '1', so when an employee_no like 18366 was returned, the variable would be set to '1' (the first digit), so make sure you set a length.
   oci_bind_by_name($stmt, ":employee_no", $employee_no, 8);
   oci_execute($stmt, OCI_DEFAULT);

   // Commit the change
   oci_commit($dbh);

   // Free resources associated with the statement
   oci_free_statement($stmt);

  print "new employee no is: $employee_no";

Centos 7 reset root/ any user lost password / lockout due to cant remember password

1. Need to be in front of the terminal. (Physically if not vm). 2. Reboot the server 3. Press 'e' in the GRUB2 boot screen. 3. bunch...