• SQL Tables in Qtemp

    From Efrain Gomez@21:1/5 to All on Fri Aug 10 12:53:19 2018
    Hi everyone,

    I am trying to create an SQL Table in Qtemp, but I receive a message saying:

    Customers in Qtemp not valid for operation.

    The funny story is that if I run the same sentence in my programmer’s library the table is created and I do not receive any message.

    This is the testing code that I am running:


    Create Table qtemp/Customers
    (Custno Char(9) Not Null Default Primary Key,
    Cfname Char(15) Default,
    Clname Char(20) Default,
    Caddr Char(30) Default,
    Czip Char(5) Default,
    Cphone Char(10) Not Null Default,
    Cemail Char(50) Not Null Default,
    Cdob Decimal(8,0) Not Null Default,
    Cgender Char(1) Not Null Default)

    Rcdfmt Custsrec




    Thanks for any help on this.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mike Colangelo@21:1/5 to Efrain Gomez on Fri Aug 10 17:05:15 2018
    On 8/10/2018 12:53 PM, Efrain Gomez wrote:
    Hi everyone,

    I am trying to create an SQL Table in Qtemp, but I receive a message saying:

    Customers in Qtemp not valid for operation.

    The funny story is that if I run the same sentence in my programmer’s library the table is created and I do not receive any message.

    This is the testing code that I am running:


    Create Table qtemp/Customers
    (Custno Char(9) Not Null Default Primary Key,
    Cfname Char(15) Default,
    Clname Char(20) Default,
    Caddr Char(30) Default,
    Czip Char(5) Default,
    Cphone Char(10) Not Null Default,
    Cemail Char(50) Not Null Default,
    Cdob Decimal(8,0) Not Null Default,
    Cgender Char(1) Not Null Default)

    Rcdfmt Custsrec




    Thanks for any help on this.


    You can't have a primary key on a table in QTEMP.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Efrain Gomez@21:1/5 to All on Fri Aug 10 17:43:07 2018
    El viernes, 10 de agosto de 2018, 13:53:21 (UTC-6), Efrain Gomez escribió:
    Hi everyone,

    I am trying to create an SQL Table in Qtemp, but I receive a message saying:

    Customers in Qtemp not valid for operation.

    The funny story is that if I run the same sentence in my programmer’s library the table is created and I do not receive any message.

    This is the testing code that I am running:


    Create Table qtemp/Customers
    (Custno Char(9) Not Null Default Primary Key,
    Cfname Char(15) Default,
    Clname Char(20) Default,
    Caddr Char(30) Default,
    Czip Char(5) Default,
    Cphone Char(10) Not Null Default,
    Cemail Char(50) Not Null Default,
    Cdob Decimal(8,0) Not Null Default,
    Cgender Char(1) Not Null Default)

    Rcdfmt Custsrec




    Thanks for any help on this.

    Hi Mike,

    Would it be possible you to explain more details about this constraint?

    Thanks,

    Efrain

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mike Colangelo@21:1/5 to Efrain Gomez on Mon Aug 13 07:37:17 2018
    On 8/10/2018 5:43 PM, Efrain Gomez wrote:
    El viernes, 10 de agosto de 2018, 13:53:21 (UTC-6), Efrain Gomez escribió:
    Hi everyone,

    I am trying to create an SQL Table in Qtemp, but I receive a message saying: >>
    Customers in Qtemp not valid for operation.

    The funny story is that if I run the same sentence in my programmer’s library the table is created and I do not receive any message.

    This is the testing code that I am running:


    Create Table qtemp/Customers
    (Custno Char(9) Not Null Default Primary Key,
    Cfname Char(15) Default,
    Clname Char(20) Default,
    Caddr Char(30) Default,
    Czip Char(5) Default,
    Cphone Char(10) Not Null Default,
    Cemail Char(50) Not Null Default,
    Cdob Decimal(8,0) Not Null Default,
    Cgender Char(1) Not Null Default)

    Rcdfmt Custsrec




    Thanks for any help on this.

    Hi Mike,

    Would it be possible you to explain more details about this constraint?

    Thanks,

    Efrain


    There's not much to explain. DB2 on IBM i won't allow you to create
    several types of database objects in QTEMP. For example, you can't
    create a function or stored procedure or sequence in QTEMP.

    For whatever reason, DB2 won't let you create a constraint on a table in
    QTEMP, and the primary key is implemented as a constraint. You can't
    create a temporary table with a check constraint, either, for the same
    reason.

    What you /can/ do is create your temporary table, then create a unique
    index on the column. For your table above:

    create unique index qtemp/customers_i1 on qtemp/customers (custno)

    That would at least give you the uniqueness attribute of a primary key.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)