Skip to main content



      Home
Home » Archived » EGL Development Tools » How do I know if a GET succeeded in fetching the record?
How do I know if a GET succeeded in fetching the record? [message #811661] Fri, 02 March 2012 12:04 Go to next message
Eclipse UserFriend
I'm posting some code to make my point, but it's really a more general question.

function fetchSomeField(someOtherRecordID bigInt) returns (Timestamp?)
  someRecord1 SOMERECORD;
  get someRecord1 from ds using (someOtherRecordID) with #sql{
    select * from someTable where OTHERRECORD_ID = ?
  };
  if (someRecord1 != null) <-- Fails, it's not null, even though such record doesn't exist 
    return (someRecord1.timestampField1);
  else
    return (null);
  end
end


How do I know if the GET action did actually fetch a record or not?
Re: How do I know if a GET succeeded in fetching the record? [message #811740 is a reply to message #811661] Fri, 02 March 2012 14:18 Go to previous messageGo to next message
Eclipse UserFriend
In the meanwhile, I'm using this:

function fetchSomeField(someOtherRecordID bigInt) returns (Timestamp?)
  someRecord1 SOMERECORD;
  rs SQLResultSet?;
  open rs from ds using(someOtherRecordID) with #sql{
    select * from someTable where OTHERRECORD_ID = ?
  };
  if (rs.setNext())
    get someRecord1 from rs;
    return (someRecord1.timestampField1);
  else
    return (null);
  end
end


It looks quite right actually! Smile
Re: How do I know if a GET succeeded in fetching the record? [message #812398 is a reply to message #811661] Sat, 03 March 2012 14:04 Go to previous messageGo to next message
Eclipse UserFriend
Hi

The first code you wrote was almost correct. You are checking someRecord1 for null, but you did not define it as nullable. Without a ? the initial value is an empty record and you can't even assign null to it.

someRecord1 SOMERECORD;
should be:
someRecord1 SOMERECORD?;

Adding the ? to the declaration sets someRecord1's initial value to null. If no record is returned from the get it will remain null.

The second example accomplishes the same thing.

regards,
Joe
Re: How do I know if a GET succeeded in fetching the record? [message #813815 is a reply to message #812398] Mon, 05 March 2012 13:39 Go to previous message
Eclipse UserFriend
I forgot about nullable semantics. Thanks, Joe!
Previous Topic:EGL EDT V 0.8.0 M2
Next Topic:selectionListeners
Goto Forum:
  


Current Time: Sat May 24 07:13:25 EDT 2025

Powered by FUDForum. Page generated in 0.04631 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top