Guest User

Untitled

a guest
Oct 23rd, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. // Temporal
  2. // Agrega id_tbl como serial y primary key las tablas cnx_datos_estad_#
  3.  
  4. synchronized( this )
  5. {
  6. String sTblDatos = "cnx_datos_estad_".concat( String.valueOf( intIdInst ) );
  7. String sSeq = sTblDatos.concat( "_id_tbl_seq" );
  8. StringBuilder sBufSQL = new StringBuilder();
  9.  
  10. boolean bAgregar = true;
  11. sBufSQL.append( "SELECT id_tbl FROM " ).append( sTblDatos );
  12.  
  13. try
  14. {
  15. ResultSet result = stmtCnx.executeQuery( sBufSQL.toString() );
  16. bAgregar = false;
  17. }
  18. catch( Exception ex )
  19. {
  20. bAgregar = true;
  21. }
  22. if( bAgregar == true )
  23. {
  24. // Agrega la columna
  25. sBufSQL = new StringBuilder();
  26. try
  27. {
  28. sBufSQL.append( "CREATE SEQUENCE " ).append( sSeq );
  29. stmtCnx.executeUpdate( sBufSQL.toString() );
  30. }
  31. catch( Exception ex )
  32. {
  33. }
  34.  
  35. try
  36. {
  37. sBufSQL = new StringBuilder();
  38.  
  39. sBufSQL.append( "ALTER TABLE " ).append( sTblDatos );
  40. sBufSQL.append( " ADD COLUMN id_tbl INTEGER DEFAULT nextval('" );
  41. sBufSQL.append( sSeq );
  42. sBufSQL.append( "')" );
  43.  
  44. stmtCnx.executeUpdate( sBufSQL.toString() );
  45. }
  46. catch( Exception ex )
  47. {
  48. }
  49. }
  50. }
Add Comment
Please, Sign In to add comment