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
Oracle DatabaseJava

Avatar of undefined
Last Comment
gbcbr
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
gbcbr
Flag of Cyprus image

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
gbcbr
Flag of Cyprus image

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
gbcbr
Flag of Cyprus image

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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
Avatar of Sean Stuber
Sean Stuber

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of gbcbr
gbcbr
Flag of Cyprus image

ASKER

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

Java is a platform-independent, object-oriented programming language and run-time environment, designed to have as few implementation dependencies as possible such that developers can write one set of code across all platforms using libraries. Most devices will not run Java natively, and require a run-time component to be installed in order to execute a Java program.

102K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo