Hi!
Got a stored procedure that looks something like this;
I would like to change "transnr" in CREATE TEMP... to a "id INTEGER AUTO_INCREMENT" and then adding a PRIMARY KEY(ID).
The problem is;
How do I write the INSERT INTO...??
Thanks in advance!
/Hylsan
Got a stored procedure that looks something like this;
Code:
CREATE TEMPORARY TABLE tmp_skatt (transnr INTEGER, ewc VARCHAR(50), vikt DOUBLE);
/* Plockar ut "allt in" */
insert into tmp_skatt
select trans2009.transnr, 'Allt in', sum(trans2009.nettovikt) vikt from trans2009 inner join artikel on trans2009.artikel = artikel.artikel where
trans2009.transtid between dat1 and dat2 and trans2009.kund='101' and trans2009.status='2' and trans2009.artikel between '1000' and '9999'
and artikel.ewc like '1-%-%'
group by artikel.sandstatus;
/* Plockar ut "uppstått inom anläggning" */
insert into tmp_skatt
select trans2009.transnr, 'Uppstått inom anläggningen', sum(trans2009.nettovikt) vikt from trans2009 inner join artikel on trans2009.artikel = artikel.artikel where
trans2009.transtid between dat1 and dat2 and trans2009.kund='101' and trans2009.status='2' and trans2009.artikel between '1000' and '9999'
and artikel.ewc like "2-%-%"
group by artikel.sandstatus;
select * from tmp_skatt;
/* Rensar ut i tmp-tabellerna */
DROP TEMPORARY TABLE tmp_skatt;
I would like to change "transnr" in CREATE TEMP... to a "id INTEGER AUTO_INCREMENT" and then adding a PRIMARY KEY(ID).
The problem is;
How do I write the INSERT INTO...??
Thanks in advance!
/Hylsan