How to assign question mark "?" to a mandatory fie

Posted by Admin on 20-Feb-2009 00:56

Hi all,

Does anyone know how to assign the question mark "?" to a mandatory field using dynamic object. Below is my code.

define varaible hbDomMstr as handle no-undo.

create buffer hbDomMstr for table "dom_mstr".

do transaction:

hbDomMstr:buffer-create().

hbDomMstr:buffer-field("dom_domain"):buffer-value = "?".

end.

/* Note: dom_domain is a mandatory field of table dom_mstr */

When I ran the code it gave me a progress error as shown below. What I can't understand is that I assigned a value "?" to the field other than a unknown value ?, why it interpret "?" as unknown value? And how could I assign the "?" to a mandatory database field? Thanks in advance.

"** dom_domain is mandatory, but has a value of ?. (275)"

All Replies

Posted by kevin_saunders on 20-Feb-2009 03:16

The ? is the unknown value in Progress.

Posted by Admin on 20-Feb-2009 03:25

yes, it's true. But I want to assign the character "?" to the field, not the unknown value ?.

It works fine with following code.

create dom_mstr.

assign dom_domain = "?".

But I don't know how to use dynamic object to assign the value "?" to a mandatory database field.

Posted by kevin_saunders on 20-Feb-2009 03:28

Assuming dom_domain is character, you can try:

hbDomMstr:buffer-field("dom_domain"):buffer-value = " '?' ".

Posted by Admin on 20-Feb-2009 03:33

But that assigns " '?' " to the field, not "?". So you end up with single quotes and spaces in the field value.

I also tried to assign CHR(63). It seems to be an internal (mis-)interpretation in the buffer object. "~?" does not work either.

I'd consider it a bug and log it with the support.

Posted by Håvard Danielsen on 20-Feb-2009 08:11

> But I don't know how to use dynamic object to assign the value "?" to a mandatory database field.

Note that you would have the same problem with a non mandatory field. The difference is that with a non mandatory field the unknown value will end up in the database while a mandatory field does not allow the unknown value.

The only workaround I can think of is to assign the "?" to a variable first:

c = "?".

hbDomMstr:buffer-field("dom_domain"):buffer-value = c.

Also note that the general recommendation is to avoid storing "?" in a Progress database because a display and assign will make it into an unknown value.

Many applications also stringifies unknown values to pass them as parameters when the parameter is passed using comma separated values or some other concatenated form (since you cannot append ? to a string).

Posted by Admin on 20-Feb-2009 08:39

Bug assigning "?" to a dynamic buffer field reference is not consistent with the static assignment.

ASSIGN table.field = ? AND

ASSIGN table.field = "?"

have different results (the latter one results in the ? as a literal. With dynamic references "?" is not interpreted as a literal. It's interpreted as ?.

By the way, your suggestion does not work (in 10.2A). Try this:

The last resort I could think of might be a buffer-copy and using only the mandatory field that should receive the ? in the field list. Haven't tried that yet.

Posted by Håvard Danielsen on 20-Feb-2009 09:26

> Bug assigning "?" to a dynamic buffer field reference

is not consistent with the static assignment.

ASSIGN table.field = ? AND

ASSIGN table.field = "?"

have different results (the latter one results in the

? as a literal. With dynamic references "?" is not

interpreted as a literal. It's interpreted as ?.

Yes, I'm aware of the differences. I'm just warning that the "?" as a single value in a progress database field often cause issues later. I guess having it in a mandatory field actually is less risky though, since it wont inadvertently be changed to an unknown value.

> By the way, your suggestion does not work (in 10.2A).

Try this:

Interesting... It works on a non-mandatory field, but that was of course not the problem here.

>

The last resort I could think of might be a

buffer-copy and using only the mandatory field that

should receive the ? in the field list. Haven't tried

that yet.

buffer-copy might work. I suspect the problem has to do with the fact that buffer-value datatype is resolved at runtime, similar to input-value.

This thread is closed