Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.


I have no data in a table,

$ dbisql -c "uid=sadb;pwd=sadb;eng=ftnode_sa;links=tcpip(host=;port=49153);LOG=conn.log;dbn=ftnode_sa" "select * from test1"
x y 

(0 rows)

yet when I run a hash query over the results, I get a hash value:

$ dbisql -c "uid=sadb;pwd=sadb;eng=ftnode_sa;links=tcpip(host=;port=49153);LOG=conn.log;dbn=ftnode_sa" "select hash(list(hash_val,'' ORDER BY hash_val), 'MD5') as hash_val from (select hash( x||y, 'MD5') as hash_val from (select x,y from test1) as ht) as ht"

When I perform the same test in PostgreSQL and Oracle then no hash value is returned, which is as expected. Note, when a table does have row data then the hash value matches to Oracle and PostgreSQL, but not so with empty tables.

Could somebody suggest why ?


asked 18 Sep '17, 23:11

bluefrog's gravatar image

accept rate: 0%

edited 18 Sep '17, 23:12

It has to do with the LIST aggregate you are using as argument for the HASH function.

SELECT LIST(null) by definition returns an empty string, and that prevents HASH from returning null.

(The hash value in your sample is that of an empty string.)

permanent link

answered 19 Sep '17, 06:08

Volker%20Barth's gravatar image

Volker Barth
accept rate: 34%

edited 19 Sep '17, 07:00

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 18 Sep '17, 23:11

question was seen: 1,508 times

last updated: 19 Sep '17, 07:00