Main > Forum > 1C:Enterprise Platform > 1C:Query language and DCS > how to use UUID("00000000-0000-0000-0000-000000000000") in query under where

Forum

Search UsersRules
how to use UUID("00000000-0000-0000-0000-000000000000") in query under where
#1
Active user
Points:: 0
Joined:: Jul 28, 2015

Hi every one.

I have to use UUID("00000000-0000-0000-0000-000000000000") in a query under where condition. But when I was using, I got error. Could you help me please? I'm trouble in with this.

For example;

Code
SELECT
       SalesInvoices.Ref.CurrentAccounts,
       SalesInvoices.Variants
FROM
       Document.SalesInvoices.Variants AS SalesInvoicesVariants
WHERE
       SalesInvoicesVariants.Ref.Date >= &StartDate
       AND SalesInvoicesVariants.Ref.Date <= &EndDate
       AND SalesInvoicesVariants.Ref.CurrentAccount<> VALUE(Catalog.CurrentAccount.EmptyRef)
       AND SalesInvoicesVariants.SourceDocumentLineUnicID = 
                VALUE(UUID("00000000-0000-0000-0000-00000"))

Where is the problem ? How can I do that?

Could you help me please? Thank you.

Profile
#2
Guest
Points::
Joined::

Hello, Mehmet Tuğrul SARIÇİÇEK.

To make this work you should pass UUID("00000000-0000-0000-0000-00000") as a parameter and use this parameter in your query.

Code
SELECT
       SalesInvoices.Ref.CurrentAccounts,
       SalesInvoices.Variants
FROM
       Document.SalesInvoices.Variants AS SalesInvoicesVariants
WHERE
       SalesInvoicesVariants.Ref.Date >= &StartDate
       AND SalesInvoicesVariants.Ref.Date <= &EndDate
       AND SalesInvoicesVariants.Ref.CurrentAccount<> VALUE(Catalog.CurrentAccount.EmptyRef)
       AND SalesInvoicesVariants.SourceDocumentLineUnicID = &EmptyUUID

Code
Query.SetParameter("EmptyUUID", New UUID("00000000-0000-0000-0000-000000000000"));

Profile
#3
Active user
Points:: 0
Joined:: Jul 28, 2015

Timofey Bugaevsky,

Thank you so much sir, I'm very thankful for your interest but we want to fix this UUID in this query.

Is that possible sir?

Profile
#4
Guest
Points::
Joined::

If it's because you are using Data composition schema, set this parameter value in settings.

Profile
#5
Active user
Points:: 0
Joined:: Jul 28, 2015

Timofey Bugaevsky,

Thank you so much sir, thank you so much

Profile
#6
Interested
Points:: 15
Joined:: Oct 27, 2011

Is there any way to define empty UUID inside query without passing it as a parameter?

Profile
#7
Interested
Points:: 0
Joined:: Dec 4, 2017

Dear Alexey,

The rules according to which UUID values are compared in 1C:Enterprise queries are as follows:

- values of the UUID type are compared based on their values; the system ensures comparison result repetition in the same database only

- comparison of values of the UUID type with values of other types is not supported

Also, in the query code, there is no way to cast a string expression to the UUID type because the casting supports primitive and reference types only.

Thus, the only way to use the empty UUID in the query is to pass it as a query parameter as it was mentioned earlier.

Best regards,
Vladimir Gurov

Profile
#8
Interested
Points:: 15
Joined:: Oct 27, 2011

But what about some special function like UUID.EmptyValue(). Basically we need to eliminate empty values and there is no way to do it without pasing params.

Profile
#9
Interested
Points:: 0
Joined:: Dec 4, 2017

Dear Alexey,

We understand your point on having a method or a property that would indicate whether the UUID is empty as it is a typical functionality of UUID/GUID-related libraries. We can suggest the idea to our developers but cannot guarantee they accept it and implement it quickly.

Meanwhile, the only reasonable way to check whether the given UUID is empty is by using query parameters as it was mentioned earlier.

A more sophisticated method to compare UUID values in your 1C:Enterprise queries is by using temporary tables. You create a temporary table for the data your want to compare from one side, without a UUID column, but with a string column instead, and fill the table with data. You use your 1C:Enterprise script to cast UUID values to string values in this column. Similarly, you create a temporary table for the data you want to compare from the other side and fill it with data. Ultimately, in your 1C:Enterprise query you compare string values in the tables' columns and fetch data from the tables.

For instance, if your task is to locate empty UUIDs, you can create a single temporary table and compare its UUID-representing string column values with the "00000000-0000-0000-0000-00000" string in your query.

Best regards,
Vladimir Gurov

Profile
#10
Interested
Points:: 15
Joined:: Oct 27, 2011

Please make this topic a feature request. I think many developers will benefit from this possibility.

Profile
#11
Interested
Points:: 0
Joined:: Dec 4, 2017

Dear Alexey,

We have forwarded this feature request to our developers. We agree that this feature would be beneficial, though let me repeat that we cannot guarantee that this feature will be implemented and when it will be implemented.

Best regards,
Vladimir Gurov

Profile
#12
Interested
Points:: 15
Joined:: Oct 27, 2011

Vladimir, I have a great luck of having implemented fair amount of my requirements over the years. So I am not expecting it to happen any time soon, but it is always great to see something implemented that you have asked some time ago. Keeping my fingers crossed.

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.