dbo.informe_valores

Description

Properties

Name Value
File Collation
File Group
Filestream File Group
Is Partitioned

False

Partitioned Column
Partition Scheme
File Groups
Filestream Partition Scheme
Filestream File Groups
Heap

True

Full Text Catalog
Full Text
Compression NONE
Row Count (~) 0
Created 10/1/2007 3:29:34 PM
Last Modified 11/30/2024 5:55:14 PM

Columns

8
Key Name Data Type Length Precision Scale Not Null Identity Rule Default Computed Persisted Description
nombre_variable varchar 200 0 0

True

False

False

valor varchar 512 0 0

False

False

False

instancia tinyint 1 3 0

True

False

False

cargado_por int 4 10 0

False

False

False

cargado_fecha datetime 8 23 3

False

False

False

modificado_por int 4 10 0

False

False

False

modificado_fecha datetime 8 23 3

False

False

False

informe int 4 10 0

True

False

False

Indexes

1
Key Name Columns Unique Type Description
PK__informe_valores__20C1E124 informe, nombre_variable, instancia

True

Triggers

3
Name ANSI Nulls ON Quoted Identifier ON On Not For Replication Description
tD_informe_valores

True

True

AFTER DELETE

False

tI_informe_valores

True

True

AFTER INSERT

False

tU_informe_valores

True

True

AFTER UPDATE

False

Foreign Keys

1
Name Columns Description
FK__informe_v__infor__79A62B13 informe

SQL Script

Copy
CREATE TABLE dbo.informe_valores (
  nombre_variable varchar(200) NOT NULL,
  valor varchar(512) NULL,
  instancia tinyint NOT NULL,
  cargado_por int NULL,
  cargado_fecha datetime NULL,
  modificado_por int NULL,
  modificado_fecha datetime NULL,
  informe int NOT NULL,
  PRIMARY KEY NONCLUSTERED (informe, nombre_variable, instancia) WITH (FILLFACTOR = 90)
)
ON [PRIMARY]
GO

SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER trigger dbo.tD_informe_valores on dbo.informe_valores for DELETE as
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* DELETE trigger on informe_valores */
begin
  declare  @errno   int,
           @errmsg  varchar(255)
    /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
    /* informe_valores R/268 informe_valores_historico ON PARENT DELETE RESTRICT */
    /* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="informe_valores"
        CHILD_OWNER="", CHILD_TABLE="informe_valores_historico"
        P2C_VERB_PHRASE="R/268", C2P_VERB_PHRASE="", 
        FK_CONSTRAINT="R_268", FK_COLUMNS="informe""nombre_variable""instancia" */

    if exists (
      select * from deleted,informe_valores_historico
      where
        /*  %JoinFKPK(informe_valores_historico,deleted," = "," and") */
        informe_valores_historico.informe = deleted.informe and
        informe_valores_historico.nombre_variable = deleted.nombre_variable and
        informe_valores_historico.instancia = deleted.instancia
    )
    begin
      select @errno  = 30001,
             @errmsg = 'Cannot DELETE informe_valores because informe_valores_historico exists.'
      goto error
    end


    /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
    return
error:
    raiserror (@errmsg,@errno,1) 
    rollback transaction
end

GO
CREATE OR ALTER trigger dbo.tI_informe_valores on dbo.informe_valores for INSERT as
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* INSERT trigger on informe_valores */
begin
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount
  /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
  /* informes R/267 informe_valores ON CHILD INSERT RESTRICT */
  /* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="informes"
      CHILD_OWNER="", CHILD_TABLE="informe_valores"
      P2C_VERB_PHRASE="R/267", C2P_VERB_PHRASE="", 
      FK_CONSTRAINT="R_267", FK_COLUMNS="informe" */

  if
    /* %ChildFK(" or",update) */
    update(informe)
  begin
    select @nullcnt = 0
    select @validcnt = count(*)
      from inserted,informes
        where
          /* %JoinFKPK(inserted,informes) */
          inserted.informe = informes.informe
    /* %NotnullFK(inserted," is null","select @nullcnt = count(*) from inserted where"," and") */
    
    if @validcnt + @nullcnt != @numrows
    begin
      select @errno  = 30002,
             @errmsg = 'Cannot INSERT informe_valores because informes does not exist.'
      goto error
    end
  end


  /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
  return
error:
    raiserror (@errmsg,@errno,1) 
    rollback transaction
end

GO
CREATE OR ALTER trigger dbo.tU_informe_valores on dbo.informe_valores for UPDATE as
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* UPDATE trigger on informe_valores */
begin
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @insinforme int, 
           @insnombre_variable varchar(200), 
           @insinstancia tinyint,
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount
  /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
  /* informe_valores R/268 informe_valores_historico ON PARENT UPDATE RESTRICT */
  /* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="informe_valores"
      CHILD_OWNER="", CHILD_TABLE="informe_valores_historico"
      P2C_VERB_PHRASE="R/268", C2P_VERB_PHRASE="", 
      FK_CONSTRAINT="R_268", FK_COLUMNS="informe""nombre_variable""instancia" */

  if
    /* %ParentPK(" or",update) */
    update(informe) or
    update(nombre_variable) or
    update(instancia)
  begin
    if exists (
      select * from deleted,informe_valores_historico
      where
        /*  %JoinFKPK(informe_valores_historico,deleted," = "," and") */
        informe_valores_historico.informe = deleted.informe and
        informe_valores_historico.nombre_variable = deleted.nombre_variable and
        informe_valores_historico.instancia = deleted.instancia
    )
    begin
      select @errno  = 30005,
             @errmsg = 'Cannot UPDATE informe_valores because informe_valores_historico exists.'
      goto error
    end
  end

  /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
  /* informes R/267 informe_valores ON CHILD UPDATE RESTRICT */
  /* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="informes"
      CHILD_OWNER="", CHILD_TABLE="informe_valores"
      P2C_VERB_PHRASE="R/267", C2P_VERB_PHRASE="", 
      FK_CONSTRAINT="R_267", FK_COLUMNS="informe" */

  if
    /* %ChildFK(" or",update) */
    update(informe)
  begin
    select @nullcnt = 0
    select @validcnt = count(*)
      from inserted,informes
        where
          /* %JoinFKPK(inserted,informes) */
          inserted.informe = informes.informe
    /* %NotnullFK(inserted," is null","select @nullcnt = count(*) from inserted where"," and") */
    
    if @validcnt + @nullcnt != @numrows
    begin
      select @errno  = 30007,
             @errmsg = 'Cannot UPDATE informe_valores because informes does not exist.'
      goto error
    end
  end


  /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
  return
error:
    raiserror (@errmsg,@errno,1) 
    rollback transaction
end

GO

ALTER TABLE dbo.informe_valores WITH NOCHECK
  ADD FOREIGN KEY (informe) REFERENCES dbo.informes (informe)
GO