A question of tables

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default A question of tables

    Hi All

    As per my previous posting, I'm having trouble getting my schema out of my
    DB so you will have to bear with me on this.

    Basically I have the following tables (PLEASE NOTE: these are me
    pseudo-trying to create DDL - apologies for errors):

    CREATE TABLE STOCK
    (STOCKID TEXT(30) NOT NULL PK,
    CATID TEXT(30) NOT NULL,
    MANUID TEXT(30) NOT NULL,
    TAXID TEXT(30) NOT NULL,
    PIC TEXT(50) NULL,
    THUMBPIC TEXT(50) NULL,
    UNIT TEXT(50) NULL,
    WEIGHT INTEGER NULL,
    QTYINSTOCK INTEGER
    NEWSTOCK INTEGER
    DISCON BYTE
    SPECIAL BYTE
    LASTUPDATE DATE/TIME);

    CREATE TABLE STOCKDESCS
    (STOCKID TEXT(30) NOT NULL,
    STOCKNAME TEXT(50) NOT NULL,
    SHORTDESC TEXT(255) NULL,
    FULLDESC MEMO NULL,
    LANGID TEXT(30) NOT NULL);

    CREATE TABLE STOCKPRICES
    (STOCKID TEXT(30) NOT NULL,
    CURRENCYID TEXT(30) NOT NULL,
    RRPNETAMOUNT DECIMAL(18,3) NULL,
    RRPTAXAMOUNT DECIMAL(18,3) NULL,
    NETAMOUNT DECIMAL(18,3) NULL,
    TAXAMOUNT DECIMAL(18,3) NULL);

    Not actually sure if I should have the above price amounts set to
    DECIMAL(18,3), but I read that I should use the decimal option as it is more
    accurate and the Access default is 18,3

    Anyway this isn't the problem. My prob is that if I run the below query:

    strSQLQuery = "SELECT s.STOCKID, s.THUMBPIC, sd.STOCKNAME, sd.SHORTDESC,
    (sp.RRPNETAMOUNT + sp.RRPTAXAMOUNT) AS RRP, (sp.NETAMOUNT + sp.TAXAMOUNT) AS
    PRICE FROM STOCK s, STOCKDESCS sd, STOCKPRICES sp WHERE s.STOCKID=sd.STOCKID
    AND s.STOCKID=sp.STOCKID AND sd.LANGID='" & cSelLang & "' AND
    sp.CURRENCYID='" & cSelCurrency & "' AND s.SPECIAL=1"

    I get the cartisan (sp?) result that there has to be entries in the
    STOCKDESCS and STOCKPRICES tables in order to bring back the records for the
    selected lang and currency, ie cSelCurrency and cSelLang.

    The reason for my query is that my ASP page has pop-up options for different
    currencies and languages. The only problem is that the above query really
    only works if the admin user has religiously entered descs and prices for
    each currency and language.

    I need it that if the prices and/or descs aren't entered then I still bring
    back the rest of the data.

    I'm putting in flags so that the user can omit the necessary langs and
    currencies so missing data won't look odd.

    Is it all to do with these outer joins again?

    Your help would be appreciated.

    Rgds

    Laphan




    Laphan Guest

  2. Similar Questions and Discussions

    1. help please. simple question using tables.
      You can view my page at: http://www.ironies.com/indexold.htm . So, I created the horizontal lines on the page using 'insert horizontal rule" and...
    2. Tables question...
      Hi, I have a (hopefully) quick question for the experienced... I have a table of categories. On my form I want certain category values to...
    3. silly question re tables
      Hi I've created a 7 col 55 line table with border and baclground colour. I can copy the information from the old table and paste it in the new...
    4. Beginners question about tables
      Hi, When using tables is there a way of fixing cell width and height, I was told there was a 'locking' option. Another related problem is that...
    5. newB question: related tables question
      hello i have a data base with 10 tables, i want to automaticaly creat a row in all of the tables wehen i create in the first one. normal table...
  3. #2

    Default Re: A question of tables

    Just to elaborate on this theme, is there anyway that I could adapt the
    query so that if there isn't a price available in the STOCKPRICES table for
    the currencyid specified then I can change my query to take the exchange
    rate from a 4th table (or session var) and convert the default currency
    price (which should be in the STOCKPRICES table) with this exchange rate.

    At present, I using the following method to cater for the above and
    aforementioned problems (see below):

    IF cSelCurrency <> cDefCurrency THEN

    strSQLQuery = "SELECT s.STOCKID, s.THUMBPIC, sd.STOCKNAME, sd.SHORTDESC,
    ((sp.RRPNETAMOUNT * " & cSelCurrencyRate & ") + (sp.RRPTAXAMOUNT * " &
    cSelCurrencyRate & ")) AS RRP, ((sp.NETAMOUNT * " & cSelCurrencyRate & ") +
    (sp.TAXAMOUNT * " & cSelCurrencyRate & ")) AS PRICE FROM STOCK s, STOCKDESCS
    sd, STOCKPRICES sp WHERE s.STOCKID=sd.STOCKID AND s.STOCKID=sp.STOCKID AND
    sd.LANGID='" & cSelLang & "' AND s.SPECIAL=1"

    ELSE

    strSQLQuery = "SELECT s.STOCKID, s.THUMBPIC, sd.STOCKNAME, sd.SHORTDESC,
    (sp.RRPNETAMOUNT + sp.RRPTAXAMOUNT) AS RRP, (sp.NETAMOUNT + sp.TAXAMOUNT) AS
    PRICE FROM STOCK s, STOCKDESCS sd, STOCKPRICES sp WHERE s.STOCKID=sd.STOCKID
    AND s.STOCKID=sp.STOCKID AND sd.LANGID='" & cSelLang & "' AND s.SPECIAL=1"

    END IF

    I then execute whichever query string is relevant.

    Rgds

    Laphan


    Laphan <news@DoNotEmailMe.co.uk> wrote in message
    news:ONxroEQMEHA.1388@TK2MSFTNGP09.phx.gbl...
    Hi All

    As per my previous posting, I'm having trouble getting my schema out of my
    DB so you will have to bear with me on this.

    Basically I have the following tables (PLEASE NOTE: these are me
    pseudo-trying to create DDL - apologies for errors):

    CREATE TABLE STOCK
    (STOCKID TEXT(30) NOT NULL PK,
    CATID TEXT(30) NOT NULL,
    MANUID TEXT(30) NOT NULL,
    TAXID TEXT(30) NOT NULL,
    PIC TEXT(50) NULL,
    THUMBPIC TEXT(50) NULL,
    UNIT TEXT(50) NULL,
    WEIGHT INTEGER NULL,
    QTYINSTOCK INTEGER
    NEWSTOCK INTEGER
    DISCON BYTE
    SPECIAL BYTE
    LASTUPDATE DATE/TIME);

    CREATE TABLE STOCKDESCS
    (STOCKID TEXT(30) NOT NULL,
    STOCKNAME TEXT(50) NOT NULL,
    SHORTDESC TEXT(255) NULL,
    FULLDESC MEMO NULL,
    LANGID TEXT(30) NOT NULL);

    CREATE TABLE STOCKPRICES
    (STOCKID TEXT(30) NOT NULL,
    CURRENCYID TEXT(30) NOT NULL,
    RRPNETAMOUNT DECIMAL(18,3) NULL,
    RRPTAXAMOUNT DECIMAL(18,3) NULL,
    NETAMOUNT DECIMAL(18,3) NULL,
    TAXAMOUNT DECIMAL(18,3) NULL);

    Not actually sure if I should have the above price amounts set to
    DECIMAL(18,3), but I read that I should use the decimal option as it is more
    accurate and the Access default is 18,3

    Anyway this isn't the problem. My prob is that if I run the below query:

    strSQLQuery = "SELECT s.STOCKID, s.THUMBPIC, sd.STOCKNAME, sd.SHORTDESC,
    (sp.RRPNETAMOUNT + sp.RRPTAXAMOUNT) AS RRP, (sp.NETAMOUNT + sp.TAXAMOUNT) AS
    PRICE FROM STOCK s, STOCKDESCS sd, STOCKPRICES sp WHERE s.STOCKID=sd.STOCKID
    AND s.STOCKID=sp.STOCKID AND sd.LANGID='" & cSelLang & "' AND
    sp.CURRENCYID='" & cSelCurrency & "' AND s.SPECIAL=1"

    I get the cartisan (sp?) result that there has to be entries in the
    STOCKDESCS and STOCKPRICES tables in order to bring back the records for the
    selected lang and currency, ie cSelCurrency and cSelLang.

    The reason for my query is that my ASP page has pop-up options for different
    currencies and languages. The only problem is that the above query really
    only works if the admin user has religiously entered descs and prices for
    each currency and language.

    I need it that if the prices and/or descs aren't entered then I still bring
    back the rest of the data.

    I'm putting in flags so that the user can omit the necessary langs and
    currencies so missing data won't look odd.

    Is it all to do with these outer joins again?

    Your help would be appreciated.

    Rgds

    Laphan






    Laphan Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139