0

I am running a Mysql procedure (MySQL 5.7) with following query :

DECLARE LAST_MAC BIGINT;

SET LAST_MAC = (SELECT COALESCE(MAX(MAC_ADDRESS), 0) FROM MAC_ADDRESS_TABLE) + 1;
      INSERT INTO MAC_ADDRESS_TABLE(MAC_ADDRESS)
      WITH TEMP (N)
      AS (
        VALUES (LAST_MAC)
        UNION ALL
        SELECT N+1 FROM TEMP WHERE N+1 < (LAST_MAC + CREATED)
      ) SELECT N AS MAC_ADDRESS FROM TEMP;

After running the query , i am getting following error :

right syntax to use near 'TEMP (N)
      AS (
        VALUES (LAST_MAC)
        UNION ALL
        SELECT N'

I have verified this query on DB2 and PostgreSQL . It is working fine . I want to know whether WITH AS clause is not supporting in MySQL procedure query ? How can i achieve this with any alternative methods ?

user2986042
  • 1,098
  • 2
  • 16
  • 37

1 Answers1

1

MySql does not support WITH clause. For more information about this refer the this How do you use the "WITH" clause in MySQL?

Jinesh Shah
  • 922
  • 10
  • 18