how to use UUID("00000000-0000-0000-0000-000000000000") in query under where

Common questions about 1C:Query language, Query builder tool and Data composition schema

#1
People who like this:0Yes/0No
Active user
Rating: 7
Joined: Jul 28, 2015
Company:

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.

 
#2
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

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"));

 
#3
People who like this:0Yes/0No
Active user
Rating: 7
Joined: Jul 28, 2015
Company:

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?

Edited: Mehmet Tuğrul SARIÇİÇEK - Aug 21, 2015 05:58 AM
 
#4
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

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

Download dcs.png (7.57 KB)
 
#5
People who like this:0Yes/0No
Active user
Rating: 7
Joined: Jul 28, 2015
Company:

Timofey Bugaevsky,

Thank you so much sir, thank you so much

 
#6
People who like this:0Yes/0No
Interested
Rating: 32
Joined: Oct 27, 2011
Company: Abaco Soluciones S.A.

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

 
#7
People who like this:0Yes/0No
Interested
Rating: 16
Joined: Dec 4, 2017
Company:

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

1C Company support team
 
#8
People who like this:0Yes/0No
Interested
Rating: 32
Joined: Oct 27, 2011
Company: Abaco Soluciones S.A.

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.

 
#9
People who like this:0Yes/0No
Interested
Rating: 16
Joined: Dec 4, 2017
Company:

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

1C Company support team
 
#10
People who like this:0Yes/0No
Interested
Rating: 32
Joined: Oct 27, 2011
Company: Abaco Soluciones S.A.

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

 
#11
People who like this:0Yes/0No
Interested
Rating: 16
Joined: Dec 4, 2017
Company:

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

1C Company support team
 
#12
People who like this:0Yes/0No
Interested
Rating: 32
Joined: Oct 27, 2011
Company: Abaco Soluciones S.A.

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.

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.