cancel
Showing results for 
Search instead for 
Did you mean: 

SAP HANA CLOUD syntax error

kimkeunho
Explorer
0 Kudos

Hi. I'm trying to create a table in hana cloud. According to hana cloud sql reference, "on update" should work fine, but it keeps generate syntax error.

My question is, how can I create a table that automatically updates a certain column, using "on update" query? (in this case, it should change REG_DATE when the row is updated).

yogananda
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi kimkeunho

Kindly paste the query in below to see once.

Accepted Solutions (0)

Answers (2)

Answers (2)

kimkeunho
Explorer
0 Kudos

Many thanks. That works. So...since your answer also excluded the <on update current_timestamp> part, is it safe to assume that there are no such method to implement that functionality?

kimkeunho
Explorer
0 Kudos

In my original database (which is mariadb), the DDL for the table is like the following statments.

CREATE TABLE `app_info` (

`APP_INFO_NDX` bigint(20) NOT NULL ',

`APP_OS` varchar(100) NOT NULL COMMENT,

`APP_VER` varchar(100) NOT NULL COMMENT,

`APP_DETAIL` varchar(1000) DEFAULT NULL,

`USE_YN` varchar(20) NOT NULL COMMENT,

`APP_REG_DT` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() ,

`ATTACH_GRP_NO` bigint(20) NOT NULL,

PRIMARY KEY (`APP_INFO_NDX`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3

The problematic point is written in bold. It seems like hana db does not support <on update current_timestamp> query, which is available in mariadb. I want it working properly in hana cloud as well, because I need to know the last modification timestamp of updated record rows. I've tried to use a trigger, but it is not working in hana db. Any suggestions or ideas to solve this problem?

yogananda
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi kimkeunho

CREATE TABLE app_info (
APP_INFO_NDX bigint NOT NULL,
APP_OS varchar(100) NOT NULL,
APP_VER varchar(100) NOT NULL,
APP_DETAIL varchar(1000) DEFAULT NULL,
USE_YN varchar(20) NOT NULL,
APP_REG_DT timestamp NOT NULL DEFAULT current_timestamp ,
ATTACH_GRP_NO bigint NOT NULL,
PRIMARY KEY (APP_INFO_NDX)
)