dbo.informe_balances

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

2
Key Name Data Type Length Precision Scale Not Null Identity Rule Default Computed Persisted Description
informe int 4 10 0

True

False

False

balance int 4 10 0

True

False

False

Indexes

1
Key Name Columns Unique Type Description
PK__informe_balances__1ED998B2 informe, balance

True

Triggers

2
Name ANSI Nulls ON Quoted Identifier ON On Not For Replication Description
tI_informe_balances

True

True

AFTER INSERT

False

tU_informe_balances

True

True

AFTER UPDATE

False

Foreign Keys

2
Name Columns Description
FK__informe_b__balan__619B8048 balance
FK__informe_b__infor__78B206DA informe

SQL Script

Copy
CREATE TABLE dbo.informe_balances (
  informe int NOT NULL,
  balance int NOT NULL,
  PRIMARY KEY NONCLUSTERED (informe, balance) WITH (FILLFACTOR = 90)
)
ON [PRIMARY]
GO

SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER trigger dbo.tI_informe_balances on dbo.informe_balances for INSERT as
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* INSERT trigger on informe_balances */
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 */
  /* balances R/277 informe_balances ON CHILD INSERT RESTRICT */
  /* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="balances"
      CHILD_OWNER="", CHILD_TABLE="informe_balances"
      P2C_VERB_PHRASE="R/277", C2P_VERB_PHRASE="", 
      FK_CONSTRAINT="R_277", FK_COLUMNS="balance" */

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

  /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
  /* informes R/276 informe_balances ON CHILD INSERT RESTRICT */
  /* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="informes"
      CHILD_OWNER="", CHILD_TABLE="informe_balances"
      P2C_VERB_PHRASE="R/276", C2P_VERB_PHRASE="", 
      FK_CONSTRAINT="R_276", 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_balances 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_balances on dbo.informe_balances for UPDATE as
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* UPDATE trigger on informe_balances */
begin
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @insinforme int, 
           @insbalance int,
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount
  /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
  /* balances R/277 informe_balances ON CHILD UPDATE RESTRICT */
  /* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="balances"
      CHILD_OWNER="", CHILD_TABLE="informe_balances"
      P2C_VERB_PHRASE="R/277", C2P_VERB_PHRASE="", 
      FK_CONSTRAINT="R_277", FK_COLUMNS="balance" */

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

  /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
  /* informes R/276 informe_balances ON CHILD UPDATE RESTRICT */
  /* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="informes"
      CHILD_OWNER="", CHILD_TABLE="informe_balances"
      P2C_VERB_PHRASE="R/276", C2P_VERB_PHRASE="", 
      FK_CONSTRAINT="R_276", 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_balances 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_balances
  ADD FOREIGN KEY (balance) REFERENCES dbo.balances (balance)
GO

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

Depends On

2