New Native Oracle Functionality - Anonymous Blocks

VA Smalltalk is a "100% VisualAge compatible" IDE that includes the original VisualAge technology and the popular VA Assist and WidgetKit add-ons.

Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig

New Native Oracle Functionality - Anonymous Blocks

Postby tc » Thu May 27, 2010 8:29 pm

Hello,

Here is a standalone anonymous block one could execute in PL*SQL:
Code: Select all
DECLARE
   ts TIMESTAMP;
BEGIN
   ts := SYSTIMESTAMP;
   :outTS := ts;
END;



. . . to execute it from ST, one would do (in a workspace):
Code: Select all
connection := AbtDbmSystem activeDatabaseConnection
   flushCache;
   autoCommit: true;
   commitUnitOfWork;
   yourself.

wStream := WriteStream on: String new.
wStream
   nextPutAll: 'DECLARE '; cr;
   nextPutAll: 'ts TIMESTAMP; '; cr;
   nextPutAll: 'BEGIN '; cr;
   nextPutAll: 'ts := SYSTIMESTAMP; '; cr;
   nextPutAll: ':outTS := ts; '; cr;
   nextPutAll: 'END; '.

timeStampName := 'outTS'.

inOutParams := AbtCompoundType new
   addField: (AbtOracle10TimeStampField new
      name: timeStampName).
   
aDict := Dictionary new.
aDict
   at: timeStampName
   put: (AbtTimestamp now
      date: (Date today addDays: 3);
      yourself).

anonymousBlockSpec := AbtAnonymousBlockSpec new
   plSqlString: wStream contents;
   useSqlCall: true;
   parameters: inOutParams.

resultSet := connection invokeAnonymousBlockSpec: anonymousBlockSpec withInputDictionary: aDict.

resultSet




tstamp result.jpg
tstamp result.jpg (69.67 KiB) Viewed 138 times



--tc
tc
Moderator
 
Posts: 304
Joined: Tue Oct 17, 2006 7:40 am
Location: Raleigh, NC

Return to VA Smalltalk 7.0, 7.5 & 8.0

Who is online

Users browsing this forum: No registered users and 1 guest