Skip to main content

Syntax error when using DECLARE within embedded SQL (WINDOWS)

  • May 10, 2021
  • 3 replies
  • 0 views

I am trying to add some logic to my embedded sql by using an sql variable

EXEC SQL RELAXED
    DECLARE @PARM1 AS INTEGER
    SELECT
        CUSTOMER_KEY
    INTO
        :CUSTOMER_KEY
    FROM [db_owner].[CUSTFILE]
    WHERE ( CUSTOMER_KEY = CUSTOMER-KEY)
    ORDER BY CUSTOMER_KEY
END-EXEC

The compiler reports;

-->ERROR: syntax error at AS

Compiler switches are;

ccbl32 -Di -Zd -w -Zl -Zr -Pr -Ps -La -Li -Lf 

Is there anyway around this?

3 replies

Claudio Contardi
Forum|alt.badge.img+2

I am trying to add some logic to my embedded sql by using an sql variable

EXEC SQL RELAXED
    DECLARE @PARM1 AS INTEGER
    SELECT
        CUSTOMER_KEY
    INTO
        :CUSTOMER_KEY
    FROM [db_owner].[CUSTFILE]
    WHERE ( CUSTOMER_KEY = CUSTOMER-KEY)
    ORDER BY CUSTOMER_KEY
END-EXEC

The compiler reports;

-->ERROR: syntax error at AS

Compiler switches are;

ccbl32 -Di -Zd -w -Zl -Zr -Pr -Ps -La -Li -Lf 

Is there anyway around this?

Good morning, blinkok

Does it work if you remove the "AS" ?

DECLARE @PARM1 INTEGER

See: https://bit.ly/3heDgeN

Claudio Contardi
Product Support Engineer, Senior
Micro Focus


  • May 12, 2021

Good morning, blinkok

Does it work if you remove the "AS" ?

DECLARE @PARM1 INTEGER

See: https://bit.ly/3heDgeN

Claudio Contardi
Product Support Engineer, Senior
Micro Focus

Unfortunatley it still abends with 'Syntax errror at int'


Stephen Hjerpe
  • Participating Frequently
  • May 12, 2021

Unfortunatley it still abends with 'Syntax errror at int'

This is not supported.  I believe all variables need to be defined as part of the SQL DECLARE section of Working-Storage.