Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Temporal
- // Agrega id_tbl como serial y primary key las tablas cnx_datos_estad_#
- synchronized( this )
- {
- String sTblDatos = "cnx_datos_estad_".concat( String.valueOf( intIdInst ) );
- String sSeq = sTblDatos.concat( "_id_tbl_seq" );
- StringBuilder sBufSQL = new StringBuilder();
- boolean bAgregar = true;
- sBufSQL.append( "SELECT id_tbl FROM " ).append( sTblDatos );
- try
- {
- ResultSet result = stmtCnx.executeQuery( sBufSQL.toString() );
- bAgregar = false;
- }
- catch( Exception ex )
- {
- bAgregar = true;
- }
- if( bAgregar == true )
- {
- // Agrega la columna
- sBufSQL = new StringBuilder();
- try
- {
- sBufSQL.append( "CREATE SEQUENCE " ).append( sSeq );
- stmtCnx.executeUpdate( sBufSQL.toString() );
- }
- catch( Exception ex )
- {
- }
- try
- {
- sBufSQL = new StringBuilder();
- sBufSQL.append( "ALTER TABLE " ).append( sTblDatos );
- sBufSQL.append( " ADD COLUMN id_tbl INTEGER DEFAULT nextval('" );
- sBufSQL.append( sSeq );
- sBufSQL.append( "')" );
- stmtCnx.executeUpdate( sBufSQL.toString() );
- }
- catch( Exception ex )
- {
- }
- }
- }
Add Comment
Please, Sign In to add comment