Re: SQL RPGLE cursor delete from view? -204



Charles Wilt wrote:

In article <Uk2tc.12022$be.10695@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>, jonball@xxxxxxxxxxxxxx says...

Stan The Man wrote:


this is just a "temporary" file in memory
maybe i dont have my verbage correct
i just want to delete the record in my "selected set" in you will
i could do this in RPG, but i wanted to use SQL and do it all in 1 smooth step

this is just a read-only and print application

Whatever, you just can't delete from a cursor that joins multiple files.



Even if you could do the delete from the cursor, you wouldn't want to since as I read your post you simply want to remove a record from the current result set without affecting the actual data.

I'm not sure he is really only trying to delete from the result set, although it's possible; the language is a little opaque. In any event, a DELETE operation in SQL definitely is the wrong way to do it.

Your suggestion below about populating a temporary table below, then working with its contents as the result set, possibly would work for the original poster.


Deleting via a cursor deletes the row in the underlying table.

A cursor and/or a view is simply a window or an access path into the original table(s).


To do this with SQL, you'll need to do the same thing you'd need to do with RPG....build an actual temporary work file.

Depending on the version of OS/400 you are running:

create table QTEMP/MYWORKFILE <...>

<or>

declare global temporary table <...>


HTH,
CHarles

.



Relevant Pages

  • Re: Opinions on approach, please...
    ... Code conversion is much more tricky. ... to update more than 32k records without a commit in-between. ... I advise you to do cursor definitions on working storage). ... I don't want to see ANY SQL code in them. ...
    (comp.lang.cobol)
  • Re: Opinions on approach, please...
    ... to update more than 32k records without a commit in-between. ... Translating the above to SQL it would be as follows. ... I advise you to do cursor definitions on working storage). ... exec sql open file-a end-exec. ...
    (comp.lang.cobol)
  • Re: Millions of Delete Statements
    ... You mention a cursor. ... Others have mentioned batching the commands, ... so I will throw out one that is less good (executing them ... get the whole SQL statement I don't know of another way to do it). ...
    (comp.databases.ms-sqlserver)
  • Re: Daten schnell lesen =?ISO-8859-1?Q?=28Gegenst=FCck_zu_BU?= =?ISO-8859-1?Q?LK_INS
    ... Damit meinte ich eine direkte Verarbeitung mittels ... 10maligem FETCH (näheres findest Du unter DECLARE CURSOR). ... Ein DataReader in einer SQL Server Assembly ist ... Anweisungen auf dem Server erledigt werden kann. ...
    (microsoft.public.de.sqlserver)
  • Re: Migration recommendations; PRELIMINARY INQUIRY
    ... there are massive advantages to moving to SQL as you are ... A lot of legacy applications have grown up using a cursor based ... To join/leave the list, search archives, change list settings, * ... Authorised and regulated by the Financial Services Authority. ...
    (comp.sys.hp.mpe)