Creating constraints

Need some help.
Anyone now how to create a constrain for this problem:
evry persone got a sysnr:
ex 197910182291
the first 4 numbers are the year of birth
the seccond 2 is the Month
the next 2 is the day
so if the Birthday date = 18-10-1979
how can i check of the sysnr is vallid???
19791018 of the sysnr should the same as the birthdaydate
but inverted as 18101979
the birthdaydate is long (18-oct-1979)
anyone???
(this check i need when i creating new tables and filling them up)

Maybe the TO_DATE function would help.
The manual reference for it is on http://tahiti.oracle.com/
There are various examples scattered elsewhere on the web.
The best forum for following up this question about the SQL
language is the PL/SQL and SQL forum at:
http://www.oracle.com/forums/forum.jsp?forum=75
-- CJ

Similar Messages

  • Can I create constraints "Primary key - Foreign key" on materialized views?

    Hello!
    Can I create constraints "Primary key - Foreign key" on materialized views like on tables?
    My purpose - is to make DB schema "COPY" with set of materialized views or tables, which take data from time to time from other tables situated.into another schema "ORIGINAL".
    Also - I want to use reporting tool, like Crystal Reports, to make nice reports from schema "COPY". To make nice reports, I need primary-foreign relationships between materialized views or tables in schema "COPY".
    Is it possible to use materialized views?
    Or I should use only tables to get such result?
    Thank you in advance.
    Edited by: kogotok1 on Dec 3, 2010 5:01 PM

    What happens when you try it? Or search the manuals.
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/statements_6002.htm#i2105365
    http://download.oracle.com/docs/cd/E11882_01/server.112/e10706/repmview.htm#REPLN360

  • Please Help - Avoid default name when creating constraints

    Here I am creating two very simple tables:
    create table supplier
         id number not null,
         constraint pk_supplier primary key (id)
    create table product
    id number not null,
    supplier_id number not null,
    constraint pk_product primary key (id),
    constraint fk_product_supplier_id
    foreign key (supplier_id) references supplier(id)
    After done while I choose to view table constraint information by using:
    select table_name, constraint_name
    from user_cons_columns
    where lower(table_name) = 'product';
    I get result:
    TABLE_NAME                     CONSTRAINT_NAME
    PRODUCT                        SYS_C005441
    PRODUCT                        SYS_C005442
    PRODUCT                        PK_PRODUCT
    PRODUCT                        FK_PRODUCT_SUPPLIER_ID
    What is the "SYS_C005441" and "SYS_C005442" for? Can I avoid creating them?
    Thanks

    Justin Cave wrote:
    Are you suggest not explicitly naming all your constraints? Or just the NOT NULL ones?No, not at all. Did not even thought that far when I responded. Bit of foot in mouth as I only thought of not null constraints. Blame it on a lack of coffee. :-)
    I usually name primary & foreign key and check constraints. But not null constraints - too much of an effort to name them IMO.
    But you do raise an interesting topic. Why bother naming some constraints (e.g. PK and FK) and not others (e.g. not null)? So playing devil's advocate, why should we be naming constraints at all?
    It sounds like you're suggesting that all constraints should get system default names. Well, one can argue that the same effort of naming other constraints is not worth it - why have null constraints as the exception to implicit naming? I would think that the issue I raised also applies to all constraints.
    You have multiple foreign key constraints for INVOICE_ID - how do you name these? I would like both the table and column names as this will provide the meaning needed when seeing the constraint being violated. But with 30 chars only, that is a problem. So invariable one needs to start to abbreviate table and column names in order to make it meaningful constraint name. Been there many times - disliked the constraint name I came up with every time, as it was a compromise and not the actual naming format I would have preferred.
    If that's what you're suggesting, doesn't that create problems for you when different environments have different constraint names? I know personally that I'd much rather have named constraints so that when there are constraint violation errors in production, I can start troubleshooting the problem in my local environment without first determining how to map the production constraint name to my local database's constraint name. Understand your point - and yes, it can be an issue. But by the same token, why should an application user ever see a default Oracle exception? With the exception of system-type exceptions (e.g. no more tablespace space, eof on communcation channel), all other exceptions should be custom application exceptions.
    Showing for example a "+ORA-00001: unique constraint (xxx.xxxxx) violated+" is wrong IMO. The app code should trap that exception and raise a meaningful and unique application exception for that. The user seeing anything other than a custom app exception, should itself be an exception.
    And I'd much rather be able to put the constraint name in a script that is to be promoted through the environments rather than coming up with a process that uses dynamic SQL to figure out the name of the constraint I want to do something to. Well, I would not rely on a constraint name itself to determine what it is. Just because it says fk_invoiceid_invoices does not mean that is is a foreign key on column invoice_id and references the invoices table. The safe/proper thing to do would be to query the data dictionary and confirm just what that constraint is.
    I suppose if you know that all the lower environments are very recent clones of production rather than running all the scripts in source control that these problems may not be particularly large. But I'm curious if you have some better approach to handling them (or if I'm completely misinterpreting what you're suggesting).Not sure if you recall some feature discussion with Tom and others (was on asktom?) when someone came up with this core issue and suggested it be addressed by allowing one to define an exception message with the definition of the constraint. Cannot recall the exact syntax proposed, but I do remember thinking that it was not a shabby idea - as this solves the problem of having to invent a meaningful name using 30 chars only. And it also removes the need for trapping that constraint violation in all app code that may cause the exception and raising a custom and meaningful app exception instead. Not too mention that plain and direct SQL access will show the same exception message.
    Perhaps in Oracle 12c? I assume the c as it seems that The Next Big Thing is cloud computing and surely Oracle 12 will somehow try to exploit that buzzword - as it has with i (Internet) and g (Grid) versions. ;-)

  • Creating Constraint for a Dependency

    Hi all,
            I am basically an abaper, there is a requirement to create a constraint for a dependency. when i go to the transaction cu01 to create a dependency and try to add the code for constraint. The screen do not show me any means of adding the code. There are options for adding PRECONDITION, ACTION, SELECTION CONDITION and PROCEDURE. But when i go to the transaction CU03 i see additional option on the screen RULES & CONSTRAINTS. Could any help me out in creating the constraint for a dependency.
    Thanks in Advance
    Shiv

    Hi Gurav,
                 Thanks for your previous reply. The requirement is, i have to compare the weight assigned to the material while creating sales order with the Max and Min weight set for the material in variant configuration.
    Example:
                 Material     -     312.
                 Min Weight  -   100 Gm
                 Max Weight -   1000 Gm
    Variant Configuration details:
    Varient Tables - ZZDIS_FMT_MINWGT & ZZDIS_FMT_MAXWGT
    Dependency Net - ZZDIS_CON_FMT_MINWGT & ZZDIS_CON_FMT_MAXWGT
    Dependency (constraint) -   ZZDIS_CON_FMT_MIN01 &   ZZDIS_CON_FMT_MAX01.
    Characteristics : ZZDIS_FMT_MINWGT & ZZDIS_FMT_MAXWGT
    Class: ZZDIS_FMT_MINWGT & ZZDIS_FMT_MAXWGT.
            I need to write the code in the constraint with the above details. Could you please help me on that.
    My official mail Id - [email protected]
    Thanks in Advance
    Shiv

  • Problem in create constraints

    hi..
    i am attempting to create a primary constraint on one table which containts
    more than 50 lacs records.when i tried to add constraints with enable novalidate,but its failed to create a constraints on the table.
    we have to preserve the data which already presented in the table. there is no way to delete and change the records which is presented now.
    please in what way to over come this problem.
    by
    ravikumar

    BANNER
    Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Prod
    PL/SQL Release 10.1.0.2.0 - Production
    CORE 10.1.0.2.0 Production
    TNS for 32-bit Windows: Version 10.1.0.2.0 - Production
    NLSRTL Version 10.1.0.2.0 - Production
    desc hp_tran_dtls
    Name Null? Type
    TC VARCHAR2(3)
    DOC_NO VARCHAR2(15)
    DOC_DT DATE
    AGR_NO VARCHAR2(10)
    TRAN_DTLS_SRNO NUMBER(6)
    GL_CODE NOT NULL VARCHAR2(5)
    SUB_CODE VARCHAR2(15)
    REF_NO VARCHAR2(15)
    REF_DT DATE
    CHQ_NO VARCHAR2(10)
    CHQ_DT DATE
    ACT VARCHAR2(5)
    DIV VARCHAR2(5)
    EMP VARCHAR2(5)
    PARTICULARS VARCHAR2(60)
    DBCR CHAR(1)
    AMT NOT NULL NUMBER(16,2)
    TRN_TYPE CHAR(1)
    LOCK_REC_FLG CHAR(1)
    TMP_RECNO VARCHAR2(10)
    VALUE_DT DATE
    CHQ_BANK VARCHAR2(10)
    BRANCH NOT NULL VARCHAR2(5)
    SECTOR VARCHAR2(5)
    PRODUCT VARCHAR2(5)
    PORTFOLIO VARCHAR2(5)
    FUTURE1 VARCHAR2(5)
    FUTURE2 VARCHAR2(5)
    BRANCHNM VARCHAR2(30)
    REASON1 VARCHAR2(5)
    TMP_REC_DT DATE
    ADDL_AMT NUMBER(14,2)
    TRANS_NAT VARCHAR2(5)
    REC_STATUS CHAR(1)
    BUSI_AREA VARCHAR2(5)
    FA_TRANSFER CHAR(1)
    CHQ_HNDL VARCHAR2(60)
    CHQ_HNDL_TAG CHAR(1)
    INS_CHECK VARCHAR2(2)
    FA_POST_IND VARCHAR2(3)
    FA_POST_DOC_NO VARCHAR2(10)
    i have to create primary(tc,doc_no,TRAN_DTLS_SRNO)

  • Create constraint to enforce proper email domain

    Hi,
    I'm new to SQL, but am trying to help a friend build a database for his company he is trying to start (think of a mechanic and his home garage).
    I'm using Oracle 11g Express. Per the the below code, how do I build a check constraint that enforces that the value for 'Email' must be using the domain of his company? E.G.- *@billsgarage.com
    Thanks for your help!
    CREATE TABLE EMPLOYEE
    (EmpNo NUMBER(6) PRIMARY KEY,
    Title VARCHAR2(30) NOT NULL,
    Fname VARCHAR2(10) NOT NULL,
    Lname VARCHAR2(10) NOT NULL,
    Phone VARCHAR2(12) NOT NULL,
    Email VARCHAR2(40),
    HireDate DATE DEFAULT GETDATE(),

    Hi,
    In Oracle, to handle such requirements we have constraints. These constraints can either be added while creating the table or modifying the table structure.
    While creating table, constraint can be added as below. For example, I have created a table called as Test_Tab with two columns. And I added a constraint on the email column.
    1. A check constraint is added which checks whether the values coming into the table has @google.com pattern or not. If not then, such email id would not be inserted into the table.
    2. And this check is done through a function instr which checks a particular pattern and returns the position when found.
    create table Test_tab
    name varchar2(30),
    email varchar2(30) constraint email_check check(instr(email,'@google.com')>0)
    If you have already created the table, then you can use :
    Alter table test_Tab
    Add email constraint email_check check(instr(email,'@google.com')>0)
    Hope that is what you needed.

  • Create constraint to avoid space

    I am using Oracle 10.2.0.4.
    How can I create a constraint for a varchar2 (20) column to avoid spaces. The constraint should NOT be triggered if the value has spaces together with some digit or character eg 'a b'.
    It should only be triggered if the column being inserted has one or more space and no other characters. eg . ' ' or ' '
    Thanks for any help.

    It sounds like you just want
    CHECK( TRIM(column_name) IS NOT NULL )Justin

  • Creating Constraint

    I have been runing following composite primay key since 4 hrs.Is it any problem that it is taking time?Please help me
    ALTER TABLE temp_ino ADD CONSTRAINT
    PRIMARY
    KEY(ST_NO,PO_NO,TRANS_DATE,TIC_NO,SEQNO_1,TIC_START_TIME)
    USING INDEX TIC_ITEM parallel 10
    Total no of row in temp_info table is 591989900

    Just a little bit of advice that may come in handy in the future.
    Once this has all completed and the index you've created behind the scenes is all shiny and brand new, just take note of the height of the index.
    If it has a height of 4 (blevel of 3) or more which an index of this size could very well have, be very careful of any rebuild criteria that suggests that an index with a height of 4 or more should be rebuilt.
    Because now you know spending 9+ hours to rebuild such an index will be an entirely pointless exercise ...
    Cheers
    Richard Foote
    http://richardfoote.wordpress.com/

  • ALTER TABLE privilege and CREATE/DROP/ENABLE/DISABLE constraint privilege

    Hi,
    I am looking for some detailed info regarding the below previleges
    ALTER TABLE, CREATE CONSTRAINT, DROP CONSTRAINT, ENABLE CONSTRAINT AND DISABLE CONSTRAINT PRiVILEGES.
    I have two schemas 'A' and 'B', I want to provide user 'A' with Alter table, create or drop constraint,Enable or Disable constraint on schema B.
    Please let me know how to make this work.
    Thank you

    I got the answer for my second question, I have an option to grant 'Alter ANY table' privilege to the user.Yes, but you should not do that.
    Regarding question one, Suppose I have two schemas A and B and I want Schema A to have alter table privilege on all tables of Schema B.
    Can I do this in one command No
    or I need to grant alter on each table saperately?Yes
    If I am chosing the second option for each table saperately then whenever a table is added in schema B we need to grant privilege on that table as well.Yes. But nothing strange there. Designing and creating objects includes the privileges on them.
    If user A is granted with alter table privilege on a table which user B owns then can user A drop/create/enable/disable constraints for that table?Yes, isn't that what all this about?
    Again, letting one user alter the objects of another user is generally not such a good idea. Hope you see this from our discussion.
    Alter table privilege includes adding and dropping columns. This is why I suggested writing a procedure that does exactly what you need. And then grant execute on that to A.
    The best thing of course would be NOT TO disable the constraints, they are probably there for a reason.
    I am currently handling an issue where one session doing this, deadlocks with another session doing only selects - From other tables, that is!
    Regards
    Peter

  • SQL 2012 and later will fail to publish a database for any tables with a default constraint that references a user defined function.

    Script will create database, 3 database objects and publish. 
    The error is due to the generation script to create the conflict tables that is not stripping out default constraints that reference a UDF. 
    As you can see below, the failure is on the generation script for the conflict table.
    The conflict table should be a bucket table that shouldn’t enforce data integrity. 
    See how the default constraints for the columns someint and somestring were stripped out of the generation logic however the default constraint that utilizes a UDF persist and uses the same object name that was used on the production table (The
    bold line) , this occurs if I explicitly name the constraint or let the system generate the name for me like in the example posted. 
      The only way I could see getting around this right now is to drop all default constraints in the system that uses a UDF, publish then add the constraints back which is vulnerable to invalid data and a lot of moving
    steps.  This all worked with SQL 2000, 2005, 2008, 2008r2, it’s stopped working in SQL 2012 and continues to not work in SQL 2014. 
    Error messages:
    Message: There is already an object named 'DF__repTable__id__117F9D94' in the database.
    Could not create constraint. See previous errors.
    Command Text: CREATE TABLE [dbo].[MSmerge_conflict_MergeRepFailurePublication_repTable](
            [id] [varchar](8) NULL CONSTRAINT [DF__repTable__id__117F9D94]  DEFAULT ([dbo].[repUDF]()),
            [somedata] [varchar](64) NULL,
            [rowguid] [uniqueidentifier] ROWGUIDCOL  NULL,
            [someint] [int] NULL,
            [somestring] [varchar](64) NULL
    Parameters:
    Stack:    at Microsoft.SqlServer.Replication.AgentCore.ReMapSqlException(SqlException e, SqlCommand command)
       at Microsoft.SqlServer.Replication.AgentCore.AgentExecuteNonQuery(SqlCommand command, Int32 queryTimeout)
       at Microsoft.SqlServer.Replication.AgentCore.ExecuteDiscardResults(CommandSetupDelegate commandSetupDelegate, Int32 queryTimeout)
       at Microsoft.SqlServer.Replication.Snapshot.YukonMergeConflictTableScriptingManager.ApplyBaseConflictTableScriptToPublisherIfNeeded(String strConflictScriptPath)
       at Microsoft.SqlServer.Replication.Snapshot.BaseMergeConflictTableScriptingManager.DoConflictTableScriptingTransaction(SqlConnection connection)
       at Microsoft.SqlServer.Replication.RetryableSqlServerTransactionManager.ExecuteTransaction(Boolean bLeaveTransactionOpen)
       at Microsoft.SqlServer.Replication.Snapshot.BaseMergeConflictTableScriptingManager.DoConflictTableScripting()
       at Microsoft.SqlServer.Replication.Snapshot.MergeSmoScriptingManager.GenerateTableArticleCftScript(Scripter scripter, BaseArticleWrapper articleWrapper, Table smoTable)
       at Microsoft.SqlServer.Replication.Snapshot.MergeSmoScriptingManager.GenerateTableArticleScripts(ArticleScriptingBundle articleScriptingBundle)
       at Microsoft.SqlServer.Replication.Snapshot.MergeSmoScriptingManager.GenerateArticleScripts(ArticleScriptingBundle articleScriptingBundle)
       at Microsoft.SqlServer.Replication.Snapshot.SmoScriptingManager.GenerateObjectScripts(ArticleScriptingBundle articleScriptingBundle)
       at Microsoft.SqlServer.Replication.Snapshot.SmoScriptingManager.DoScripting()
       at Microsoft.SqlServer.Replication.Snapshot.SqlServerSnapshotProvider.DoScripting()
       at Microsoft.SqlServer.Replication.Snapshot.MergeSnapshotProvider.DoScripting()
       at Microsoft.SqlServer.Replication.Snapshot.SqlServerSnapshotProvider.GenerateSnapshot()
       at Microsoft.SqlServer.Replication.SnapshotGenerationAgent.InternalRun()
       at Microsoft.SqlServer.Replication.AgentCore.Run() (Source: MSSQLServer, Error number: 2714)
    Get help: http://help/2714
    Server COL-PCANINOW540\SQL2012, Level 16, State 0, Procedure , Line 1
    Could not create constraint. See previous errors. (Source: MSSQLServer, Error number: 1750)
    Get help: http://help/1750
    Server COL-PCANINOW540\SQL2012, Level 16, State 0, Procedure , Line 1
    Could not create constraint. See previous errors. (Source: MSSQLServer, Error number: 1750)
    Get help: http://help/1750
    Pauly C
    USE [master]
    GO
    CREATE DATABASE [MergeRepFailure]
    ALTER DATABASE [MergeRepFailure] SET COMPATIBILITY_LEVEL = 110
    GO
    USE [MergeRepFailure]
    GO
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    create view
    [dbo].[repView] as select right(newid(),8) as id
    GO
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE FUNCTION [dbo].[repUDF]()
    RETURNS varchar(8)
    BEGIN
    declare @val varchar(8)
    select top 1 @val = id from [repView]
    return @val
    END
    GO
    create table repTable
    id varchar(8) default([dbo].[repUDF]()),
    somedata varchar(64) null,
    rowguid uniqueidentifier ROWGUIDCOL default(newid()),
    someint int default(1),
    somestring varchar(64) default('somestringvalue')
    GO
    insert into reptable (somedata) values ('whatever1')
    insert into reptable (somedata) values ('whatever2')
    go
    /*test to make sure function is working*/
    select * from reptable
    GO
    /*Publish database*/
    use [MergeRepFailure]
    exec sp_replicationdboption @dbname = N'MergeRepFailure', @optname = N'merge publish', @value = N'true'
    GO
    declare @Descrip nvarchar(128)
    select @Descrip = 'Merge publication of database ''MergeRepFailure'' from Publisher ''' + @@servername +'''.'
    print @Descrip
    -- Adding the merge publication
    use [MergeRepFailure]
    exec sp_addmergepublication @publication = N'MergeRepFailurePublication', @description = N'@Descrip',
    @sync_mode = N'native', @retention = 14, @allow_push = N'true', @allow_pull = N'true', @allow_anonymous = N'true',
    @enabled_for_internet = N'false', @snapshot_in_defaultfolder = N'true', @compress_snapshot = N'false', @ftp_port = 21,
    @ftp_subdirectory = N'ftp', @ftp_login = N'anonymous', @allow_subscription_copy = N'false', @add_to_active_directory = N'false',
    @dynamic_filters = N'false', @conflict_retention = 14, @keep_partition_changes = N'false', @allow_synctoalternate = N'false',
    @max_concurrent_merge = 0, @max_concurrent_dynamic_snapshots = 0, @use_partition_groups = null, @publication_compatibility_level = N'100RTM',
    @replicate_ddl = 1, @allow_subscriber_initiated_snapshot = N'false', @allow_web_synchronization = N'false', @allow_partition_realignment = N'true',
    @retention_period_unit = N'days', @conflict_logging = N'both', @automatic_reinitialization_policy = 0
    GO
    exec sp_addpublication_snapshot @publication = N'MergeRepFailurePublication', @frequency_type = 4, @frequency_interval = 14, @frequency_relative_interval = 1,
    @frequency_recurrence_factor = 0, @frequency_subday = 1, @frequency_subday_interval = 5, @active_start_time_of_day = 500, @active_end_time_of_day = 235959,
    @active_start_date = 0, @active_end_date = 0, @job_login = null, @job_password = null, @publisher_security_mode = 1
    use [MergeRepFailure]
    exec sp_addmergearticle @publication = N'MergeRepFailurePublication', @article = N'repTable', @source_owner = N'dbo', @source_object = N'repTable', @type = N'table',
    @description = null, @creation_script = null, @pre_creation_cmd = N'drop', @schema_option = 0x000000010C034FD1, @identityrangemanagementoption = N'manual',
    @destination_owner = N'dbo', @force_reinit_subscription = 1, @column_tracking = N'false', @subset_filterclause = null, @vertical_partition = N'false',
    @verify_resolver_signature = 1, @allow_interactive_resolver = N'false', @fast_multicol_updateproc = N'true', @check_permissions = 0, @subscriber_upload_options = 0,
    @delete_tracking = N'true', @compensate_for_errors = N'false', @stream_blob_columns = N'false', @partition_options = 0
    GO
    use [MergeRepFailure]
    exec sp_addmergearticle @publication = N'MergeRepFailurePublication', @article = N'repView', @source_owner = N'dbo', @source_object = N'repView',
    @type = N'view schema only', @description = null, @creation_script = null, @pre_creation_cmd = N'drop', @schema_option = 0x0000000008000001,
    @destination_owner = N'dbo', @destination_object = N'repView', @force_reinit_subscription = 1
    GO
    use [MergeRepFailure]
    exec sp_addmergearticle @publication = N'MergeRepFailurePublication', @article = N'repUDF', @source_owner = N'dbo', @source_object = N'repUDF',
    @type = N'func schema only', @description = null, @creation_script = null, @pre_creation_cmd = N'drop', @schema_option = 0x0000000008000001,
    @destination_owner = N'dbo', @destination_object = N'repUDF', @force_reinit_subscription = 1
    GO

    More information, after running a profile trace the following 2 statements, the column with the default on a UDF returns a row while the other default does not.  This might be the cause of this bug.  Is the same logic to generate the object on
    the subscriber used to generate the conflict table?  
    exec sp_executesql N'
    select so.name, schema_name(so.schema_id)
    from sys.sql_dependencies d
    inner join sys.objects so
    on d.referenced_major_id = so.object_id
    where so.type in (''FN'', ''FS'', ''FT'', ''TF'', ''IF'')
    and d.class in (0,1)
    and d.referenced_major_id <> object_id(@base_table, ''U'')
    and d.object_id = object_id(@constraint, ''D'')',N'@base_table nvarchar(517),@constraint nvarchar(517)',@base_table=N'[dbo].[repTable]',@constraint=N'[dbo].[DF__repTable__id__117F9D94]'
    exec sp_executesql N'
    select so.name, schema_name(so.schema_id)
    from sys.sql_dependencies d
    inner join sys.objects so
    on d.referenced_major_id = so.object_id
    where so.type in (''FN'', ''FS'', ''FT'', ''TF'', ''IF'')
    and d.class in (0,1)
    and d.referenced_major_id <> object_id(@base_table, ''U'')
    and d.object_id = object_id(@constraint, ''D'')',N'@base_table nvarchar(517),@constraint nvarchar(517)',@base_table=N'[dbo].[repTable]',@constraint=N'[dbo].[DF__repTable__somein__1367E606]'
    Pauly C

  • SQL Server 2014 Snapshot agent duplicating constraints

    Hello,
    We are upgrading our server from SQL Server 2008 R2 Std. Ed.  to SQL Server 2014 Std. Ed.
    Our server works with Merge and Transactional publications.
    Our current problem happens when trying to generate the first snapshot using the snapshot agent. Since this is the first time, the snapshot will create all the system tables related with replication and the error happens when creating the table MSmerge_conflict_<publication>_<article>
     because now the snapshot agent is trying to create the constraints from the <article> (a table in our case)  with the same name, so it brings the conflict of having duplicated constraints names and because of that the snapshot agent fails.
     This didn't happen on 2008 because the snapshot agent didn't try to create the constraints before.
    This is the error that we see on the Snapshot Agent Status: There is already an object named"NewAccountPermission" in the database. Could not create constraint or index. See previous errors.
    The exact T-sql statement that is failing is shown on the replication monitor:
    Error messages:
    Message: There is already an object named 'NewAccountPermission' in the database.
    Could not create constraint or index. See previous errors. 
    Command Text: CREATE TABLE [dbo].[MSmerge_conflict_Roster_AccountPermissions](
    [AccountPermissionID] [int] NOT NULL CONSTRAINT [NewAccountPermission]  DEFAULT ([dbo].[getNewAccountPermissionID]()),
    [PermissionName] [varchar](255) NULL,
    [Description] [varchar](255) NULL,
    [rowguid] [uniqueidentifier] ROWGUIDCOL  NOT NULL
    Digging a bit further I searched and compared the snapshot files that creates this table. Here it can be seen that the snapshot files only differ on the creation or not of the constraint.
    Here is an extract o f the 2014 file called AccountPermissions_3.cft
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[MSmerge_conflict_Roster_AccountPermissions](
    [AccountPermissionID] [int] NOT NULL CONSTRAINT [NewAccountPermission]  DEFAULT ([dbo].[getNewAccountPermissionID]()),
    [PermissionName] [varchar](255) NULL,
    [Description] [varchar](255) NULL,
    [rowguid] [uniqueidentifier] ROWGUIDCOL  NOT NULL
    Here is the 2008 version of the same file:
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[MSmerge_conflict_Roster_AccountPermissions](
    [AccountPermissionID] [int] NOT NULL,
    [PermissionName] [varchar](255) NULL,
    [Description] [varchar](255) NULL,
    [rowguid] [uniqueidentifier] ROWGUIDCOL  NOT NULL
    Any ideas on what is going on? Do I have to configure some properties on the publication now to disallow creating the constraints on the msmerge_conflict table?
    Thank you,
    Alejandro Rivera

    Hi Hilary,
    1) There is an user table called dbo.AccountPermissions. The problem happens when the snapshot agent tries to create MSmerge_conflicts_Roster_AccountPermissions (system table). The database is called Roster.
    2) We use the default dbo schema. Here is the create script for that table (just in case):
    USE [Roster]
    GO
    /****** Object:  Table [dbo].[AccountPermissions]    Script Date: 11/17/2014 7:48:27 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_PADDING ON
    GO
    CREATE TABLE [dbo].[AccountPermissions](
    [AccountPermissionID] [int] NOT NULL CONSTRAINT [NewAccountPermission]  DEFAULT ([dbo].[getNewAccountPermissionID]()),
    [PermissionName] [varchar](255) NULL,
    [Description] [varchar](255) NULL,
    [rowguid] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [MSmerge_df_rowguid_13B9434FF11A44ACB63F5D2927C053FD]  DEFAULT (newsequentialid()),
     CONSTRAINT [pk_accountpermissions] PRIMARY KEY CLUSTERED 
    [AccountPermissionID] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    SET ANSI_PADDING OFF
    GO
    I'd put a screenshot too, but sadly the forum doesn't allow me until it verifies my account.
    Let me know if you any more info.
    Thank you,

  • Constraint capacity planning for Un-Routed items in ASCP

    Hi All,
    Is there any possibility to create constraint capacity planning for items which do not have routings in ASCP?
    I tried by setting Bill of Resources (BOR) in Aggregatin tabbed region in Plan option. But i could not get an expected result. Kindly help me out in this.
    regards,
    Murlai R
    Edited by: user10942922 on Mar 27, 2009 9:30 AM

    Dear ,
    To answer the question for Capacity requirement planning on sales order I would say that MRP does  only materials planning based on demand and reciept  but never does Capacity Requirement Plannig .MRP generates Planned Order  and susequently , production order can be genreted and farther you can carry out capacity requirement planning based on the work cente available capacity , requirement and load for those MTO orders .
    But there are SAP business suit like APO-SNP APO PPDS which carriy our details scheduleing and caapcity check based on the demand situation : Sales Order ,Independent Order  and does capcaity vaialbality chek for those demands while planning .
    Now , here is the answer of your question :
    1) Can Capacities are Scheduled as per priority given in SO automatically. : Not possible  through  SAP MRP but in APO-PPDS, APO-SNP-CTM , Herustic model .
    2) Can revised availability dates will be reflected in SO. : It can be reflected as per the ATP chekc , Replishmenet Lead  Time and re-scheduling horizon maintained in OPPQ-Carry all overall plant parametres.
    3) Which reports will be useful for understanding consolidated availability date of material for given sales order/s. : You can check through MD04/MD05 or in sales order -Availaibility check -Schedule Line -Availaibility date .
    Hope your are clear about the requirememt .
    Regards
    JH
    Edited by: Jiaul Haque on Jun 5, 2010 1:59 PM
    Edited by: Jiaul Haque on Jun 5, 2010 1:59 PM

  • Can I create a new table using strcuture of another existing table ????

    hello all -
    If I need to create table as the duplicate table for another table. I donot need data from that table, as I am going to populate date later on.
    So all need is the structure, constraints of the table to create a new table.
    create table new_temp as
    select * from old_temp;
    above command creates a table with the data, what if I donot want the data, only the defination.
    Any help woud really appreciated.
    Thanks
    Rama

    but create table as select..
    CAN'T create constraint on new table it copy only data
    not constraint
    so create new table with structure as well as
    constraint use
    SELECT dbms_metadata.get_ddl('TABLE','EMP') FROM DUAL;
    only in 9i
    kuljeet pal singh

  • Problem in PK Constraints??????????????

    Dear All,
    i have created this table and the Tablespace is VIDI, but while creating PK Constraints the constarint is taking up the Default Tablespace APREGS. Is this a problem. Or wat is the syntax to Create constraints into a tablespace.
    Below is my Script. Plz reply.
    -- Create table
    create table VIDI_ACCT_MATERIALS
    TRANSACTION_DATE DATE,
    TRANSACTION_ID CHAR(9) not null,
    WORK_CODE CHAR(18) not null,
    AMOUNT NUMBER,
    SUPPLIER_CODE CHAR(7),
    CHEQUE_NO CHAR(6),
    CHEQUE_DATE DATE,
    SRC_ID CHAR(8),
    PCC_INFO_CODE VARCHAR2(9) not null,
    CREATED_DATE DATE not null,
    CREATED_BY VARCHAR2(20) not null
    tablespace VIDI
    pctfree 10
    pctused 40
    initrans 1
    maxtrans 255
    storage
    initial 64K
    minextents 1
    maxextents unlimited
    -- Create/Recreate primary, unique and foreign key constraints
    alter table VIDI_ACCT_MATERIALS
    add constraint PK_VIDI_ACCT_MATERIALS primary key (TRANSACTION_ID,PCC_INFO_CODE)
    using index
    tablespace APREGS
    pctfree 10
    initrans 2
    maxtrans 255
    storage
    initial 64K
    minextents 1
    maxextents unlimited
    Thanks

    In any case, your constraints won't go to the tablespace where your tables resides, rather this information always go into data dictionary, which always
    be in system tablespace, however you can force your associated index to be placed in different tablespce.
    hare krishna
    Alok

  • SQL Constraints

    Hi,
    I have got a small query ( using oracle 10g)
    I would like to create constraints as shown in the below table between first and second colum( id & item). Is this possible using constraints
    id     item     Qty
    1     Apple     10
    2     Orange     40
    3     Kiwi     10
    3     Kiwi     5
    2     Apple     8
    2     Orange     50  ======> not allowed ( id 2 should be Orange)
    1     Mango     20  ======>  not allowed ( id 1 should be Apple)
    4     Mango 10
    Help in this regard is very much appreciated.
    Thanks
    YG

    Hi,
    user8268619 wrote:
    Hi,
    I have got a small query ( using oracle 10g)
    I would like to create constraints as shown in the below table between first and second colum( id & item). Is this possible using constraints
    id     item     Qty
    1     Apple     10
    2     Orange     40
    3     Kiwi     10
    3     Kiwi     5
    2     Apple     8
    2     Orange     50  ======> not allowed ( id 2 should be Orange)
    1     Mango     20  ======>  not allowed ( id 1 should be Apple)
    4     Mango 10
    Help in this regard is very much appreciated.
    Thanks
    YG
    Sorry, it's not clear what you want.
    When you say "id 2 should be Orange", do you mean item should be 'Orange' whenever id=2?  If so, what's wrong with the row
    2     Orange     50  ======> not allowed ( id 2 should be Orange)
    You may need to have 2 tables; the table you mentioned above, and another table with the allowed (id, item) combinations, with a foreign key constraint.

Maybe you are looking for

  • Problem while running the report from a form

    Hi, I am able to call a report from forms9i using run_report_object. This report just has a boilertext within it. I did this just to check the functionality of run_report_object built-in. This worked perfectly. But when I am trying to call a report b

  • I am no longer able to email to a group

    I have been trying for 3 days to send e-mail messages to a group from the contacts I set up in my address book.  I have been able to do this for years, and all of a sudden, it does not work.  I always get the same message: Sending the message content

  • Recover from source system deletion

    Hi experts, Our source system assignment to ECC was accidentally deleted which subsequently deleted the transfer stuctures/rules.  Apart from restoring from backup, how can we recover the transfer rules?  We could manually assign the source system ag

  • Date in sql query problem

    Hi, I have a search form with 1 field (date picker) - the user chooses a date and a report based on a sql query is shown. I want the report to be based on only the month and year, and not the particular day. If there is a date picker (or something si

  • How do you call a JavaScript function from a Java applet

    I have an Applet that needs to run on the following platforms: Internet Explorer (Windows-NT, Windows -2000), Netscape (Windows-NT, Windows-2000, Sun(Solaris), RedHat(Linux), HP(11.0), IBM(AIX)). The Applet needs to call a JavaScript function that is