Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8524621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:44:23+00:00 2026-06-11T07:44:23+00:00

My SQL Anywhere 12.0.1 database has two tables: CREATE TABLE ListDetails ( ListDetailId UNIQUEIDENTIFIER

  • 0

My SQL Anywhere 12.0.1 database has two tables:

CREATE TABLE "ListDetails" (
    ListDetailId    UNIQUEIDENTIFIER    NOT NULL PRIMARY KEY,
    ListId          UNIQUEIDENTIFIER    NOT NULL,
    CountryId       VARCHAR(3)          NULL REFERENCES "Countries"      ( CountryId ) DEFAULT 'USA',
    LocaleCode      VARCHAR(3)          NULL REFERENCES "Locales"        ( LocaleCode ),
    Plate           VARCHAR(50)         NULL,
    HashedPlate     UNIQUEIDENTIFIER    NULL,
    AlarmClassId    INT                 NULL REFERENCES "AlarmClasses"   ( AlarmClassId ),
    BeginDate       DATETIME            NULL,
    EndDate         DATETIME            NULL,
    ListPriorityId  INT                 NULL REFERENCES "ListPriorities" ( ListPriorityId ),
    VehicleTypeId   INT                 NULL REFERENCES "VehicleTypes"   ( VehicleTypeId ),
    PlateClassId    INT                 NULL REFERENCES "PlateClasses"   ( PlateClassId ),
    MakeId          INT                 NULL REFERENCES "VehicleBrands"  ( VehicleBrandId ),
    ModelId         INT                 NULL REFERENCES "VehicleModels"  ( VehicleModelId ),
    "Year"          INT                 NULL,
    ColorId         INT                 NULL REFERENCES "VehicleColors"  ( VehicleColorId ),
    Notes           VARCHAR(8000)       NULL,
    OfficerNotes    VARCHAR(8000)       NULL,
    IsNewRow        BIT                 NOT NULL DEFAULT '1',
    CreatedDate     DATETIME            NOT NULL DEFAULT NOW(),
    i_active        SMALLINT            NOT NULL DEFAULT 1,
    ModifyDate      DATETIME            NULL,
    Subscriber      UNIQUEIDENTIFIER    NULL,
    FromToVersion   BIGINT              NOT NULL,
    FromVersion     BIGINT,
    InstanceId      UNIQUEIDENTIFIER    NOT NULL UNIQUE
);

And:

CREATE GLOBAL TEMPORARY TABLE "ListDetailsLoad" ( 
    ListDetailId    UNIQUEIDENTIFIER    NOT NULL,
    ListId          UNIQUEIDENTIFIER    NOT NULL,
    CountryId       VARCHAR(3)          NULL,
    LocaleCode      VARCHAR(3)          NULL,
    Plate           VARCHAR(50)         NULL,
    HashedPlate     UNIQUEIDENTIFIER    NULL,
    AlarmClassId    INT                 NULL,
    BeginDate       DATETIME            NULL,
    EndDate         DATETIME            NULL,
    ListPriorityId  INT                 NULL,
    VehicleTypeId   INT                 NULL,
    PlateClassId    INT                 NULL,
    MakeId          INT                 NULL,
    ModelId         INT                 NULL,
    "Year"          INT                 NULL,
    ColorId         INT                 NULL,
    Notes           VARCHAR(8000)       NULL,
    OfficerNotes    VARCHAR(8000)       NULL,
    Subscriber      UNIQUEIDENTIFIER    NULL,
    InstanceId      UNIQUEIDENTIFIER    NOT NULL
) NOT TRANSACTIONAL;

My program (written in C#) performs a bulk copy into the ListDetailsLoad table and then runs a stored procedure. The stored procedure’s job is to move the data into the ListDetails table. Here’s the stored procedure:

MERGE INTO "ListDetails" AS dst
USING "ListDetailsLoad" AS src
ON dst.ListDetailId = src.ListDetailId
WHEN MATCHED THEN UPDATE 
    SET ListDetailId    = src.ListDetailId,
        ListId          = src.ListId,
        CountryId       = src.CountryId,
        LocaleCode      = src.LocalCode,
        Plate           = src.Plate,
        HashedPlate     = src.HashedPlate,
        AlarmClassId    = src.AlarmClassId,
        BeginDate       = src.BeginDate,
        EndDate         = src.EndDate,
        ListPriorityId  = src.ListPriorityId,
        VehicleTypeId   = src.VehicleType,
        PlateClassId    = src.PlateClassId,
        MakeId          = src.MakeId,
        ModelId         = src.ModelId,
        "Year"          = src."Year",
        ColorId         = src.ColorId,
        Notes           = src.Notes,
        OfficerNotes    = src.OfficerNotes,
        ModifyDate      = NOW(),
        FromToVersion   = dbVersion.NEXTVAL,
        FromVersion     = NULL,
        Subscriber      = src.Subscriber,
        InstanceId      = src.InstanceId
    WHEN NOT MATCHED THEN INSERT
        ( ListDetailId, ListId,        CountryId,  LocaleCode,     Plate,         HashedPlate,
          AlarmClassId, BeginDate,     EndDate,    ListPriorityId, VehicleTypeId, PlateClassId,
          MakeId,       ModelId,       "Year",     ColorId,        Notes,         OfficerNotes,
          ModifyDate,   FromToVersion, Subscriber, FromVersion,    InstanceId )
    VALUES
        ( src.ListDetailId, src.ListId,        src.CountryId,  src.LocaleCode,     src.Plate,         src.HashedPlate,
          src.AlarmClassId, src.BeginDate,     src.EndDate,    src.ListPriorityId, src.VehicleTypeId, src.PlateClassId,
          src.MakeId,       src.ModelId,       src."Year",     src.ColorId,        src.Notes,         src.OfficerNotes,
          NOW(),            dbVersion.NEXTVAL,     NULL,       src.Subscriber, src.InstanceId );

    TRUNCATE TABLE "ListDetailsLoad";
END;

This compiles fine. The problem is when I run it, I get the following error message:

Could not execute statement.  Column "ListDetailId" found in more than one table or it is used more than once in the SELECT list -- it needs a correlation name.

How do I fix the MERGE statement?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T07:44:24+00:00Added an answer on June 11, 2026 at 7:44 am

    It tells you what the problem is. 🙂

    On the left side of your UPDATE statement, there are no correlation names, and it doesn’t know which ListDetailId to update. This should work:

    USING "ListDetailsLoad" AS src
    ON dst.ListDetailId = src.ListDetailId
    WHEN MATCHED THEN UPDATE 
        SET dst.ListDetailId    = src.ListDetailId,
            dst.ListId          = src.ListId,
            dst.CountryId       = src.CountryId,
            dst.LocaleCode      = src.LocalCode,
            dst.Plate           = src.Plate,
            dst.HashedPlate     = src.HashedPlate,
            dst.AlarmClassId    = src.AlarmClassId,
            dst.BeginDate       = src.BeginDate,
            dst.EndDate         = src.EndDate,
            dst.ListPriorityId  = src.ListPriorityId,
            dst.VehicleTypeId   = src.VehicleType,
            dst.PlateClassId    = src.PlateClassId,
            dst.MakeId          = src.MakeId,
            dst.ModelId         = src.ModelId,
            dst."Year"          = src."Year",
            dst.ColorId         = src.ColorId,
            dst.Notes           = src.Notes,
            dst.OfficerNotes    = src.OfficerNotes,
            dst.ModifyDate      = NOW(),
            dst.FromToVersion   = dbVersion.NEXTVAL,
            dst.FromVersion     = NULL,
            dst.Subscriber      = src.Subscriber,
            dst.InstanceId      = src.InstanceId
        WHEN NOT MATCHED THEN INSERT
            ( ListDetailId, ListId,        CountryId,  LocaleCode,     Plate,         HashedPlate,
              AlarmClassId, BeginDate,     EndDate,    ListPriorityId, VehicleTypeId, PlateClassId,
              MakeId,       ModelId,       "Year",     ColorId,        Notes,         OfficerNotes,
              ModifyDate,   FromToVersion, Subscriber, FromVersion,    InstanceId )
        VALUES
            ( src.ListDetailId, src.ListId,        src.CountryId,  src.LocaleCode,     src.Plate,         src.HashedPlate,
              src.AlarmClassId, src.BeginDate,     src.EndDate,    src.ListPriorityId, src.VehicleTypeId, src.PlateClassId,
              src.MakeId,       src.ModelId,       src."Year",     src.ColorId,        src.Notes,         src.OfficerNotes,
              NOW(),            dbVersion.NEXTVAL,     NULL,       src.Subscriber, src.InstanceId );
    
        TRUNCATE TABLE "ListDetailsLoad";
    END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to make a connection to a Sybase (SQL Anywhere) database in a
I have three tables in an SQL 2005 database, that I need to query
I've got a SQL Anywhere 9 database, and I would like to reset the
How to use Wordnet in SQL database. Does it exists anywhere can someone give
I am trying to execute an SQL query on an Adaptive Server Anywhere database.
I'm new to SQL Anywhere. I'm porting a database that we developed in PostgreSQL
I'm trying to connect to SQL Anywhere database on external server. I'm working on
The database I am using is SQL Anywhere from Sybase. v 11.0.1 I have
How to connect to SQL Anywhere 10 db? I have tryed the instruction written
Does anyone know of a mechanism in Sybase ASA 9 / Sybase SQL Anywhere

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.