joereynolds / sql-lint

An SQL linter
MIT License
437 stars 40 forks source link

Unable to lint query: OPEN dmsShipmentCursor; #254

Open martinbos opened 1 year ago

martinbos commented 1 year ago

Error on: OPEN dmsShipmentCursor;

sql looks like:

drop procedure if exists fixDMSDeclarations// create procedure fixDMSDeclarations() DETERMINISTIC begin declare done int default 0; declare shipmentOID varchar(40); declare backupShipmentOID varchar(40); declare itemOID varchar(40); DECLARE itemCounter INT DEFAULT 0;

declare dmsShipmentCursor cursor for
    SELECT OID
    FROM cus_nl_dms_cusdec_good_shp
    WHERE
        `DMS_CUSDEC_GOOD_SHIP_OID` IS NULL
        AND dms_cusdec_good_ship_oid_b IS NOT NULL
        AND dms_cusdec_good_ship_oid_b IN (SELECT oid FROM cus_nl_dms_cusdec);

declare dmsItemCursor cursor for
    SELECT OID, gov_agncy_gdsitm_oid_b
    FROM cus_nl_dms_gvagncy_gds_itm
    WHERE
        GOV_AGNCY_GDSITM_OID IS NULL
        AND GOV_AGNCY_GDSITM_INDEX IS NULL
        AND gov_agncy_gdsitm_oid_b IS NOT NULL
        AND gov_agncy_gdsitm_oid_b IN (SELECT oid FROM cus_nl_dms_cusdec_good_shp)
    ORDER BY gov_agncy_gdsitm_oid_b;

declare continue handler for not found set done = 1;

OPEN dmsShipmentCursor;
dmsShipmentLoop: loop

    fetch next from dmsShipmentCursor into shipmentOID;
    if done = 1 then
        leave dmsShipmentLoop;
    end if;
joereynolds commented 3 months ago

Hi, what dialect are you using here? MySQL?

martinbos commented 3 months ago

Not sure. I saw similar coding in other scripts, so i used it to create this script. (Already a while ago)