Buffer-copy with Handle

Posted by atuldalvi123 on 17-May-2016 04:09

Hi,

How can I use except with buffer-copy with handle.

eg.

hBuffer1:BUFFER-COPY(hBuffer).

both are handle for 1 table and have to create the same record except few fields but EXCEPT is not working for handle. What is the correct syntax ?

All Replies

Posted by Kondra Mohan Raju on 17-May-2016 04:37

try this syntax:

buffer-copy Source-Buffer except fields to Target-Buffer.

Posted by AdrianJones on 17-May-2016 04:44

Syntax  BUFFER-COPY( source-buffer-handle  

  [ , except-list [ , pairs-list [ , no-lobs ] ] ] )

source-buffer-handle

An expression that evaluates to the source buffer handle.

except-list

A character expression that evaluates to a comma-separated list of field names to be excluded from the copy.

so you want...

hBuffer1:BUFFER-COPY(hBuffer,"FieldToExlcude1,fieldtoExlcude2").

Posted by atuldalvi123 on 17-May-2016 04:50

Thanks Guyz

I am having below code

ASSIGN

      cString   = "FOR EACH " + ipcTable + " NO-LOCK"

      cWhereCls = "WHERE GIPR-ID = " + ipioldGIPRID  

      cString   = cString + " " + cWhereCls

      .

 CREATE BUFFER hbuffer  FOR TABLE ipcTable.

 CREATE BUFFER hbuffer1 FOR TABLE ipcTable.

 CREATE QUERY hquery.

 hquery:SET-BUFFERS(hBuffer).

 hquery:QUERY-PREPARE(cString).

 hquery:QUERY-OPEN.

 hquery:GET-FIRST.

 REPEAT:

     IF hquery:QUERY-OFF-END THEN LEAVE.

     DO TRANSACTION:

       hquery:GET-CURRENT(EXCLUSIVE-LOCK).

       hBuffer1:BUFFER-CREATE().

       hBuffer1:BUFFER-COPY(hBuffer, "GIPR-ID").

       ASSIGN hBuffer1:BUFFER-FIELD("GIPR-ID"):BUFFER-VALUE = INT(ipinewGIPRID).

       hBuffer:BUFFER-DELETE().

       hBuffer:BUFFER-RELEASE().

     END.

     hquery:GET-NEXT.

 END.

before creating record i want to check if the record is already exist to avoid index issue . How do i achieve this ?

Posted by smat-consulting on 17-May-2016 08:04

I don't understand why you copy the record, if all you're doing is changing the giprid...

If you have any other unique index on this table,a side of one with giprid, you might run into problems,a s you're trying to create a second identical record.

But, to answer your question: if giprid is the only unique field(sequence) in the table, you can simply do a dynamic query try to find a record with that giprid before the logic currently in your procedure...

Posted by smat-consulting on 17-May-2016 08:10

Also, just for completeness sake (incase this was not a reduced excerpt):

 you're missing the delete query and delete buffer statements at the end of your procedure.

 And you're not explicitly dealing with error-situations (like the record can't blocked exclusively). Progress does a good job in default error-handling. I usually prefer to deal with it explicitly, however. That way, I assure it does what I think it does, I see in the code that I need to create a test-case for it, and months down the line,w hen I (or somebody else) looks at it, they have a better chance to know what the original intent was...

This thread is closed