January 2, 2012 at 4:25 am
Hi,
INSERT INTO
Fireball_RawImportData.dbo.MultiSourceWorkQueueBond
(
GenericKey,
NewEntity
)
VALUES
(
dbo.GetGlobalUniqueEntityIdentifier('Fireball.dbo.Bond', CONVERT(INT, @SourceId)),
0
)
What exactly is this insert doing I'm confused?
ALTER FUNCTION [dbo].[GetGlobalUniqueEntityIdentifier]
(
@TableName VARCHAR(500),
@NativeUniqueIdentifier VARCHAR(500)
)
RETURNS VARBINARY(20) AS
BEGIN
DECLARE @PersistenceSourceId UNIQUEIDENTIFIER = dbo.GetConfigurationValue_GUID('Fireball', 'Fireball Persistence Source')
DECLARE @EntityType UNIQUEIDENTIFIER =
(
SELECT
Class.EntityType
FROM
dbo.MultiSourceTableClassMap TableClass
INNER JOIN
Fireball_MetaData.dbo.Class ON
Class.ClassId = TableClass.ClassId
WHERE
TableClass.TableName = @TableName
)
RETURN HASHBYTES(
'SHA1',
CAST(@PersistenceSourceId AS VARBINARY) +
CAST(@EntityType AS VARBINARY) +
CAST(@NativeUniqueIdentifier AS VARBINARY))
END
January 2, 2012 at 4:32 am
Whatβs confusing in it? The INSERT statement is calling a function that returns hash bytes (varbinary value). :Whistling:
January 2, 2012 at 4:40 am
The functions looks like its meant to create a new unique value based on the input table name and the value returned from another function call within it. The output which is a hash value i.e var binary format is then inserted as it into the table.
It seems the function is meant to do some sort of versioning based on the input data.
January 2, 2012 at 4:45 am
varbinary value yes... but i'm getting null value i dont know why π
January 2, 2012 at 4:49 am
ashuthinks (1/2/2012)
varbinary value yes... but i'm getting null value i dont know why π
What value are you using for @SourceID?
What do you get when you run this query?
SELECT
Class.EntityType
FROM
dbo.MultiSourceTableClassMap TableClass
INNER JOIN
Fireball_MetaData.dbo.Class ON
Class.ClassId = TableClass.ClassId
WHERE
TableClass.TableName = 'Fireball.dbo.Bond'
For better assistance in answering your questions, please read this[/url].
Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]
January 2, 2012 at 4:49 am
January 2, 2012 at 5:04 am
SELECT
Class.EntityType
FROM
dbo.MultiSourceTableClassMap TableClass
INNER JOIN
Fireball_MetaData.dbo.Class ON
Class.ClassId = TableClass.ClassId
WHERE
TableClass.TableName = 'Fireball.dbo.Bond'
this query giving me output : 2026ADB1-83FA-484A-AC95-2136AD94E638
I have taken @SourceId = 0 .
I'm not sure from where it is coming this parameter.
January 2, 2012 at 5:11 am
ashuthinks (1/2/2012)
varbinary value yes... but i'm getting null value i dont know why π
It will / may return NULLs if any of following is NULL:
@PersistenceSourceId
@EntityType
@NativeUniqueIdentifier
RETURN HASHBYTES(
'SHA1',
CAST(@PersistenceSourceId AS VARBINARY) +
CAST(@EntityType AS VARBINARY) +
CAST(@NativeUniqueIdentifier AS VARBINARY))
January 2, 2012 at 5:14 am
What does this return?
select dbo.GetConfigurationValue_GUID('Fireball', 'Fireball Persistence Source')
For better assistance in answering your questions, please read this[/url].
Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]
January 2, 2012 at 5:16 am
select dbo.GetConfigurationValue_GUID('Fireball', 'Fireball Persistence Source')
this returns:
5C72E9D7-90CB-462C-8D6F-F8AF4163A416
January 2, 2012 at 5:25 am
Seems ok so far:
DECLARE @NativeUniqueIdentifier VARCHAR(500) = '0'
DECLARE @PersistenceSourceId UNIQUEIDENTIFIER = '5C72E9D7-90CB-462C-8D6F-F8AF4163A416'
DECLARE @EntityType UNIQUEIDENTIFIER = '2026ADB1-83FA-484A-AC95-2136AD94E638'
DECLARE @ReturnValue VARBINARY(20)
SELECT @ReturnValue = HASHBYTES(
'SHA1',
CAST(@PersistenceSourceId AS VARBINARY) +
CAST(@EntityType AS VARBINARY) +
CAST(@NativeUniqueIdentifier AS VARBINARY))
SELECT @ReturnValue
What does this return?
select dbo.GetGlobalUniqueEntityIdentifier('Fireball.dbo.Bond', CONVERT(INT, '0')),
For better assistance in answering your questions, please read this[/url].
Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]
January 2, 2012 at 5:28 am
ashuthinks (1/2/2012)
select dbo.GetConfigurationValue_GUID('Fireball', 'Fireball Persistence Source')this returns:
5C72E9D7-90CB-462C-8D6F-F8AF4163A416
Chris's New Question: π
What does it return?
SELECT dbo.GetGlobalUniqueEntityIdentifier('Fireball.dbo.Bond', CONVERT(INT, @SourceId))
January 2, 2012 at 5:29 am
ChrisM@home (1/2/2012)
Seems ok so far:...
What does this return?
select dbo.GetGlobalUniqueEntityIdentifier('Fireball.dbo.Bond', CONVERT(INT, '0')),
Ooops. I missed by few minutes. π
January 2, 2012 at 5:33 am
Dev (1/2/2012)
ChrisM@home (1/2/2012)
Seems ok so far:...
What does this return?
select dbo.GetGlobalUniqueEntityIdentifier('Fireball.dbo.Bond', CONVERT(INT, '0')),
Ooops. I missed by few minutes. π
Haha! Thinking along the same lines π
For better assistance in answering your questions, please read this[/url].
Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]
Viewing 14 posts - 1 through 13 (of 13 total)
You must be logged in to reply to this topic. Login to reply