Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. 4GL horror

4GL horror

Scheduled Pinned Locked Moved The Weird and The Wonderful
databasetutorial
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Andrew Carrell
    wrote on last edited by
    #1

    Here's one that's created in Informix 4GL (which is a horror in itself) on how to validate a from-and-to range to make sure it has no overlaps in the DB:

    FUNCTION verify_location()

    DECLARE c\_det\_cur CURSOR FOR 
    	SELECT frerc.from\_loc\_id, frerc.to\_loc\_id
    	FROM frerc
    		WHERE frerc.dc\_id = m\_i\_frerc\_rec.dc\_id
    		  AND frerc.whse\_id = m\_i\_frerc\_rec.whse\_id
    
    # check if select worked correctly
    IF SQLCA.SQLCODE <> 0
    THEN
    	#...
    	RETURN TRUE, 0
    END IF
    
    OPEN c\_det\_cur 
    IF SQLCA.SQLCODE <> 0
    THEN
    	#...
    	RETURN TRUE, 0
    END IF
    
    FETCH c\_det\_cur INTO m\_from\_loc, m\_to\_loc
    
    IF m\_modify = 0 AND m\_i\_frerc\_rec.from\_loc\_id >= m\_from\_loc
    	AND m\_i\_frerc\_rec.from\_loc\_id <= m\_to\_loc 
    THEN
    	CALL sh\_err\_msg("S2096")
    	LET m\_from = 1
    	LET m\_modify = 1
    END IF
    
    IF m\_modify = 0 AND m\_i\_frerc\_rec.to\_loc\_id >= m\_from\_loc
    	AND m\_i\_frerc\_rec.to\_loc\_id <= m\_to\_loc 
    THEN
    	CALL sh\_err\_msg("S2097")
    	LET m\_from = 1
    	LET m\_modify = 1
    END IF
    
    IF m\_from\_loc >= m\_i\_frerc\_rec.from\_loc\_id
    	AND m\_from\_loc <= m\_i\_frerc\_rec.to\_loc\_id
    THEN
    	CALL sh\_err\_msg("S2097")
    	LET m\_from = 1
    	LET m\_modify = 1
    END IF
    
    IF m\_modify = 0 AND m\_to\_loc >= m\_i\_frerc\_rec.from\_loc\_id
    	AND m\_to\_loc <= m\_i\_frerc\_rec.to\_loc\_id
    THEN
    	CALL sh\_err\_msg("S2096")
    	LET m\_to = 1
    END IF 	
    
    IF m\_to = 0 AND 
    	m\_from = 0
    THEN
    	WHILE SQLCA.SQLCODE = 0
    		FETCH c\_det\_cur INTO m\_from\_loc, m\_to\_loc
    
    		IF m\_i\_frerc\_rec.from\_loc\_id >= m\_from\_loc
    			AND m\_i\_frerc\_rec.from\_loc\_id <= m\_to\_loc 
    		THEN
    			CALL sh\_err\_msg("S2096")
    			LET m\_from = 1
    			EXIT WHILE
    		END IF
    
    		IF m\_i\_frerc\_rec.to\_loc\_id >= m\_from\_loc
    			AND m\_i\_frerc\_rec.to\_loc\_id <= m\_to\_loc 
    		THEN
    			CALL sh\_err\_msg("S2097")
    			LET m\_from = 1
    			EXIT WHILE
    		END IF
    
    		IF m\_from\_loc >= m\_i\_frerc\_rec.from\_loc\_id
    			AND m\_from\_loc <= m\_i\_frerc\_rec.to\_loc\_id
    		THEN
    			CALL sh\_err\_msg("S2097")
    			LET m\_to = 1
    			EXIT WHILE
    		END IF
    	
    		IF m\_to\_loc >= m\_i\_frerc\_rec.from\_loc\_id
    			AND m\_to\_loc <= m\_i\_frerc\_rec.to\_loc\_id
    		THEN
    			CALL sh\_err\_msg("S2096")
    			LET m\_from = 1
    			EXIT WHILE
    		END IF
    
    	END WHILE
    END IF
    
    LET m\_modify = 0
    

    END FUNCTION

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups