Moodle  2.2.1
http://www.collinsharper.com
oracle_sql_generator Class Reference
Inheritance diagram for oracle_sql_generator:
Collaboration diagram for oracle_sql_generator:

Public Member Functions

 getResetSequenceSQL ($table)
 getTableName (xmldb_table $xmldb_table, $quoted=true)
 getCreateTempTableSQL ($xmldb_table)
 getDropTempTableSQL ($xmldb_table)
 getTypeSQL ($xmldb_type, $xmldb_length=null, $xmldb_decimals=null)
 getCreateSequenceSQL ($xmldb_table, $xmldb_field)
 getCreateTriggerSQL ($xmldb_table, $xmldb_field, $sequence_name)
 getDropSequenceSQL ($xmldb_table, $xmldb_field, $include_trigger=false)
 getCommentSQL ($xmldb_table)
 getDropTableExtraSQL ($xmldb_table)
 getRenameTableExtraSQL ($xmldb_table, $newname)
 getAlterFieldSQL ($xmldb_table, $xmldb_field, $skip_type_clause=NULL, $skip_default_clause=NULL, $skip_notnull_clause=NULL)
 getDropEnumSQL ($xmldb_table, $xmldb_field)
 getCreateDefaultSQL ($xmldb_table, $xmldb_field)
 getDropDefaultSQL ($xmldb_table, $xmldb_field)
 getCheckConstraintsFromDB ($xmldb_table, $xmldb_field=null)
 getSequenceFromDB ($xmldb_table)
 getTriggerFromDB ($xmldb_table)
 isNameInUse ($object_name, $type, $table_name)
 addslashes ($s)

Static Public Member Functions

static getReservedWords ()

Data Fields

 $statement_end = "\n/"
 Only set values that are different from the defaults present in XMLDBgenerator.
 $number_type = 'NUMBER'
 $unsigned_allowed = false
 $default_for_char = ' '
 $drop_default_value_required = true
 $drop_default_value = NULL
 $default_after_null = false
 $sequence_extra_code = true
 $sequence_name = ''
 $sequence_cache_size = 20
 $enum_inline_code = false
 $alter_column_sql = 'ALTER TABLE TABLENAME MODIFY (COLUMNSPECS)'

Detailed Description

This class generate SQL code to be used against Oracle It extends XMLDBgenerator so everything can be overridden as needed to generate correct SQL.

Definition at line 37 of file oracle_sql_generator.php.


Member Function Documentation

addslashes ( s)

Reimplemented from sql_generator.

Definition at line 652 of file oracle_sql_generator.php.

Here is the caller graph for this function:

getAlterFieldSQL ( xmldb_table,
xmldb_field,
skip_type_clause = NULL,
skip_default_clause = NULL,
skip_notnull_clause = NULL 
)

Given one xmldb_table and one xmldb_field, return the SQL statements needed to alter the field in the table Oracle has some severe limits:

  • clob and blob fields doesn't allow type to be specified
  • error is dropped if the null/not null clause is specified and hasn't changed
  • changes in precision/decimals of numeric fields drop an ORA-1440 error

To store all the needed SQL commands

Get the quoted name of the table and field

Take a look to field metadata

To calculate the oldlength if the field is numeric, we need to perform one extra query because ADOdb has one bug here. http://phplens.com/lens/lensforum/msgs.php?id=15883

Detect if we are changing the type of the column

Detect if precision has changed

Detect if decimal has changed

Detect if we are changing the default

Detect if we are changing the nullability

If type has changed or precision or decimal has changed and we are in one numeric field

  • create one temp column with the new specs
  • fill the new column with the values from the old one
  • drop the old column
  • rename the temp column to the original name

Prevent temp field to have both NULL/NOT NULL and DEFAULT constraints

Create the temporal column

Copy contents from original col to the temporal one

Drop the old column

Rename the temp column to the original one

Mark we have performed one change based in temp fields

Re-enable the notnull and default sections so the general AlterFieldSQL can use it

Dissable the type section because we have done it with the temp field

If new field is nullable, nullability hasn't changed

If new field hasn't default, default hasn't changed

If type and precision and decimals hasn't changed, prevent the type clause

If NULL/NOT NULL hasn't changed prevent null clause to be specified

Initially, prevent the notnull clause

But, if we have used the temp field and the new field is not null, then enforce the not null clause

If default hasn't changed prevent default clause to be specified

Initially, prevent the default clause

But, if we have used the temp field and the new field has default clause, then enforce the default clause

If arriving here, something is not being skipped (type, notnull, default), calculate the standard AlterFieldSQL

Finally return results

Reimplemented from sql_generator.

Definition at line 316 of file oracle_sql_generator.php.

Here is the call graph for this function:

Here is the caller graph for this function:

getCheckConstraintsFromDB ( xmldb_table,
xmldb_field = null 
)

Given one xmldb_table returns one array with all the check constraints in the table (fetched from DB) Optionally the function allows one xmldb_field to be specified in order to return only the check constraints belonging to one field. Each element contains the name of the constraint and its description If no check constraints are found, returns an empty array

TODO: Moodle 2.1 - drop in Moodle 2.1

Filter by the required field if specified

Lets clean a bit each constraint description, looking for the filtered field

description starts by "$filter IN" assume it's a constraint belonging to the field

Assign filtered results to the final results array

Reimplemented from sql_generator.

Definition at line 537 of file oracle_sql_generator.php.

Here is the call graph for this function:

Here is the caller graph for this function:

getCommentSQL ( xmldb_table)

Returns the code (in array) needed to add one comment to the table

Reimplemented from sql_generator.

Definition at line 248 of file oracle_sql_generator.php.

Here is the call graph for this function:

getCreateDefaultSQL ( xmldb_table,
xmldb_field 
)

Given one xmldb_table and one xmldb_field, return the SQL statements needed to create its default (usually invoked from getModifyDefaultSQL()

Just a wrapper over the getAlterFieldSQL() function for Oracle that is capable of handling defaults

Reimplemented from sql_generator.

Definition at line 511 of file oracle_sql_generator.php.

Here is the call graph for this function:

getCreateSequenceSQL ( xmldb_table,
xmldb_field 
)

Returns the code needed to create one sequence for the xmldb_table and xmldb_field passes

Reimplemented from sql_generator.

Definition at line 191 of file oracle_sql_generator.php.

Here is the call graph for this function:

getCreateTempTableSQL ( xmldb_table)

Given one correct xmldb_table, returns the SQL statements to create temporary table (inside one array)

Reimplemented from sql_generator.

Definition at line 120 of file oracle_sql_generator.php.

Here is the call graph for this function:

getCreateTriggerSQL ( xmldb_table,
xmldb_field,
sequence_name 
)

Returns the code needed to create one trigger for the xmldb_table and xmldb_field passed

Definition at line 209 of file oracle_sql_generator.php.

Here is the call graph for this function:

Here is the caller graph for this function:

getDropDefaultSQL ( xmldb_table,
xmldb_field 
)

Given one xmldb_table and one xmldb_field, return the SQL statements needded to drop its default (usually invoked from getModifyDefaultSQL()

Just a wrapper over the getAlterFieldSQL() function for Oracle that is capable of handling defaults

Reimplemented from sql_generator.

Definition at line 521 of file oracle_sql_generator.php.

Here is the call graph for this function:

getDropEnumSQL ( xmldb_table,
xmldb_field 
)

Given one xmldb_table and one xmldb_field, return the SQL statements needed to drop its enum (usually invoked from getModifyEnumSQL()

TODO: Moodle 2.1 - drop in Moodle 2.1

Let's introspect to know the real name of the check constraint

Get the 1st (should be only one)

Extract the REAL name

All we have to do is to drop the check constraint

Constraint not found. Nothing to do

Reimplemented from sql_generator.

Definition at line 494 of file oracle_sql_generator.php.

Here is the call graph for this function:

getDropSequenceSQL ( xmldb_table,
xmldb_field,
include_trigger = false 
)

Returns the code needed to drop one sequence for the xmldb_table and xmldb_field passed Can, optionally, specify if the underlying trigger will be also dropped

Definition at line 230 of file oracle_sql_generator.php.

Here is the call graph for this function:

Here is the caller graph for this function:

getDropTableExtraSQL ( xmldb_table)

Returns the code (array of statements) needed to execute extra statements on table drop

Reimplemented from sql_generator.

Definition at line 259 of file oracle_sql_generator.php.

Here is the call graph for this function:

getDropTempTableSQL ( xmldb_table)

Given one correct xmldb_table and the new name, returns the SQL statements to drop it (inside one array)

Reimplemented from sql_generator.

Definition at line 131 of file oracle_sql_generator.php.

Here is the call graph for this function:

getRenameTableExtraSQL ( xmldb_table,
newname 
)

Returns the code (array of statements) needed to execute extra statements on table rename

Drop old trigger (first of all)

Rename the sequence, disablig CACHE before and enablig it later to avoid consuming of values on rename

Create new trigger

Temp table for trigger code generation

Rename all the check constraints in the table

Drop the old constraint

Reimplemented from sql_generator.

Definition at line 267 of file oracle_sql_generator.php.

Here is the call graph for this function:

static getReservedWords ( ) [static]

Returns an array of reserved words (lowercase) for this DB

This file contains the reserved words for Oracle databases from http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96540/ap_keywd.htm

Reimplemented from sql_generator.

Definition at line 661 of file oracle_sql_generator.php.

getResetSequenceSQL ( table)

Reset a sequence to the id field of a table.

Parameters:
string$tablename of table or xmldb_table object
Returns:
array sql commands to execute

Fallback, seqname not found, something is wrong. Inform and use the alternative getNameForObject() method

Reimplemented from sql_generator.

Definition at line 68 of file oracle_sql_generator.php.

Here is the call graph for this function:

getSequenceFromDB ( xmldb_table)

Given one xmldb_table returns one string with the sequence of the table in the table (fetched from DB) The sequence name for oracle is calculated by looking the corresponding trigger and retrieving the sequence name from it (because sequences are independent elements) If no sequence is found, returns false

If trigger found, regexp it looking for the sequence name

Reimplemented from sql_generator.

Definition at line 580 of file oracle_sql_generator.php.

Here is the call graph for this function:

Here is the caller graph for this function:

getTableName ( xmldb_table xmldb_table,
quoted = true 
)

Given one xmldb_table, returns it's correct name, depending of all the parametrization Overridden to allow change of names in temp tables

Parameters:
xmldb_tabletable whose name we want
booleanto specify if the name must be quoted (if reserved word, only!)
Returns:
string the correct name of the table

Get the name, supporting special oci names for temp tables

Apply quotes optionally

Reimplemented from sql_generator.

Definition at line 100 of file oracle_sql_generator.php.

Here is the call graph for this function:

Here is the caller graph for this function:

getTriggerFromDB ( xmldb_table)

Given one xmldb_table returns one string with the trigger in the table (fetched from DB) If no trigger is found, returns false

Definition at line 605 of file oracle_sql_generator.php.

Here is the call graph for this function:

Here is the caller graph for this function:

getTypeSQL ( xmldb_type,
xmldb_length = null,
xmldb_decimals = null 
)

Given one XMLDB Type, length and decimals, returns the DB proper SQL type

38 is the max allowed

Reimplemented from sql_generator.

Definition at line 141 of file oracle_sql_generator.php.

isNameInUse ( object_name,
type,
table_name 
)

Given one object name and it's type (pk, uk, fk, ck, ix, uix, seq, trg) return if such name is currently in use (true) or no (false) (invoked from getNameForObject()

Reimplemented from sql_generator.

Definition at line 626 of file oracle_sql_generator.php.


Field Documentation

$alter_column_sql = 'ALTER TABLE TABLENAME MODIFY (COLUMNSPECS)'

Reimplemented from sql_generator.

Definition at line 61 of file oracle_sql_generator.php.

$default_after_null = false

Reimplemented from sql_generator.

Definition at line 53 of file oracle_sql_generator.php.

$default_for_char = ' '

Reimplemented from sql_generator.

Definition at line 47 of file oracle_sql_generator.php.

$drop_default_value = NULL

Reimplemented from sql_generator.

Definition at line 51 of file oracle_sql_generator.php.

$drop_default_value_required = true

Reimplemented from sql_generator.

Definition at line 50 of file oracle_sql_generator.php.

$enum_inline_code = false

Definition at line 59 of file oracle_sql_generator.php.

$number_type = 'NUMBER'

Reimplemented from sql_generator.

Definition at line 44 of file oracle_sql_generator.php.

$sequence_cache_size = 20

Definition at line 57 of file oracle_sql_generator.php.

$sequence_extra_code = true

Reimplemented from sql_generator.

Definition at line 55 of file oracle_sql_generator.php.

$sequence_name = ''

Reimplemented from sql_generator.

Definition at line 56 of file oracle_sql_generator.php.

$statement_end = "\n/"

Only set values that are different from the defaults present in XMLDBgenerator.

Reimplemented from sql_generator.

Definition at line 41 of file oracle_sql_generator.php.

$unsigned_allowed = false

Reimplemented from sql_generator.

Definition at line 46 of file oracle_sql_generator.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations