Link to home
Create AccountLog in
Avatar of gbcbr
gbcbrFlag for Cyprus

asked on

String Symbol recognizing

I extract date from different tables with sql query:
From one table, where symbol inserts by trigger from another table it recognized well
 
"SELECT * FROM EURUSD where timest = ( select max( timest ) from EURUSD ) and rownum = 1 union all "
..........

                if (s.equals("EUR/USD")) {

                    symbol[0] = s;
                    openBid[0] = bpx;
                    timest[0] = tst;

...........

                    System.out.println("   Symbol  " + symbol[0] +
                                       "  openBid[0]  " + openBid[0] +
                                       "    timest[0]    " + timest[0]);

...........

CREATE TABLE "LIONFX"."EURUSD"
  (
    "ID"     NUMBER NOT NULL ENABLE,
    "SYMBOL" VARCHAR2(20 BYTE),
    "BIDPX" FLOAT(126),
    "ASKPX" FLOAT(126),
    "TIMEST" TIMESTAMP (0),

.............

 Symbol  EUR/USD  openBid[0]  1.34373    timest[0]    2011-10-07 12:09:53.0

Open in new window

from another table with default value in column symbol, it doesn't recognize symbol and doesn't create array.
 
CREATE TABLE "LIONFX"."EURUSD_BOT_BUY"
  (
    "BUY_PX" VARCHAR2(20 BYTE),
    "TS" TIMESTAMP (6) NOT NULL ENABLE,

Open in new window

for it's stance that I don't see this column in sql generated by sqldeveloper, but I see it in columns bookmark Symbol-column.tiff
 
"SELECT * FROM EURUSD_BOT_BUY where ts = ( select max( ts ) from EURUSD_BOT_BUY ) and rownum = 1 

............


            for (DataBuy data : dataList) {

                String s;
                Timestamp ts;
                String bot_buy;

                s = data.getSymbol();
                ts = data.getTs();
                bot_buy = data.getBuyPx();
                bb = Double.parseDouble(bot_buy);

                System.out.println("   Symbol  " + s + "   buy_px  " +
                                   bot_buy + "   bb   " + bb);


                if (s.equals("EUR/USD")) {

                    symbol[0] = s;
                    buy_px[0] = bb;
                    ts_buy[0] = ts;
......

                    System.out.println("   Symbol  " + symbol[0] +
                                       "    ts_buy[0]    " + ts_buy[0] +
                                       "   buy_px[0]  " + buy_px[0]);

......

   Symbol  EUR/USD  openBid[0]  1.34373    timest[0]    2011-10-07 12:09:53.0
   Symbol  EUR/USD   buy_px  1.34357   bb   1.34357
   Symbol  EUR/USD  openBid[0]  1.34371    timest[0]    2011-10-07 12:10:01.0
   Symbol  EUR/USD   buy_px  1.34357   bb   1.34357

Open in new window

Avatar of Sean Stuber
Sean Stuber

I'm not entirely sure what your question is  but as long as you've got my attention...
 this construct is not very efficient...

SELECT * FROM EURUSD_BOT_BUY where ts = ( select max( ts ) from EURUSD_BOT_BUY ) and rownum = 1

that requires double access to the same table
try this instead.  change the "*"  to be the columns you really want

select * from
(SELECT t.*,row_number() over(order by ts desc) rn FROM EURUSD_BOT_BUY t )
where rn = 1
Avatar of gbcbr

ASKER

I use this query to get values every second from the last row because I need to build 1 sec charts and I need all columns value, especially symbol value I need for data separating and creating array.
But as you can see on output, it get symbol value, but this construction

(s.equals("EUR/USD"))

doesn't see it, and as a result doesn't create array
>>> I use this query to get values every second from the last row because I need to build 1 sec charts

all the more reason to do it efficiently.


as for the equals not working,  do you have whitespace in the field?  maybe you need to trim something.
>>
(s.equals("EUR/USD"))

doesn't see it, and as a result doesn't create array
>>

One simple explanation: 's' is empty

>> doesn't create array

As a point of fact, the array is already created. You're just setting the first element
Avatar of gbcbr

ASKER

>>One simple explanation: 's' is empty
's' not empty, this is the fact, please look at the code again.
This what I'm asking for.
I have clear printout for 's', but I can't use this value
>>> I have clear printout for 's', but I can't use this value

have you checked for whitespace?


EUR/USD
EUR/USD 

Open in new window


both look the same to me
note,  that second one has an extra space
Avatar of gbcbr

ASKER

I checked, no whitespace, I even try "'EUR/USD'"
nothing
Avatar of gbcbr

ASKER

and make varchar2 exactly 7 symbols Symbol-column2.tiff

either java is broken, or something you looked at isn't what you think it is
change your output to something like this...


System.out.println("   Symbol  >>>>" + s + "<<<<   buy_px  " +
                                   bot_buy + "   bb   " + bb);
Avatar of gbcbr

ASKER

Symbol  EUR/USD  openBid[0]  1.34711    timest[0]    2011-10-07 13:25:41.0
   Symbol  >>>>EUR/USD<<<<   buy_px  1.34745   bb   1.34745
   Symbol  >>>>EUR/CHF<<<<   buy_px  1.23887   bb   1.23887
   Symbol  EUR/USD   sell_px  1.34688   bs   1.34688
   Symbol  EUR/USD  openBid[0]  1.34704    timest[0]    2011-10-07 13:25:43.0
   Symbol  >>>>EUR/USD<<<<   buy_px  1.34745   bb   1.34745
   Symbol  >>>>EUR/CHF<<<<   buy_px  1.23887   bb   1.23887
   Symbol  EUR/USD   sell_px  1.34688   bs   1.34688

Open in new window

as you see it shows correct symbol for all queries, I just remove from previous outputs other queries.
You see it shows correct symbol for EUR/USD and for EUR/CHF as well.
I suppose it has to be some other construction to call value from DEFAULT.

As I ask from the beginning, why it doesn't show symbol column in generated sql? Symbol-column3.tiff
>> in generated sql?

Where is that happening - we don't see it above ..?

>>> why it doesn't show symbol column in generated sql?

> either java is broken, or something you looked at isn't what you think it is

oops, I forgot one other option:   or there is other code you haven't posted that is relevant to this problem
Avatar of gbcbr

ASKER

means sql which generated by SQLDeveloper as you can see when you will open Symbol-columns.tiff and Symbol-columns3.tiff
ASKER CERTIFIED SOLUTION
Avatar of Sean Stuber
Sean Stuber

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of gbcbr

ASKER

@sdstuber
There are three sets of tables.
First one is works perfect already 10 month.
Second and third just collect results of bot calculation, but they didn't have column 'symbol', you suggest to create column with default value. That's all.
No any other code relevant to this case.
how is the previous question about defaulting relevant here?

Your problem here is ...

you are expecting   s.equals("EUR/USD")  to return TRUE
but it returns FALSE

Is that correct?

The oracle tables are irrelevant to that evaluation.
Or maybe I'm misunderstanding what you're trying to show us

Avatar of gbcbr

ASKER

The problem was in incorrect position println