?
Solved

String Symbol recognizing

Posted on 2011-10-07
17
Medium Priority
?
336 Views
Last Modified: 2012-05-12
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

0
Comment
Question by:gbcbr
  • 8
  • 7
  • 2
17 Comments
 
LVL 74

Expert Comment

by:sdstuber
ID: 36930611
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
0
 

Author Comment

by:gbcbr
ID: 36930655
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
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 36930683
>>> 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.
0
Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

 
LVL 86

Expert Comment

by:CEHJ
ID: 36930688
>>
(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
0
 

Author Comment

by:gbcbr
ID: 36930707
>>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
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 36930722
>>> 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
0
 

Author Comment

by:gbcbr
ID: 36930751
I checked, no whitespace, I even try "'EUR/USD'"
nothing
0
 

Author Comment

by:gbcbr
ID: 36930797
and make varchar2 exactly 7 symbols Symbol-column2.tiff
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 36930805

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);
0
 

Author Comment

by:gbcbr
ID: 36930894
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
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 36930931
>> in generated sql?

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

Expert Comment

by:sdstuber
ID: 36930947

>>> 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
0
 

Author Comment

by:gbcbr
ID: 36930948
means sql which generated by SQLDeveloper as you can see when you will open Symbol-columns.tiff and Symbol-columns3.tiff
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 2000 total points
ID: 36930988
I'm sorry, I don't see the relevance of the sql developer images

is there other other code you're not showing us?

try this....

System.out.println("   Symbol  >>>>" + s + "<<<<   buy_px  " +
                                   bot_buy + "   bb   " + bb);
if (s.equals("EUR/USD")) { System.out.println("Yes  equals works"); }

Open in new window



if, later on  equals does not work,  then it must be some intervening code
0
 

Author Comment

by:gbcbr
ID: 36930997
@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.
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 36931028
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

0
 

Author Closing Comment

by:gbcbr
ID: 36931030
The problem was in incorrect position println
0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
Suggested Courses
Course of the Month15 days, 3 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question