Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ () — Sybase SQL Server 4.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

  1                       Version 4.0 -- 1/15/89             sp_bindrule
  ______________________________________________________________________

  NAME:  sp_bindrule

  FUNCTION:
       Binds a rule to a column or user datatype.

  SYNTAX:
       sp_bindrule rulename, objname [, futureonly]

  EXAMPLES:
       1)  sp_bindrule today, "employees.startdate"

           Assuming that a rule named today  has  been  created  in  the







  sp_bindrule             Version 4.0 -- 1/15/89                       2
  ______________________________________________________________________
           current database with CREATE RULE, this command binds  it  to
           the  startdate  column of the employees table.  When a row is
           added to employees, the data  for  the  startdate  column  is
           checked against the rule today.

       2)  sp_bindrule rule_ssn, ssn

           Assuming the existence of a rule named rule_ssn  and  a  user
           datatype named ssn, this command binds rule_ssn to ssn.  In a
           CREATE TABLE statement, columns of type ssn inherit the  rule
           rule_ssn.  Existing columns of type ssn also inherit the rule
           rule_ssn,  unless  you  use  the  optional  third  parameter,
           futureonly  (which prevents existing columns of type ssn from
           inheriting the rule), or unless  ssn's  rule  has  previously
           been changed (in which case the changed rule is maintained).

       3)  sp_bindrule rule_ssn, ssn, futureonly



  3                       Version 4.0 -- 1/15/89             sp_bindrule
  ______________________________________________________________________
           The rule rule_ssn is bound to  the  user  type  ssn,  but  no
           existing columns of type ssn are affected.

  PARAMETERS:
       rulename -  is the name of a rule.  Rules are created with CREATE
           RULE  statements  and  then bound to specific columns or user
           datatypes with sp_bindrule.
       objname -  is the name of the table and column, or user datatype,
           to which the rule is to be bound.  If the parameter is not of
           the form "table.column", it is assumed to be a user datatype.
           (Quotation  marks  are  required  around all stored procedure
           parameters that have embedded blanks or punctuation.)
       futureonly -  prevents existing columns of a user  datatype  from
           inheriting  the  new  rule.   This parameter is optional when
           binding a rule to a user datatype.  It  is  never  used  when
           binding a rule to a column.




  sp_bindrule             Version 4.0 -- 1/15/89                       4
  ______________________________________________________________________

  COMMENTS:

       o The rule is enforced when an INSERT is attempted, not at  bind-
         ing.   You  can  bind  a  character rule to a column of numeric
         datatype, even though such an INSERT is illegal.
       o First use the CREATE RULE statement to  create  a  rule.   Then
         execute  sp_bindrule to bind it to a column or user datatype in
         the current database.

       o You cannot bind a rule to a SQL Server-supplied datatype.
       o You cannot bind a rule to a text or image column.

       o If binding to a column, the objname argument  must  be  of  the
         form  "table.column".  Any other format is taken to be the name
         of a user datatype.
       o You can bind a new rule to a  column  or  user  datatype  using



  5                       Version 4.0 -- 1/15/89             sp_bindrule
  ______________________________________________________________________
         sp_bindrule without unbinding an existing rule.  The  old  rule
         is overridden.

       o Existing columns of the user  datatype  inherit  the  new  rule
         unless  their rule has previously been changed, or the value of
         the optional third parameter is futureonly.  New columns of the
         user datatype always inherit the rule.

  MESSAGES:
       The rule was successfully bound to the specified  column  in  the
           specified table.
       The rule was successfully bound to the specified user datatype.
       The objname parameter supplied with  the  procedure  contained  a
           reference to another database.  Rules can be bound to objects
           in the current database only.
       First create the rule in the current database with  CREATE  RULE.
           Then execute sp_bindrule.
       Only the owner of a table can bind a rule to any of its  columns.


  sp_bindrule             Version 4.0 -- 1/15/89                       6
  ______________________________________________________________________
           You are not the owner or the object doesn't exist.
       Only the owner of a user datatype can bind a rule to it.  You are
           not the owner.
       Existing columns of the specified user datatype now have the  new
           rule  bound  to  them  (unless  their  rules  were previously
           changed).

  PERMISSIONS:
       Execute permission to object owner.

  TABLES USED:
       syscolumns, sysobjects, systypes

  SEE ALSO:
       sp_bindefault, sp_unbindefault, sp_unbindrule, CREATE RULE,  DROP
       RULE



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026