Question: Persistence fireDAC Oracle in delphi XE7 win32

Issue #89 closed
Alphonse ngayap created an issue

Hello, i use Oracle database, how i can change something to have: - String for VARVHAR2 and not NVARCHAR2 - TDateTime for DATE and not TIMESTAMP

Thank

Comments (6)

  1. Linas Naginionis

    Can you be more specific what you want to change? Do you want to change how Oracle SQL Generator generates Create Table statements?

  2. Alphonse ngayap reporter

    Hello, l use firedac and oracle db.I want TDateTime générateur DATE ans not Timestam. String générateur Varchar2 ans not Nvarchar2.

    Thank

  3. Alphonse ngayap reporter

    hello, for example this Entity class

      [Entity]
      [Table('Customers')]
      [Sequence('SEQ_CUST', 1, 1)]
      TCustomer = class
      private
        [UniqueConstraint]
        [Column('CUSTID', [cpRequired, {cpDontInsert,} cpPrimaryKey, cpNotNull], 0, 0, 0, 'Primary Key')]
        [AutoGenerated]
        FId: Integer;
      public
        FName: string;
        FAge: Integer;
        FHeight: Double;
        FLastEdited: TDateTime;
        FEmail: string;
        FMiddleName: Nullable<string>;
      public
        property ID: Integer read FId;
        [Column('CUSTNAME', [], 50, 0, 0, 'Customers name')]
        property Name: string read FName write FName;
        [Column('CUSTAGE', [], 0, 0, 0, 'Customers age')]
        property Age: Integer read FAge write FAge;
        [Column('CUSTHEIGHT', [], 0, 5, 2, 'Customers height')]
        property Height: Double read FHeight write FHeight;
        //[Column('LastEdited', [], 0, 0, 0, 'Last Edited')]
        [Column]
        property LastEdited: TDateTime read FLastEdited write FLastEdited;
        [Column('EMAIL', [], 50, 0, 0, 'E-mail address')]
        property EMail: string read FEmail write FEmail;
        [Column('MIDDLENAME', [], 50, 0, 0, 'Middle name')]
        property MiddleName: string read FMiddleName write FMiddleName;
      end;
    

    Oracle SQL Generator generates Create Table statements generate this :

      CREATE TABLE "CUSTOMERS" 
       (    "CUSTID" NUMBER(*,0) NOT NULL ENABLE, 
        "CUSTNAME" NVARCHAR2(50), 
        "CUSTAGE" NUMBER(*,0), 
        "CUSTHEIGHT" NUMBER(5,2), 
        "LastEdited" TIMESTAMP (6), 
        "EMAIL" NVARCHAR2(50), 
        "MIDDLENAME" NVARCHAR2(50), 
         PRIMARY KEY ("CUSTID")
      USING INDEX  ENABLE
       ) ;
    

    I want this :

      CREATE TABLE "CUSTOMERS" 
       (    "CUSTID" NUMBER(12,0) NOT NULL ENABLE, 
        "CUSTNAME" VARCHAR2(50), 
        "CUSTAGE" NUMBER(12,0), 
        "CUSTHEIGHT" NUMBER(5,2), 
        "LastEdited" DATE, 
        "EMAIL" VARCHAR2(50), 
        "MIDDLENAME" VARCHAR2(50), 
         PRIMARY KEY ("CUSTID")
      USING INDEX  ENABLE
       ) ;
    

    I do not want NVARCHAR2, TIMESTAMP and NUMBER(*,0)

    Thank

  4. Linas Naginionis

    You could write your own Oracle SQL Generator which would extend TOracleSQLGenerator. Then you'll only need to override GetSQLDataTypeName function. After you've done, you must register your new generator by calling

    TSQLGeneratorRegister.RegisterGenerator(TYourOracleSQLGenerator.Create);
    

    Note that your registration should be executed after Spring.Persistence.SQL.Generators.Oracle unit initialization.

  5. Log in to comment