Link to home
Start Free TrialLog in
Avatar of gbcbr
gbcbrFlag for Cyprus

asked on

Insert into Oracle table column with permanent value

I need to add column which will have permanent string value.
I have tables which have two columns each one, when I execute SELECT from all of them I need to have identification column.
Let's say this sample of query so I need to add column SYMBOL, so I can separate these data into array by this way.
 I know that I can make trigger and insert EUR/USD and other symbols each time when inserting value in specified table.
But I need to create 50 triggers by this way.
Please advice
Avatar of stergium
stergium
Flag of Greece image

you can alter the query by adding a 'eur/usd' symbol column like this
  //          "SELECT 'whatever you want to show here' SYMBOL, x.* FROM EURUSD_BOT_SELL  x where timest = ( select max( timest ) from EURUSD_BOT_SELL ) and rownum = 1 union all " +...
hope that helps
Avatar of gbcbr

ASKER

No, this will complicate my code.
Main question is to create two arrays according to currency pairs and use pair symbol as identification, so I will only add to the existing query:
 
String s = data.getSymbol();
double bpx = data.getOpenBid();
String bb = data.getBotBuy();

if (s.equals("EUR/USD")) {
openBid[0] = bpx;

botBuy[0] = bb;

Open in new window

and I will have as much arrays as I need.
Avatar of Sean Stuber
Sean Stuber

 if it's a value needed at insert just use column default values  - no need for triggers or default values



alternately,  use a table with lookups,  can you give an example of what you're trying to do?

inputs and expected outputs
Avatar of gbcbr

ASKER

When I created these tables, I'm especially make them separated by names to see separated data in each table.
public void statistic_EURUSD_S(boolean bl0) throws SQLException,
                                                       ClassNotFoundException,
                                                       InstantiationException,
                                                       IllegalAccessException {

        if (bl0 == false) {
            ts = new java.util.Date();
            sell_px[0] = DCC.getInstance().getSellPriceEURUSD();
            System.out.println(" EUR/USD Sell signal  at  " + ts +
                               "  : with price =  " + sell_px[0]);

            lionconn.insertBotResult(sell_px, buy_px, ts);
        } else {

        }
    }

Open in new window

CREATE TABLE "LIONFX"."EURUSD_BOT_BUY"
  (
    "BUY_PX" VARCHAR2(20 BYTE),
    "TS" TIMESTAMP (6) NOT NULL ENABLE,............

Open in new window

At the moment I need to use this tables for charts creating together with with another table, but this table full and has all columns
CREATE TABLE "LIONFX"."EURUSD"
  (
    "ID"     NUMBER NOT NULL ENABLE,
    "SYMBOL" VARCHAR2(20 BYTE),
    "BIDPX" FLOAT(126),
    "ASKPX" FLOAT(126),
    "TIMEST" TIMESTAMP (0),.......

Open in new window

So, I want to use the same query
String s = data.getSymbol();
double bpx = data.getOpenBid();
String bb = data.getBotBuy();

if (s.equals("EUR/USD")) {
openBid[0] = bpx;

botBuy[0] = bb;

Open in new window

where String bb will be value from BUY_PX column
Avatar of gbcbr

ASKER

@sdstuber
of course I can change application code and insert "EUR/USD" value, but this is big enough job for 50 tables.
So, I just try to minimize my job. This reason why I suppose that much easy to insert in each table just one more column with permanent value.
Thank you
ASKER CERTIFIED SOLUTION
Avatar of Franck Pachot
Franck Pachot
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gbcbr

ASKER

this is exactly what I'm asking for. Thank you