From VisualWorks®, 7.6 of February 8, 2008 on March 3, 2008 at 9:41:04 pm (Dialog confirm: 'You are filing-in a Parcel source file!\\While this is possible it will not have\the same effect as loading the parcel.\None of the Parcel''s prerequisites will\be loaded and none of its load actions\will be performed.\\Are you sure you want to file-in?' withCRs) ifFalse: [self error: 'Parcel file-in abandoned. Choose terminate or close.'] <class> <name>SQLAssistOracle</name> <environment>Store</environment> <super>Store.SQLAssist</super> <private>false</private> none <imports></imports> <category>StoreOracle</category> <attributes> <package>StoreOracle</package> </attributes> </class> <comment> Store.SQLAssistOracle
Sql generator for Oracle. At the moment, no differences between Oracle and the default.
</comment> <class> <name>OracleBroker</name> <environment>Store</environment> <super>Store.SQLBroker</super> <private>false</private> none <imports></imports> <category>StoreOracle</category> <attributes> <package>StoreOracle</package> </attributes> </class> <comment> Store.OracleBroker
Interface to Oracle database. Class Variables: Signals <SignalCollection of: Signal> Oracle signals
</comment> <name>Signals</name> <environment>Store.OracleBroker</environment> <private>false</private> <constant>false</constant> <category>signals</category> <attributes> <package>StoreOracle</package> </attributes> <methods> Store.OracleBroker class <category>error handling</category>
alreadyExistErrors ^ Array with: self objectAlreadyExistisErrorNumber
brokerSignals "self brokerSignals" ^Signals isNil ifTrue: [ Signals := self signalCollection] ifFalse: [ Signals ]
cannotCloseCursorErrorCode "Answer a number that database uses in case whe the cursor cannot be closed." ^ 1041
doesNotExistErrors ^ Array with: self objectAlreadyGoneErrorNumber with: self specifiedindexDoesntExistisErrorNumber with: self sequenceDoesNotExistErrorNumber with: self tableSpaceDoesntExistisErrorNumber
grantRevokeToFromYourselfError ^ 1749
invalidObjectErrorNumber ^ self objectAlreadyGoneErrorNumber
isNotLoggedOnSignal: exception ^ ( exception parameter notNil and: [ exception parameter isEmpty not and: [ self notLoggedOnErrorCode = exception parameter first dbmsErrorCode abs ] ] )
isServerDeadSignals: exception ^ ( exception parameter notNil and: [ exception parameter isEmpty not and: [ self serverDiedErrorCodes includes: exception parameter first dbmsErrorCode abs]])
isSessionInvalidSignal: ex ^ ( ex parameter isNil and:[ ex getSignal = self connectionClass invalidSessionStateSignal ]).
notLoggedOnErrorCode "Answer a number that database uses in case where the user is not logged on. This could happen when the server kicked us off but is still on line." ^ 1012
objectAlreadyExistisErrorNumber ^ 955
objectAlreadyGoneErrorNumber ^942
reconnectSignals: ex ^( ( self isSessionInvalidSignal: ex ) or: [ self isServerDeadSignals: ex ] ) or: [ self isNotLoggedOnSignal: ex ]
sequenceDoesNotExistErrorNumber ^ 2289
serverDiedErrorCodes "Answer a number that database uses in case of server going away while we are connected." ^ Set with: 3113 with: 3114
signalCollection ^ (SignalCollection new: 6) add: self connectionClass unableToExecuteSQLSignal; add: self connectionClass unableToOpenCursorSignal; add: CProcedureType externalAccessFailedSignal; add: self connectionClass invalidSessionStateSignal; add: self connectionClass unableToPrepareSignal; add: self connectionClass unableToCloseCursorSignal; yourself
specifiedindexDoesntExistisErrorNumber ^ 1418
tableSpaceAlreadyExistisErrorNumber ^ 1543
tableSpaceDoesntExistisErrorNumber ^ 959
userDoesNotExistErrorNumber ^ 1918
</methods> <methods> Store.OracleBroker class <category>create objects</category>
createDatabaseSequence: aClass self performCreate: [ self processSQL: 'CREATE SEQUENCE ' , ( self sequenceNameWithPrefix: aClass)] for: aClass name
createDatabaseTable: aClass "Creates a corresponding database table." | aKeyCollection aStream | aKeyCollection := OrderedCollection new. aStream := (String new: 100) writeStream. aStream nextPutAll: (self createDatabaseTableColumnsFor: aClass keyNames: aKeyCollection). aStream nextPutAll: (self createTablePrimaryKeySectionFor: aClass keys: aKeyCollection). self createTable: (self tableNameWithPrefix: aClass) columns: '(', aStream contents.
createMethodRetrievalIndex: aClass "self createMethodRetrievalIndex: Method" | prefix | prefix := self tablePrefix. prefix isEmpty ifFalse: [prefix := prefix , '.']. self createIndex: prefix, aClass indexName onTable: (self tableNameWithPrefix: aClass) columns: aClass indexColumnNames
createTablePrimaryKeySectionFor: aClass keys: aKeyCollection | aStream pkStream str | aStream := (String new: 100 ) writeStream. aKeyCollection isEmpty ifFalse: [aStream nextPutAll: ' PRIMARY KEY ('. pkStream := (String new: 100) writeStream. aKeyCollection do: [:each | pkStream nextPutAll: each , ', ']. pkStream skip: -2. aStream nextPutAll: pkStream contents , ')'. str := aClass indexParameters. str notNil ifTrue: [aStream cr. aStream nextPutAll: ' USING INDEX '; nextPutAll: str; space] ]. aStream nextPutAll: ')'; cr. aStream nextPutAll: 'PCTFREE 10 PCTUSED 60 '. str := aClass tableSpaceName. str notNil ifTrue: [aStream cr. aStream nextPutAll: 'TABLESPACE '. aStream nextPutAll: str; space]. str := aClass storageParameters. str notNil ifTrue: [aStream cr. aStream nextPutAll: str] ifFalse: [aStream skip: -2.]. ^ aStream contents.
installPhysicalSpaces "Create the physical Oracle table spaces used by Store." | path fileName1 fileName2 | DbRegistry goToScript ifFalse: [ (Dialog confirm: 'Create tablespaces? (Answer no only if they have already been created)') ifFalse: [ ^true ]]. path := Dialog request: 'Please, enter directory for the table spaces.' initialAnswer: ''. path isEmpty ifTrue: [ ^nil ]. fileName1 := path asFilename constructString: self fileNameForBlobs, '.dbf'. fileName2 := path asFilename constructString: self fileNameForClasses, '.dbf'. ^[ Transcript cr; show: 'Creating tablespace ' , self fileNameForClasses. self processSQL: 'CREATE TABLESPACE ', self fileNameForClasses, ' DATAFILE ''', fileName2,''' SIZE ', self spaceForClasses, ' REUSE DEFAULT STORAGE (INITIAL 1M NEXT 512K PCTINCREASE 1)'. Transcript cr; show: 'Creating tablespace ' , self fileNameForBlobs. self processSQL: 'CREATE TABLESPACE ', self fileNameForBlobs, ' DATAFILE ''', fileName1,''' SIZE ', self spaceForBlobs, ' REUSE DEFAULT STORAGE (INITIAL 1M NEXT 512K PCTINCREASE 1)'. self processSQL: 'ALTER DATABASE DATAFILE ''', fileName1,''' AUTOEXTEND ON'. self processSQL: 'ALTER DATABASE DATAFILE ''', fileName2,''' AUTOEXTEND ON'. true ] on: Error do: [ :exp | exp parameter first dbmsErrorCode == self tableSpaceAlreadyExistisErrorNumber ifTrue: [ Transcript show: exp description. true] ifFalse: [ Dialog warn: exp description. nil ] ].
spaceForBlobs ^ '16M'
spaceForClasses ^ '32M'
</methods> <methods> Store.OracleBroker class <category>accessing</category>
currentTimestampSQLString ^'SELECT SYS_EXTRACT_UTC(CURRENT_TIMESTAMP) FROM DUAL'
databaseName ^'Oracle'
fullTableName: aClass ^self tableNameWithPrefix: aClass
getBlobData: aData ^ aData
indexNameFor: aClass ^ (self tableNameWithPrefix: aClass), aClass indexName.
needsSequenceFor: aClass ^ aClass needsSequence
</methods> <methods> Store.OracleBroker class <category>private-accessing</category>
dismissSession: aSession [aSession dismiss] on: (SignalCollection with: self connectionClass unableToCloseCursorSignal with: self connectionClass unableToCancelCursorSignal) do: [ :ex | ex return ]
getNewSession | session | session := self connection getSession. session maxLongBytes: self maxLongBytes. session setDefaultDisplayLobSizeTo: self maxLongBytes. ^session
resetSessionCursorFor: aSession aSession notNil ifTrue: [ aSession cursor: nil.]
sequenceGeneratorSession: session forClass: aClass ^self safelyExecuteBlock: [ session isNil ifTrue: [ | newSession | newSession := self getNewSession. newSession bindOutput: nil; bindInput: nil; prepare: ( self nextIDQuery: aClass ); blockFactor: 1. newSession ] ifFalse: [ session ] ]
</methods> <methods> Store.OracleBroker class <category>drop objects</category>
dropDatabase: dbName Transcript cr; show: 'Dropping tablespace ' , dbName. self performDrop: [ self processSQL: ('DROP TABLESPACE ', dbName, ' INCLUDING CONTENTS')] for: dbName. Transcript show: 'Tablespace dropped'; cr.
dropDatabaseFor: aClass self dropDatabase: aClass databaseName
dropIndexForClass: aClass self dropIndexForClass: aClass index: aClass indexName.
dropIndexForClass: aClass index: aName self performDrop:[self processSQL: 'DROP INDEX ' , self tablePrefix, '.', aName] for: (aClass name, aName)
dropSequenceForClass: aClass Transcript cr; show: 'Dropping sequence for ' , aClass name. self performDrop: [self processSQL: 'DROP SEQUENCE ' , (self tableNameWithPrefix: aClass), 'Seq'.] for: aClass name.
dropTableForClass: aClass self dropTable: (self tableNameWithPrefix: aClass)
dropUser: aName Transcript cr; show: 'Dropping user ' , aName. self performDrop: [ self processSQL: ('DROP USER ', aName )] for: aName
dropViewForClass: aClass self dropView: (self tableNameWithPrefix: aClass)
</methods> <methods> Store.OracleBroker class <category>grant statements</category>
grant: aPermissionList on: aTableName columnList: aColumnList to: aUserNameList "Assigns permissions to users." | aStream | aStream := (String new: 100) writeStream. aStream nextPutAll: 'GRANT ' . aPermissionList do: [ :each | aStream nextPutAll: (each, ', ')]. aStream skip: -2. aStream nextPutAll: ' ( '. aColumnList do: [ :each | aStream nextPutAll: (each, ', ')]. aStream skip: -2. aStream nextPutAll: ' ) '. aStream nextPutAll: (' ON ' , aTableName ). aStream nextPutAll: ( ' TO '). aUserNameList do: [ :each | aStream nextPutAll: (each, ', ')]. aStream skip: -2. self processGrantStatement: aStream contents.
processGrantStatement: aString [ self processSQL: aString ] on: self connectionClass unableToExecuteSQLSignal do: [ :exception | ((exception parameter at: 1) dbmsErrorCode == self grantRevokeToFromYourselfError) ifTrue: [ exception return ] ifFalse: [Dialog warn: (self messageFor: exception).] ].
</methods> <methods> Store.OracleBroker class <category>queries</category>
newSQLFor: aClass "self newSQLFor: Object" ^self sqlAssistClass newSQLFor: aClass table: (self tableNameWithPrefix: aClass)
nextIDQuery: aClass ^(self sqlAssistClass newSQLFor: self table: 'sys.dual') select: (Array with: (self sequenceNameWithPrefix: aClass) , '.NextVal ')
sqlAssistClass ^SQLAssistOracle
</methods> <methods> Store.OracleBroker class <category>private</category>
typeToStringMap "Etb Modified - PHM Adds new types: - PrimaryKeyInteger - PrimaryKeyString" ^ (Dictionary new ) at: #String put: 'Varchar (255)'; at: #PrimaryKey put: 'Integer NOT NULL'; at: #PrimaryKeyInteger put: 'Integer NOT NULL'; at: #PrimaryKeyString put: 'Varchar (255) NOT NULL'; at: #PrimaryKeyShortString put: 'Varchar (50) NOT NULL'; at: #Text put: 'Long'; at: #Long put: 'Long'; at: #BinData put: 'Long Raw'; at: #Integer put: 'Integer'; at: #PrimaryKeyChar put: 'char(1)'; at: #Char put: 'char (1)'; at: #String32 put: 'varchar (32)' ; yourself.
</methods> <methods> Store.OracleBroker class <category>testing</category>
ansiOuterJoins "Return true if we use ansi outer joins. With Oracle, these are introduced at 9i, but the old syntax still works everywhere" ^false.
</methods> <methods> Database.OracleConnection class <category>accessing</category>
storeBroker "Answer a broker class for Store" ^Store.OracleBroker
</methods> <methods> Database.OracleConnection <category>private-accessing</category>
nilParams self lda: nil
</methods> <methods> Database.OracleConnection <category>accessing</category>
storeBroker ^Store.OracleBroker
</methods> "Imported Classes:" self error: 'Attempting to file-in parcel imports. Choose terminate or close' <class> <name>OracleConnection</name> <environment>Database</environment> <super>Database.ExternalDatabaseConnection</super> <private>false</private> none henvHolder herrHolder hsvcctxHolder hsrvrHolder hsessHolder htxnHolder executionMode transactionMode authenticationMode signalMap libraryInitialized <imports></imports> <category>Database-Oracle</category> <attributes> <package>OracleEXDI</package> </attributes> </class> <class> <name>SQLBroker</name> <environment>Store</environment> <super>Core.Object</super> <private>false</private> none <imports></imports> <category>Store-DB-Broker</category> <attributes> <package>Store-DB-Broker</package> </attributes> </class> <class> <name>SQLAssist</name> <environment>Store</environment> <super>Core.Object</super> <private>false</private> none tableName tableClass sqlStream alias <imports></imports> <category>Store-DB-Broker</category> <attributes> <package>Store-DB-Broker</package> </attributes> </class>