Please free me from this - I'll PAY

Das Goravani das at
Tue Jan 30 18:07:53 EST 2018

> On Jan 30, 2018, at 1:30 PM, Bastiaan Olij <bastiaan at> wrote:
> I think you're biggest issue with what you've been doing so far is using
> a separate statement object because it screws up your scope. This
> approach works because begin statement/end statement does one thing
> different then calculating a string and sending that to $prepare or
> $execdirect. Statement blocks retains the scope of where the "sta:"
> command is executed.
> So seeing your code runs in a method of your table class, ergo runs
> within the scope of your list, $cinst points to the row you're trying to
> insert into your database and you're query works.
> When you do:
> Calculate lvSQL as '<your insert statement goes here>'
> Do tstaobj.$prepare(lvSQL)
> The SQL is simply text being send to $prepare. It is now parsed when
> inside of tstaobj and $cinst now points to tstaobj, your row has now
> fallen outside of the scope of the executing method and you're query
> can't be parsed, hense your error.


This is getting crazy.  The following code now works inside a table: 

Begin statement
Sta: {INSERT INTO customers ("cust_id","cust_firstname",”cust_lastname”..."cust_bizname”) 
VALUES (nextval('seq_cust_id'),@[$cinst.cust_firstname]...@[$cinst.cust_bizname])  
RETURNING ('cust_id')}
End statement
Do tstaobj.$prepare() Returns lReturnFlag
Do tstaobj.$execute() Returns lReturnFlag

The above Statement Object is a Task variable which I used to assign into the row which is the table. 

The above code inserts a record with the nextval value put in correctly. 

I am now down to “How to fetch that value back” for display on the screen. 

I thought statement objects were universal as the manual implies. Because the manual suggests using Task variables as your session and statement objects so that you’ll have easy access to them everywhere. Sounded good to me. 

It sounds like you are saying that statement objects have scope, or can cause other things to fall out of scope. 

I am almost afraid to try your method, because I’m so burnt out on this.  

Someone sent me a way to fetch my value but it’s not working. 

It looks like this: 

Do tstaobj.$fetchinto($cinst.cust_id) Returns lReturnFlag

If it worked I’d be on my way.  I just want to add the sequence (done) and know what it is back in my window. That’s all. 

Any complex things I can avoid I would rather avoid. 

Are you sure I can’t use my universal statement object?  As the manual suggests?  

More information about the omnisdev-en mailing list