0

I am trying the following syntax to assign current date to one HANA variable for further processing. I am getting an error

scalar variable is not allowed

DAY1 is declared as NVARCHAR(8) .

 DAY1 := SELECT to_nvarchar ((current_date),'YYYYMMDD') from dummy ;

Please provide some input .

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
SQL_NOVICE
  • 35
  • 1
  • 7

1 Answers1

0

You could also do this:

declare DAY1 nvarchar(8);

SELECT to_nvarchar (current_date,'YYYYMMDD') into DAY1 from dummy ;

however, if the direct assignment works on your revision, go with that as you safe the parsing & execution of the above SQL statement.

Lars Br.
  • 9,949
  • 2
  • 15
  • 29
  • Hi Lars , SELECT statement doesn't seem to work here . I guess , SELECT is expecting table type as I am getting a message "Scalar Type Not allowed " . What is your view in this ? – SQL_NOVICE Sep 30 '15 at 18:08
  • What error did you get? This definitively works in SQLScript; but not in the SQL Editor - you have to put it into a procedure/function (or a DO BEGIN block starting with SPS 10) to get the SQLScript context. – Lars Br. Oct 04 '15 at 22:43