in

Oracle Provider Not Generating Views

Last post 04-22-2008 8:19 AM by davids. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 04-18-2008 11:34 AM

    • davids
    • Top 200 Contributor
    • Joined on 07-31-2007
    • Posts 9

    Oracle Provider Not Generating Views

    I wamt to generate a class object for just 1 database object which happens to be a view.  A PK should not be preventing this from working.  When I run SubCommander, nothing is generated.

     <connectionStrings>
          <add name="AppConnection" providerName="System.Data.OracleClient" connectionString="Data Source=x;User ID=x;Password=x" />
      </connectionStrings>

    <SubSonicService defaultProvider="OracleDataProvider">
        <providers>
          <clear />
          <add name="OracleDataProvider" type="SubSonic.OracleDataProvider, SubSonic" connectionStringName="AppConnection" generatedNamespace="xxx" appendWith="_" includeTableList="MyView" />
        </providers>
      </SubSonicService>

     

    Setting ConfigPath: 'web.config'
    Building configuration from web.config
    Adding connection to OracleDataProvider
    Generating classes for OracleDataProvider (0 total)
    Finished
    Setting ConfigPath: 'web.config'
    Building configuration from web.config
    Adding connection to OracleDataProvider
    Generating ODS Controllers for OracleDataProvider (0 total)
    Finished
    Setting ConfigPath: 'web.config'
    Building configuration from web\web.config
    Adding connection to OracleDataProvider
    Setting ConfigPath: 'web.config'
    Building configuration from web.config
    Adding connection to OracleDataProvider
    Generating SPs to Generated\StoredProcedures.vb
    Finished
    Setting ConfigPath: 'web.config'
    Building configuration from web.config
    Adding connection to OracleDataProvider
    Generating Structs to Generated\AllStructs.vb
    Finished
    Running Compiler...
    Writing Files...
    Done!
    Execution Time: 1090ms
     

    Filed under:
  • 04-18-2008 11:58 AM In reply to

    • davids
    • Top 200 Contributor
    • Joined on 07-31-2007
    • Posts 9

    Re: Oracle Provider Not Generating Views

    I also trimmed this down and changed my generate routine to use the generateviews command.  

     

    Setting ConfigPath: 'web.config'
    Building configuration from web.config
    Adding connection to OracleProvider
    Execution Time: 531ms
     

    Same thing as above. 

  • 04-21-2008 2:57 PM In reply to

    • davids
    • Top 200 Contributor
    • Joined on 07-31-2007
    • Posts 9

    Re: Oracle Provider Not Generating Views

     Can someone please help me with this?

  • 04-21-2008 5:27 PM In reply to

    • davids
    • Top 200 Contributor
    • Joined on 07-31-2007
    • Posts 9

    Re: Oracle Provider Not Generating Views

     After digging and digging and digging, I found that this had to do with my schema ownership in the database.

    SubCommander uses the following SQL to get the schema:

     "SELECT a.table_name AS Name FROM user_tables a";

    and for views:

    "SELECT a.view_name AS Name FROM user_views a";

     

     Since the schema is owned by a different user and I will not be given that user's account information, I needed to alter the code as follows:

     In the OracleProvider class, change the code within the Schema Bits region (it is near 3/4 of the way down the file:

     

    private const string MANY_TO_MANY_LIST = "SELECT b.table_name FROM all_constraints a, all_cons_columns b " +
                                                      "WHERE a.table_name = :tableName " +
                                                      "AND a.constraint_type = 'R' " +
                                                      "AND a.r_constraint_name = b.constraint_name " +
                                                      "AND b.table_name like '%' + :mapSuffix";

            const string TABLE_COLUMN_SQL = "SELECT user, a.table_name, a.column_name, a.column_id, a.data_default, " +
                                            "       a.nullable, a.data_type, a.char_length, a.data_precision, a.data_scale " +
                                            "  FROM all_tab_columns a " +
                                            " WHERE a.table_name = :tableName";


            const string SP_PARAM_SQL = @"SELECT a.object_name, a.object_type, b.position, b.in_out,
                                        b.argument_name, b.data_type, b.char_length, b.data_precision, b.data_scale
                                        FROM all_objects a, all_arguments b
                                        WHERE a.object_type IN ('PROCEDURE', 'FUNCTION', 'PACKAGE')
                                        AND a.object_id = b.object_id
                                        AND a.object_name = :objectName";


            const string SP_SQL = @"SELECT a.object_name, a.object_type, a.created, a.last_ddl_time
        `                           FROM all_objects a
                                    WHERE a.object_type IN ('PROCEDURE', 'FUNCTION', 'PACKAGE') ";


            const string TABLE_SQL = "SELECT a.table_name AS Name FROM all_tables a";

            const string VIEW_SQL = "SELECT a.view_name AS Name FROM all_views a";

            const string INDEX_SQL =    "SELECT b.table_name, b.column_name, " +
                                        "       DECODE (a.constraint_type, " +
                                        "               'R', 'FOREIGN KEY', " +
                                        "               'P', 'PRIMARY KEY', " +
                                        "               'UNKNOWN' " +
                                        "              ) constraint_type " +
                                        "  FROM all_constraints a, all_cons_columns b " +
                                        " WHERE a.constraint_name = b.constraint_name " +
                                        "   AND a.constraint_type IN ('R', 'P') " +
                                        "   AND b.table_name = :tableName ";

            const string GET_TABLE_SQL =    "SELECT b.table_name " +
                                            "  FROM all_constraints a, all_cons_columns b " +
                                            " WHERE a.constraint_name = b.constraint_name " +
                                            "   AND a.constraint_type IN ('R', 'P') " +
                                            "   AND b.column_name = :columnName " +
                                            "   AND a.constraint_type = 'P' ";

            const string GET_FOREIGN_KEY_SQL =  "SELECT d.table_name " +
                                                "  FROM all_cons_columns c, all_cons_columns d, all_constraints e " +
                                                " WHERE d.constraint_name = e.r_constraint_name " +
                                                "   AND c.constraint_name = e.constraint_name " +
                                                "   AND d.column_name = :columnName " +
                                                "   AND e.table_name = :tableName ";
           
            const string GET_PRIMARY_KEY_SQL =  "SELECT e.table_name AS TableName, c.column_name AS ColumnName " +
                                                "  FROM all_cons_columns c, all_cons_columns d, all_constraints e " +
                                                " WHERE d.constraint_name = e.r_constraint_name " +
                                                "   AND c.constraint_name = e.constraint_name " +
                                                "   AND d.table_name = :tableName ";

     

    Your database account will need elevated privs. to do this but it will allow your DBA's to help you with that rather than having to know the schema owner. 

  • 04-22-2008 1:04 AM In reply to

    • ranomore
    • Top 10 Contributor
    • Joined on 11-05-2007
    • Salt Lake City
    • Posts 161
    • Moderator

    Re: Oracle Provider Not Generating Views

     Sorry no one was helpful on this, haven't seen a lot of vocal Oracle supporters in the forums of late..

    What parts specifically need eleveated privs? Is it just to get DAL generation for a schema you don't own?

  • 04-22-2008 8:19 AM In reply to

    • davids
    • Top 200 Contributor
    • Joined on 07-31-2007
    • Posts 9

    Re: Oracle Provider Not Generating Views

    Sorry I should have been more clear.  When I say elevated privs, I mean access to the sys.all_* tables for that catalog.  Not all users always have that.  It really just depends on how you implement your databases. 

Page 1 of 1 (6 items)