Path: utzoo!mnetor!uunet!husc6!bloom-beacon!gatech!hao!oddjob!gargoyle!ihnp4!ihuxy!chapman From: chapman@ihuxy.ATT.COM (Ralph Chapman) Newsgroups: comp.databases Subject: Re: Informix query Message-ID: <2327@ihuxy.ATT.COM> Date: 6 Jan 88 16:01:53 GMT References: <3072@ihlpf.ATT.COM> <3890001@hpcmmb.HP.COM> <3216@ihlpf.ATT.COM> <60@coot.AUSTIN.LOCKHEED.COM> Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 46 Summary: SQL is set-oriented and non-procedural In article <60@coot.AUSTIN.LOCKHEED.COM> Chris Wood writes: > In article <3216@ihlpf.ATT.COM>, lukas@ihlpf.ATT.COM (00704a-Lukas) writes: > > 4) Difficulty (outside of perform) of doing that most basic of > > database applications: that of cycling through the rows, adding, > > deleting, modifying as you go. > > I would like to know how to go about this also. I am using ORACLE > and would like to do this. ... > > Is there some underlying mathematical "relational purist" reason why such > procedural constructs are lacking in relational implementations? ... > > Why Can't relational systems do this? Or better yet, is there a > SQL/Relational system out there that does? SQL is set-oriented-- There is no implicit ordering in a plain vanilla "set". SQL insists on operating on an entire set all at once (conceptually, anyway), not an element at a time. This is an instance of "non-procedural" programming style-- It's supposed to SAVE you the TROUBLE of spelling out a procedure to do what you want. :-) (Not surprisingly, it's easier for non-programmers to learn this style than for programmers (of 3rd and previous generation languages) to learn it.) So you have to either: (1) formulate an "UPDATE ... WHERE" statement that selects the appropriate records a priori and updates just that subset (don't forget that you can nest SQL statements, in case the subset can't be specified by a boolean expression in a WHERE clause, e.g.: UPDATE ... WHERE field IN ( SELECT ... and so on ) (2) (in Oracle) make yourself an IAF application; that will let you go through the records one at a time. Oracle has a command that will make a quick-and-dirty IAF application for a single table. I can't figure out why SQL DBMS vendors don't supply a browser program that will loop through a SELECTed set, as you described. (Maybe I'll write one someday.) --Ralph Chapman ihnp4!ihuxy!chapman