Thiru
Thiru

Reputation: 251

Getting Error - Phrase or option conflicts with previous phrase or option. (277) - Progress 4GL

I am using following dynamic query to fetch the data from a table. But I am getting compilation error "Phrase or option conflicts with previous phrase or option. (277)". Not sure where I am making mistakes and how to fix it. Please help me modifying the below example query.

define variable hbuffer as handle    no-undo.
define variable hQuery  as handle    no-undo.
define variable cQuery  as character no-undo.

define temp-table tt_table no-undo           
field tt_week1    as character label "Week1"
.

create buffer hbuffer for table "<table>".
cQuery = "for each <table> no-lock ".
create query hQuery.
hQuery:set-buffers(hbuffer).
cQuery = cQuery + ":".
hQuery:query-prepare(cQuery).
hQuery:query-open().
if hQuery:query-open() then
do:
   do while hQuery:get-next():
      create tt_table.
      assign tt_week1 = hbuffer::qty[1] /*field name qty data type is deci-10[52].*/
      .
   end.
end.

for each tt_table :
   disp tt_week1.
end.

Upvotes: 0

Views: 289

Answers (3)

Stefan Drissen
Stefan Drissen

Reputation: 3379

As pointed out by Mike, your attempt to reference the extent is throwing the error, a dynamic extent reference uses round parentheses (and works fine with shorthand):

hbuffer::qty(1)

Additionally:

  1. you do not need to terminate your query with a :
  2. get-next() defaults to no-lock
  3. you are opening your query twice
// some demo data

define temp-table db no-undo
   field qty as decimal extent 7
   .

create db. db.qty[1] = 1.
create db. db.qty[1] = 2.

// the question

define variable hb      as handle    no-undo.
define variable hq      as handle    no-undo.
define variable cquery  as character no-undo.

define temp-table tt no-undo           
    field week1 as character label 'Week1'
    .

create buffer hb for table 'db'.
cquery = substitute( 'for each &1', hb:name ).
create query hq.
hq:set-buffers( hb ).
if hq:query-prepare( cquery ) and hq:query-open() then do:

    do while hq:get-next():
        create tt.
        tt.week1 = hb::qty(1). // <-- round parentheses
    end.

end.

for each tt:
    display tt.week1.
end.

https://abldojo.services.progress.com/?shareId=626aff353fb02369b2545434

Upvotes: 2

Mike Fechner
Mike Fechner

Reputation: 7192

The problem is with the shorthand syntax here:

hbuffer::qty[1]

If you replace this with:

hbuffer:buffer-field ("qty"):BUFFER-VALUE (1)

it'll work (until the point, that Peter made with the undefined field tt_week1. I did not find any reference saying if or if not the shorthand syntax should work with EXTENT fields. It may be worth checking that with Progress tech-support.

So this will bring you further:

assign tt_data = hbuffer:buffer-field ("qty"):BUFFER-VALUE (1) /*field name qty data type is deci-10[52].*/

Upvotes: 2

nwahmaet
nwahmaet

Reputation: 3909

The compile error should tell you the line the error is coming from.

In the code snippet, you haven't define a tt_week field anywhere.

In general, if you want to assign a (temp)table field, you should use the table.field notation; the AVM can often figure out your intent, but not being specific is error-prone.

Upvotes: 2

Related Questions