Be.Smart ERP Connector
(EN) ERP Connector
(EN) ERP Connector
  • ℹ️What is ERP Connector?
  • ⚙️System Requirements
  • 🔑Installation & Activation Guide
  • 🆕What's New
    • Versions 30.1.0.6, 29.3.0.5, 28.8.0.5 & 27.14.0.5
    • Versions 30.0.0.3, 29.2.1.2, 28.7.3.3 & 27.13.0.5
    • Versions 28.7.1.1, 27.13.0.1
    • Versions 29.2.1.0, 28.7.1.0, 27.13.0.0
    • Versions 29.1.0.0, 28.6.0.0, 27.12.0.0
    • Versions 29.0.0.1 & 28.5.1.1
  • Data Interface - Reference Manual
    • Abbreviations
    • Data interface
      • Data tables, relations
        • Table EcENTITY
        • Table EcASSOC
        • Table EcLINK
        • Table EcLOG
        • Stored procedure EcWriteEntity
    • Exporting data from a Vault
      • Properties / Attributes
      • Associations
      • Links
      • Reading data from data interface
        • Workflow sample
        • Another samples
    • Importing data into a Vault
      • Mandatory EcENTITY table fields
      • Default values
      • LifeCycle States
      • Writing data into data interface
        • Using SQL Stored Procedure
          • Example #1 – insert single EcENTITY record
          • Example #2 – insert two associated EcENTITY records
        • Using SQL syntax
        • Using SQL Management Studio
    • SQL views
      • ERP data displayed dynamically in VE Tab
        • SQL view definition sample:
      • ERP synchronized enums
    • Logging
    • Using thumbnail image data
Powered by GitBook
On this page

Was this helpful?

  1. Data Interface - Reference Manual
  2. Data interface
  3. Data tables, relations

Stored procedure EcWriteEntity

helper procedure to write data into DI – mainly for bulks consisting of more than one EcENTITY row

parameter

type

direction

description

@EntName

nvarchar (100) Required

Input

Entity name – for description, see Table EcENTITY, field ‘name’

@BulkId

int Optional

InputOutput

Transfer request bulk_id – see remarks under Table EcENTITY description

  • use NULL value to create a first EcENTITY row;

the procedure creates a new bulk_id value and passes it back

  • for writing next EcENTITY rows (within one bulk) use the value which this procedure returned in this parameter when writing the first EcENTITY row

@EnClassID

nvarchar(10)

Optional

Input

Entity type

if omitted, ‘ITEM’ value is used

RetValue

bigint

ReturnValue

EcENTITY.id inserted

The source code:

CREATE PROCEDURE [dbo].[EcWriteEntity]
    @EntName NVARCHAR (100),
    @BulkID INT = -1 OUT,
    @EntClassID NVARCHAR (10) = 'ITEM'
AS
BEGIN
    -- check mandatory fields:
    IF @EntClassID IS NULL
    BEGIN
        RAISERROR('@EntClassID parameter is NULL', 16, 1);
        RETURN -1;
    END
    IF @EntName IS NULL
    BEGIN
        RAISERROR('@EntName parameter is NULL', 16, 1);
        RETURN -1;
    END
    -- SET NOCOUNT ON added to prevent extra result sets from interfering with SELECT statements:
    SET NOCOUNT ON;
    DECLARE @InsertedID BIGINT;
    DECLARE @result TABLE ( bid int, rid bigint );
    IF @BulkID IS NULL OR @BulkID < 0
    BEGIN
        INSERT INTO EcENTITY
        (ent_class_id, name, comm_dir, bulk_id)
        OUTPUT INSERTED.bulk_id, INSERTED.id INTO @result
        VALUES
        ( @EntClassID, @EntName, 1, ISNULL((SELECT MAX(bulk_id) FROM EcENTITY), 0) + 1);
    END
    ELSE
    BEGIN
        INSERT INTO EcENTITY
        (ent_class_id, name, comm_dir, bulk_id)
        OUTPUT INSERTED.bulk_id, INSERTED.ID INTO @result
        VALUES
        ( @EntClassID, @EntName, 1, @BulkID);
    END
    
    SET @BulkID = (SELECT TOP 1 bid FROM @result);
    SET @InsertedID = (SELECT TOP 1 rid FROM @result);
    RETURN @InsertedID;
END
PreviousTable EcLOGNextExporting data from a Vault

Last updated 11 months ago

Was this helpful?