Select count(*) returns double?

I have executed a 'select count(*) from ...' statement through ODBC against Oracle9i and I am very supprised that the returned ODBC type is a 'double' and not an 'int' (or a 'numeric').
Is this really correct?

Did you ever get a response or figure this out?
My problem is fairly simliar, but specific to an 11.1.0.7 and onward release of the Oracle Client.
Current C++ Application using ODBC API calling Oracle Client 10g (all versions), 11gR1 (v11.1.0.6) returns a LONG (4-byte integer) for "SELECT COUNT(*) from tablename"
Change Oracle client to 11gR1 (v11.1.0.7) or higher (11.2.x.y etc) and that same statement returns a DOUBLE (8-byte floating value equivalent to oracle NUMBER data type).
Since the backend DB is the same version, there must be a client side setting (I presume) that has changed the default behaviour of this Aggregate SQL function to return a double rather than a long. I'm hoping to find such a setting that I can either set programmatically through an ODBC API call, or in the Oracle Client configuration itself.
I even tried using SQL CAST to make it an INT SELECT CAST(COUNT(*) AS INT) FROM tablename but that still returns a DOUBLE (8-byte floating NUMBER).
Note: given that I use ODBC, I've written alot of generic C++ code supporting the return value as LONG, as that is how it's been for 10 years via ODBC. I'd like to maintain that if possible without having to write ORACLE specific code within my applications.

Similar Messages

  • "select count(*)" and "select single *" returns different result

    Good day!
    product version SAP ECC 6.0
    oracle10
    data transfers from external oracle db into customer tables using direct oracle db link
    sometimes I get case with different results from 2 statements
    *mytable has 10 rows
    *1st statement
    data: cnt type I value 0.
    select count( * ) into cnt from mytable WHERE myfield_0 = 123 and myfield_1 = '123'.
    *cnt returns 10 - correct
    *2nd statement
    select single * from  mytable WHERE myfield_0 = 123 and myfield_1 = '123'.
    *sy-dbcnt returns 0
    *sy-subrc returns 4 - incorrect, 10 rows are "invisible"
    but
    1. se16 shows correct row number
    2. I update just one row from "invisible" rows using se16 and 2nd statement returns correct result after that
    can not understand why
    thank you in advance.

    Thank you, Vishal
    but,
    general problem is that
    1. both statements have the same WHERE conditions
    2. 1st return resultset with data (sy-dbcnt=10), 2nd return empty dataset, but must return 1 in sy-dbcnt
    Yes, different meaning, you are right, but must 2nd must return 1, because of "select single *" construction, not 0.
    Dataset to process is the same, WHERE conditions are equal...
    I think the problem is that how ABAP interperets select count(*) and "select single *".
    Maybe "select count (*)" scans only PK from index page(s)? and "select single *" scans data pages? and something is wrong with that?
    I'm new in SAP and didn't find any SAP tool to trace dump of data and indexes pages with Native SQL.
    se16 shows all records.
    And why after simple manual update of just one record using se16 "select single *" returns 1?
    I've just marked one row to update, didn't change any data, then pressed "save".

  • DIfferent # of rows return using select * & select count(*)

    In debugging some code (OWB generated PL/SQL) I came across the situation where by a query with count(*) returns a value of 600 rows. The same where clause using select * reports only 300 rows selected. There are 600 rows to select.
    Any ideas why the difference ???
    The code:
    SELECT *
    FROM "STG_SYSTEM_CUSTOMER_V" "STG_SYSTEM_CUSTOMER_V",
    DW_REPRESENTATIVE INGRP8
    where "STG_SYSTEM_CUSTOMER_V"."PILLAR_STATE_CD" IN 'VIC'
    AND "STG_SYSTEM_CUSTOMER_V"."BUS_PILLAR_CD" = 'IGA'
    AND ( "STG_SYSTEM_CUSTOMER_V"."MN_COMP_CD" = "INGRP8"."MN_COMP_CD" (+) )
    AND ( "STG_SYSTEM_CUSTOMER_V"."COUNTRY_CD" = "INGRP8"."COUNTRY_CD" (+) )
    AND ( "STG_SYSTEM_CUSTOMER_V"."COMP_CD" = "INGRP8"."COMP_CD" (+) )
    AND ( "STG_SYSTEM_CUSTOMER_V"."BUS_PILLAR_CD" = "INGRP8"."BUS_PILLAR_CD" (+) )
    AND ( "STG_SYSTEM_CUSTOMER_V"."PILLAR_STATE_CD" = "INGRP8"."PILLAR_STATE_CD" (+) )
    AND ( "STG_SYSTEM_CUSTOMER_V"."SUPP_DIVISION_CD" = "INGRP8"."DIVISION_CD" (+) )
    AND ( "STG_SYSTEM_CUSTOMER_V"."ALM_REP_NUM" = "INGRP8"."REP_NUM" (+) )
    Cheers
    Pav

    You're sure that the only difference between the two statelents is that "*" is replaced with "count(*)"? Assuming there are no transactions going on simultaneously, that would be a bug. Have you installed the latest patchset to your database?
    Justin
    Distributed Database Consulting, Inc.
    www.ddbcinc.com

  • Select Count(*) from... returns zero, select * from... returns 4000 recs?

    Hi,
    I have an odd situation where "select count(*) from my_view where some_clause" returns 0, but the exact same query fetching the data (ie "select * from my_view where some_clause") works fine and fetches, correctly, 4000+ records.
    I have tried dropping and recreating the view, and collecting DB stats again, but the problem persists.
    I had a look at the explain plans and they are very different, but both the SQL statements work fine on a copy of the database taken with impdp.
    Does anyone have any suggestions on what might be going on here ?
    Any help would be appreciated, I've run out of ideas !
    Dave
    Edited by: user10281551 on 18-Sep-2008 00:43
    Edited by: user10281551 on 18-Sep-2008 00:44

    Maybe it's the bug that a function based index is present and gets incorrectly used in the select count(*) statement?
    If that's not the case, then please show us more details, like the statement and both execution plans.
    Regards,
    Rob.

  • Select count(Key_Field) from table_name never returns

    I am doing some scalability tests and am building a db w/table that will contain 400Million records. I am trying to see how far along I am in the process, and am experiencing this problem.
    The select count(ID) never returns.
    Does anyone have any suggestions for me as to how i might make it perform better? I am not too familiar with such large scale implementations, so any advice would be appreciated, and you can feel free to tell me the most basic info... (I do read docs, etc, but there might be a place I have not yet searched..)
    The hardware is not an issue, at least for my testing, as it is as follows, and I see the IO on the arrays is busy, but not too busy, and that is to be expected, and we are neither CPU or RAM bound.
    SUN E4800
    12 CPUs
    48GB RAM
    2 T3 Arrays (fiber cards on different IO boards)
    4 internal drives (2 on each IO board), not mirrored or RAIDed

    This is always a troublesome type of query.
    Are you trying to count the number of all rows in a table? You can try to ANALYZE the table, then from user_tables select the NUM_ROWS
    I am doing some scalability tests and am building a db w/table that will contain 400Million records. I am trying to see how far along I am in the process, and am experiencing this problem.
    The select count(ID) never returns.
    Does anyone have any suggestions for me as to how i might make it perform better? I am not too familiar with such large scale implementations, so any advice would be appreciated, and you can feel free to tell me the most basic info... (I do read docs, etc, but there might be a place I have not yet searched..)
    The hardware is not an issue, at least for my testing, as it is as follows, and I see the IO on the arrays is busy, but not too busy, and that is to be expected, and we are neither CPU or RAM bound.
    SUN E4800
    12 CPUs
    48GB RAM
    2 T3 Arrays (fiber cards on different IO boards)
    4 internal drives (2 on each IO board), not mirrored or RAIDed

  • "select count(*) from dba_jobs_running" takes 5 minutes to return

    Hi,
    I login as sys or system from sql*plus to run query "select count(*) from dba_jobs_running". This query takes about 5 minutes to run.
    Querying other DBA_* views returns instantly, only this dba_jobs_running view is troubling.
    I have 11 records in dba_jobs, and 18 records in v$lock as usual.
    No error or warning in logfile, no trace file.
    What's possibly wrong with the server?
    Thanks,
    Harry

    Hi,
    The following are the exact statements I used to create the trace file:
    alter session set timed_statistics=true;
    alter session set max_dump_file_size=unlimited;
    alter session set events '10046 trace name context forever, level 12';
    select count(*) from dba_jobs_running;
    exit;
    The content of the trace file is attached at the end.
    If it is CPU bound, I have no activity on the db host. I am solely using it to analyze this problem.
    load averages: 0.02, 0.02, 0.07 22:16:38
    48 processes: 47 sleeping, 1 on cpu
    CPU states: 98.4% idle, 1.6% user, 0.0% kernel, 0.0% iowait, 0.0% swap
    Memory: 1792M real, 983M free, 517M swap in use, 2937M swap free
    PID USERNAME THR PRI NICE SIZE RES STATE TIME CPU COMMAND
    655 oracle 1 59 0 0K 0K sleep 1:14 0.32% oracle
    865 oracle 1 59 0 2072K 1184K cpu 0:00 0.14% top
    667 oracle 1 59 0 0K 0K sleep 0:13 0.08% oracle
    663 oracle 1 59 0 0K 0K sleep 0:27 0.07% oracle
    665 oracle 1 59 0 0K 0K sleep 0:15 0.02% oracle
    671 oracle 1 59 0 0K 0K sleep 0:00 0.02% oracle
    645 oracle 18 59 0 0K 0K sleep 0:23 0.01% oracle
    657 oracle 1 59 0 0K 0K sleep 0:14 0.00% oracle
    649 oracle 1 59 0 0K 0K sleep 0:02 0.00% oracle
    659 oracle 1 59 0 0K 0K sleep 0:01 0.00% oracle
    251 root 20 59 0 3256K 2512K sleep 0:00 0.00% nscd
    70 root 5 59 0 2864K 2096K sleep 0:00 0.00% picld
    224 root 3 59 0 3912K 2008K sleep 0:00 0.00% automountd
    271 root 1 59 0 4408K 1896K sleep 0:00 0.00% sendmail
    588 oracle 1 59 0 2600K 1864K sleep 0:00 0.00% bash
    Any help is greatly appreciated.
    <-- TRACE FILE CONTENT -->
    *** 2006-11-21 21:34:54.413
    *** SESSION ID:(21.832) 2006-11-21 21:34:54.412
    APPNAME mod='[email protected] (TNS V1-V3)' mh=0 act='' ah=0
    =====================
    PARSING IN CURSOR #1 len=69 dep=0 uid=0 oct=42 lid=0 tim=107123626140 hv=2004533713 ad='97219d80'
    alter session set events '10046 trace name context forever, level 12'
    END OF STMT
    EXEC #1:c=0,e=346,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=4,tim=107123625473
    WAIT #1: nam='SQL*Net message to client' ela= 11 p1=1650815232 p2=1 p3=0
    WAIT #1: nam='SQL*Net message from client' ela= 6476024 p1=1650815232 p2=1 p3=0
    =====================
    PARSING IN CURSOR #1 len=37 dep=0 uid=0 oct=3 lid=0 tim=107130104260 hv=2246554324 ad='97c21958'
    select count(*) from dba_jobs_running
    END OF STMT
    PARSE #1:c=0,e=548,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=4,tim=107130104237
    BINDS #1:
    EXEC #1:c=0,e=1412,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=4,tim=107130106034
    WAIT #1: nam='SQL*Net message to client' ela= 12 p1=1650815232 p2=1 p3=0
    *** 2006-11-21 21:40:53.931
    FETCH #1:c=350760000,e=344612113,p=0,cr=2,cu=16652,mis=0,r=1,dep=0,og=4,tim=107474718456
    WAIT #1: nam='SQL*Net message from client' ela= 1936 p1=1650815232 p2=1 p3=0
    FETCH #1:c=0,e=6,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=0,tim=107474721309
    WAIT #1: nam='SQL*Net message to client' ela= 8 p1=1650815232 p2=1 p3=0
    *** 2006-11-21 21:56:30.972
    WAIT #1: nam='SQL*Net message from client' ela= 915075702 p1=1650815232 p2=1 p3=0
    XCTEND rlbk=0, rd_only=1
    STAT #1 id=1 cnt=1 pid=0 pos=1 obj=0 op='SORT AGGREGATE (cr=2 r=0 w=0 time=100535896 us)'
    STAT #1 id=2 cnt=0 pid=1 pos=1 obj=0 op='NESTED LOOPS (cr=2 r=0 w=0 time=100535876 us)'
    STAT #1 id=3 cnt=5550 pid=2 pos=1 obj=0 op='MERGE JOIN CARTESIAN (cr=2 r=0 w=0 time=128639 us)'
    STAT #1 id=4 cnt=10 pid=3 pos=1 obj=0 op='NESTED LOOPS OUTER (cr=2 r=0 w=0 time=5839 us)'
    STAT #1 id=5 cnt=10 pid=4 pos=1 obj=69 op='FIXED TABLE FULL X$KSQRS (cr=0 r=0 w=0 time=4790 us)'
    STAT #1 id=6 cnt=10 pid=4 pos=2 obj=202 op='INDEX UNIQUE SCAN OBJ#(202) (cr=2 r=0 w=0 time=561 us)'
    STAT #1 id=7 cnt=5550 pid=3 pos=2 obj=0 op='BUFFER SORT (cr=0 r=0 w=0 time=90039 us)'
    STAT #1 id=8 cnt=555 pid=7 pos=1 obj=16 op='FIXED TABLE FULL X$KSUSE (cr=0 r=0 w=0 time=1277 us)'
    STAT #1 id=9 cnt=0 pid=2 pos=2 obj=0 op='VIEW (cr=0 r=0 w=0 time=344148954 us)'
    STAT #1 id=10 cnt=105477 pid=9 pos=1 obj=0 op='UNION-ALL (cr=0 r=0 w=0 time=343814331 us)'
    STAT #1 id=11 cnt=105476 pid=10 pos=1 obj=0 op='VIEW (cr=0 r=0 w=0 time=203487737 us)'
    STAT #1 id=12 cnt=105476 pid=11 pos=1 obj=0 op='UNION-ALL (cr=0 r=0 w=0 time=202961626 us)'
    STAT #1 id=13 cnt=0 pid=12 pos=1 obj=272 op='FIXED TABLE FULL X$KDNSSF (cr=0 r=0 w=0 time=13633786 us)'
    STAT #1 id=14 cnt=105476 pid=12 pos=2 obj=72 op='FIXED TABLE FULL X$KSQEQ (cr=0 r=0 w=0 time=188317145 us)'
    STAT #1 id=15 cnt=0 pid=10 pos=2 obj=253 op='FIXED TABLE FULL X$KTADM (cr=0 r=0 w=0 time=76301426 us)'
    STAT #1 id=16 cnt=1 pid=10 pos=3 obj=254 op='FIXED TABLE FULL X$KTCXB (cr=0 r=0 w=0 time=62693462 us)'
    STAT #1 id=16 cnt=1 pid=10 pos=3 obj=254 op='FIXED TABLE FULL X$KTCXB (cr=0 r=0 w=0 time=62693462 us)'
    <---- END of TRACE FILE -->

  • 'select count(*) from x' returns 5460 rows and 'Select * from x' returns 0 rows

    As you can see in the next lines something is wrong in my Oracle (8.0.6 on Win NT 4.0 sp 6a) :
    Oracle8 Enterprise Edition Release 8.0.6.0.0 - Production
    With the Partitioning option
    PL/SQL Release 8.0.6.0.0 - Production
    SQLWKS> SELECT * FROM V_TERRA_TE;
    PERIOD_DATE PERIOD_TIME TERRARCV TERRASND TERCV TESND
    0 rows selected.
    SQLWKS> SELECT COUNT(*) FROM V_TERRA_TE;
    COUNT(*)
    5460
    1 row selected.
    V_TERRA_TE is a complex join of 5 Tables :
    CREATE OR REPLACE VIEW "ACTUATE".V_TERRA_TE AS Select to_date(to_char(p1.period_date,'YYYYMMDD'),'YYYYMMDD') "PERIOD_DATE",
    to_date(to_char(p1.period_time,'HH24:MI'),'HH24:MI') "PERIOD_TIME",
    to_number(p1.caudalrcv + ((p3.caudalrcv + p4.caudalrcv)*(confterrate.conexadslterra/confterrate.conexadsltotal))) "TERRARCV",
    to_number(p1.caudalsnd + ((p3.caudalsnd + p4.caudalsnd)*(confterrate.conexadslterra/confterrate.conexadsltotal))) "TERRASND",
    to_number((p2.caudalrcv * confterrate.pctinfonegocio) + ((p3.caudalrcv + p4.caudalrcv)*(confterrate.conexadslte/confterrate.conexadsltotal)))"TERCV",
    to_number((p2.caudalsnd * confterrate.pctinfonegocio) + ((p3.caudalsnd + p4.caudalsnd)*(confterrate.conexadslte/confterrate.conexadsltotal)))"TESND"
    from p1,p2,p3,p4,confterrate
    where (p1.period_date=p2.period_date)and
    (p1.period_date=p3.period_date)and
    (p1.period_date=p4.period_date)and
    (p1.period_time=p3.period_time)and
    (p1.period_time=p4.period_time)and
    (p1.period_time=p2.period_time)and
    to_char(p1.period_date,'MMYYYY')=to_char(confterrate.period_datetime,'MMYYYY');
    I think that some not reported error happens in the select * with some temporary space or similar but only the message '0 rows selected' is displayed (instead the real error)
    Could somebody help me ?
    Thanks in advance
    Francisco

    Forcing the Join/sort to be made on Disk (not on memory) the problem not happens. This demostrate that ORACLE has a VERY IMPORTANT BUG : It returns 0 rows wich is false.
    To force it to work on disk i use this parameters :
    alter session set sort_area_size=0
    alter session set hash_join_enabled=false
    Note : probably is not the best combination or use of parameters, but using it the query works as espected.

  • How to run a select count(*) with multiple rows returned

    Hi,
    I have to run a select count(*) for different reports.
    1) Select count(*) from table
    where state = 'CA'
    2) Select count(*) from table
    where state = 'NY'
    3) Select count(*) from table
    where state = 'NV'
    Instead of running this query again for 50 times, is there a way for me to just put it in one query and get multiple row returns? Thank you.

    Samantha wrote:
    Hi,
    I have to run a select count(*) for different reports.
    1) Select count(*) from table
    where state = 'CA'
    2) Select count(*) from table
    where state = 'NY'
    3) Select count(*) from table
    where state = 'NV'
    Instead of running this query again for 50 times, is there a way for me to just put it in one query and get multiple row returns? Thank you.select state, count(*) from table group by state order by 1;

  • Select count(*) on sql statement returning zero when a matching row exists.

    Our account has an ANSI C application that checks for the existence a row on an Oracle table(s) by using the following SQL:
    int iCount = 0;
    EXEC SQL
    SELECT count(rownum) INTO :iCount
    FROM sys.all_tab_columns
    WHERE table_name IN
    (SELECT table_name FROM
    sys.all_synonyms
    WHERE upper(synonym_name) = upper(:szDestTable))
    AND upper(column_name) = upper(:szColumnName)
    AND owner = 'DBAUSER';
    The bind variables szDestTable and szColumnName are populated with values parsed from columns on another database table. This application is executed through out the day. Occasionally, the application will report a zero in the iCount when there should be a match. I have verified the szDestTable and szColumnName are populated with the correct values which would find a match and they are correct. To make matters even stranger, the application will parse the same input values and find a match (as it should). At some point during the day, and it can be at any time, the application will NOT find a match on the same file, same values. Every subsequent execution of this application will not find a match on the same values. Once the database is brought down and started up in the evening for its normal backups, the application will find a match again on the same values. This problem does not occur every day. I could be a week or a week and a half between incidents.
    I printed the contents of the sqlca.sqqlerrm.sqlerrmc field to a log file. The sqlca.sqlerrm.sqlerrmc field reported an ORA-1405 bind variable was null when the iCount was reporting a zero. When I compiled this application, I set the Proc*C flag to UNSAFE_NULLS=yes since there are other bind variable in the application that can be NULL and that is ok.
    The above SQL is compiled into the C application using the Proc*C compiler. It is compiled using the Oracle 11.2.0.2 libraries. The application is executed against an Oracle 11.2.0.2 database. The database and application are executed on an HP/Unix 11.31 platform.
    This problem did not start occurring until our account went from Oracle 10.2 to Oracle 11.2. Recently, I have changed the SQL to perform a “SELECT COUNT(rownum)” instead of the “SELECT COUNT(*)”. I compiled the application and executed the new application with the SELECT COUNT(rownum) against the same database where the same application with the SELECT COUNT(*) was failing to find a row that actually existed. The application with the SELECT COUNT(rownum) found the matching row as it should have. The new application has been executing in production for about 10 days now without any problems against ten various Oracle 11.2 databases.
    Why would SELECT COUNT(*) and SELECT COUNT(rownum) be any different?

    This forum is about C programming in general, and about using Studio C in particular.
    Your question is about Oracle database programming. You are more likely to find a helpful answer in a forum about database programming. Start here:
    https://forums.oracle.com/forums/category.jspa?categoryID=18

  • Using / returning double

    Hey peeps
    after some guidance
    ok, so my lecturer for programming is quite well known in the java world, although thats probs going to get shot down now :D he wrote bluej and the text book objects first. This week he set me an assignment and i have done all the base tasks and all the challenge tasks, but we get marked for comment considteny and layout of brackets etc to.
    so one of the challenge tasks was to return an avergae playing time using double, is the correct way, the 100% correct way of doing this
        public double averageTrackLength()
            return (double) totalPlayingTime / tracksPlayed;
        }or does it need editing
    thanks very much

    ok, i think i worded it wrong, what i mean is, have i used the double function correctly, as in, to return a double value to you only need
    public double averageTrackLength()
            return (double) totalPlayingTime / tracksPlayed;
        }becuase some people online from what i have read suggest this is how to do ti
    public double divide(){
       return (double)x / (double)y;
    }which is "correct"? :D
    also, finally, sorry to get on all of your tits, i have a concern with my commenting, have i just over killed commenting :D
    * This class is used to interact with the interface in order
    * to let the user play the appropriate songs. Checks are in
    * order to ensure that valid entry of selection means no
    * programme crashes, and all relevant fields have been initialised.
    * The track is selected by the user, then they can push play
    * on the interface, once this is done, if a new track is selected
    * the current track will stop, be reset to the beginning, and on
    * the users selection of play, the new track shall begin. The stop
    * button allwos the user to stop the track, at which point it rewinds
    * it to the beginning again.
    * @author Ricki Lambert
    * @version 0.1 (19/10/2008)
    public class Player
        private PlayList playList; //Holds an object of PlayList class
        private Track track; //Holds an object of Track class
        private int tracksPlayed; //Used to store the int sum of tracks played
        private int totalPlayingTime; //Used to store the integer value of the toal playing time
         * This is the constructor for the Player class. It sets the
         * tracksPlayed field to 0 and the same for totalPlayingTime. Also
         * it creates a new playList from the Playlist class. Every object
         * of Player will now be initialised with these fields values.
        public Player()
            playList = new PlayList("audio");
            tracksPlayed = 0;
            totalPlayingTime = 0;
         * Return the track collection currently loaded in this player.
        public PlayList getPlayList()
            return playList;
         * This method is used to play music in the G.U.I
         * The method is called, and every time this happens, the counter adds
         *one to the tracksPlayed variable. Then we check if the variable (that holds an object of Track)
         *is null. If it is we return (exit the method) to avoid crashing the programme. If not, call the stop method
         *using an internal method call, then call the play method of the track object we created. At the end, we add
         *the total length of the track to the totalPlayingTime variable.
        public void play()
            tracksPlayed = tracksPlayed + 1;
            if (track == null){
                return;
            stop();
            track.play();
            totalPlayingTime = totalPlayingTime + track.getDuration();
         * Checks to see if the track object is null, if so exit the method
         * using return, if not, call the stop method of the track object and
         * then call the rewind method to put that track to the beginning.
        public void stop()
            if (track == null){
                return;
            track.stop();
            track.rewind();
         * To set the track we check if the track object is not null.
         * Then if it is call the stop method by
         * using an internal method call. Then we just assign the
         * track object to the playlists getTrack method (this uses
         * the parameter to pass the number required to the method)
        public void setTrack(int trackNumber)
            if (track != null){
                stop();
            track = playList.getTrack(trackNumber);
         * Get the track name and return it. If the track is null
         * then return an empty string, else return the tracks name
         * by calling the objects method
        public String getTrackName()
            if (track == null){
                return "";
            else{
            return track.getName();
         * Return information about the currently selected track. The information
         * contains the track name and playing time, in the format
         *    track-name (playing time)
         * Return an empty string if no track is selected.
        public String getTrackInfo()
            if (track == null){
                return "";
            else{
            return "The track is called " + track.getName() + " The Track lasts for " +
                    track.getDuration() + " seconds" ;
         * Return the integer value of the tracksPlayed variable
        public int getNumberOfTracksPlayed()
            return tracksPlayed;
         * Return the integer value of the totalPlayingTime variable
        public int getTotalPlayedTrackLength()
            return totalPlayingTime;
         * Return the result of totalPlayingTime divided by tracksPlayed
         * This is returned as a double data type value.
        public double averageTrackLength()
            return (double) totalPlayingTime / tracksPlayed;
    }Edited by: compSciUndergrad on Oct 19, 2008 12:58 PM
    Edited by: compSciUndergrad on Oct 19, 2008 12:58 PM

  • SSRS Report Returning Double Quote string from a Single Quote String

    Hi, I'm getting weird thing in resultset from SSRS report when executed. When I pass parameter to a report, which passes String that has single quote value to a split function , it returns rows with double quote. 
    For example  following string:
    'N gage, Wash 'n Curl,Murray's, Don't-B-Bald
    Returns: 
    ''N gage, Wash ''n Curl,Murray''s, Don''t-B-Bald
    through SSRS report.
    Here is the split function Im using in a report.
    CREATE Function [dbo].[fnSplit] (
    @List varchar(8000), 
    @Delimiter char(1)
    Returns @Temp1 Table (
    ItemId int Identity(1, 1) NOT NULL PRIMARY KEY , 
    Item varchar(8000) NULL 
    As 
    Begin 
    Declare @item varchar(4000), 
    @iPos int 
    Set @Delimiter = ISNULL(@Delimiter, ';' ) 
    Set @List = RTrim(LTrim(@List)) 
    -- check for final delimiter 
    If Right( @List, 1 ) <> @Delimiter -- append final delimiter 
    Select @List = @List + @Delimiter -- get position of first element 
    Select @iPos = Charindex( @Delimiter, @List, 1 ) 
    While @iPos > 0 
    Begin 
    -- get item 
    Select @item = LTrim( RTrim( Substring( @List, 1, @iPos -1 ) ) ) 
    If @@ERROR <> 0 Break -- remove item form list 
    Select @List = Substring( @List, @iPos + 1, Len(@List) - @iPos + 1 ) 
    If @@ERROR <> 0 Break -- insert item 
    Insert @Temp1 Values( @item ) If @@ERROR <> 0 Break 
    -- get position pf next item 
    Select @iPos = Charindex( @Delimiter, @List, 1 ) 
    If @@ERROR <> 0 Break 
    End 
    Return 
    End
    FYI: I'm getting @List value from a table and passing it as a string to split function. 
    Any help would be appreciated!
    ZK

    Another user from TSQL forum posted this code which is returning the same resultset but when I execute both codes in SQL server it works and return single quote as expected.
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/8d5c96f5-c498-4f43-b2fb-284b0e83b205/passing-string-which-has-single-quote-rowvalue-to-a-function-returns-double-quoate?forum=transactsql
    CREATE FUNCTION dbo.splitter(@string VARCHAR(MAX), @delim CHAR(1))
    RETURNS @result TABLE (id INT IDENTITY, value VARCHAR(MAX))
    AS
    BEGIN
    WHILE CHARINDEX(@delim,@string) > 0
    BEGIN
    INSERT INTO @result (value) VALUES (LEFT(@string,CHARINDEX(@delim,@string)-1))
    SET @string = RIGHT(@string,LEN(@string)-CHARINDEX(@delim,@string))
    END
    INSERT INTO @result (value) VALUES (@string)
    RETURN
    END
    GO
    ZK

  • Select * shows 1 record - select count(*) shows 2232 records

    Using SQL 2008 R2 and SS Import Wizard
    Imported Excel file into SQL Table.  No errors reported during import.
    Command:  Select * From XLImport
    returns 1 record
    Command: Select Count(*) From XLImport
    returns 2232
    What could be causing this ??
    Many thanks
    MisterT99

    I see what happened.
    A previous command issued 'Set ROWCOUNT 1'
    When I entered 'Set ROWCOUNT 0'  That fixed the problem.
    Thanks everyone for your comments.
    MisterT99
    Cool
    That now makes sense
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Select count into versus create table as in functions/procedures

    I am working on a dynamic PL/SQL script that will count the number of records in a remote database
    based on certain criteria and then if the number is "acceptable" will create a table in the connecting
    database with those records.
    My where clauses are supposed to be the same but I am presented with the problem, when I run the
    first code ... select in to rowcount I get 122000 records, when I later do the create table as
    with the same whereclause code, I get 77 records. So now I am attempting to validate that the two
    where clauses are the same ... you'd think it would be obvious, but it's not.
    My first operation does a select count(*) into rowcount with the where clause behind it.
    The second operations creates a "sql command literal' that gets executed and returns the less value.
    I build it like testscript := 'create table '||tablename ||'as select * from '||remotetablename||'@'||linkname;
    testwhere := ' xxxxxxx'
    then I do an execute immediate teststring ||' ' testwhere; which works but gives me 77 rows in the table.
    Since I believe my where clause might be different, how can I run the first operation ... select count into rowcount
    as a normal SQL statement in the script...
    When I attempt to just run it I get -- PLS-00428: an into clause expected in this select statement......
    I will provide the source code in my next posting. Working to get it moved to this system.. Once you see it you'll understand
    why I don't think, it's the same, but I need a way to run them exactly as they are written to understand the different results.
    so How can I make the select count (*) into rowcount from .... work just like a normal select

    Here is first part of the procedure --- I get returned value of 122000 records ....
    SELECT COUNT (*)
                   INTO ROWCOUNT
                   FROM A_K_A_D_TBL@FCA08_INGRES
                   WHERE (( "a_" = '1' OR "a_" = '6' ) AND
                             ( "d_t" <> '3' OR "k_c_s" = 'Y' ) AND
                             "d_d" < DATECUTOFFDATE AND
                        "k_c_d" < DATECUTOFFDATE )OR
    (( "a_" = 4 OR "a_" = 7 ) AND
                             ( "d_t" <> '3' OR
    "k_c_s" = 'Y' OR
    "r_t" = '0' OR
                        "r_t" = '2' OR
                   "r_t" = '3' ) AND
                        "d_d" < DATECUTOFFDATE AND
                        "k_c_d" < DATECUTOFFDATE AND
                        "r_d" < DATECUTOFFDATE AND
                        "s_d" < DATECUTOFFDATE);
    then I attempt to duplicate it for string literals.... when this runs ... I get only 77 records. So that makes me think that my strings are not
    done properly.
    So I want to try to run the first sql itself ... but then I get the errors about needing select into ..... etc..
                   TESTWHERE := q'[WHERE (( "a_" = '1' OR "a_" = '6' ) AND ( "d_t" <> '3' OR "k_c_s" = 'Y' )]'||
              q'[ AND "d_d" < DATE ']'||TO_CHAR(DATECUTOFFDATE,'YYYY-MM-DD')||q'[']'||
                             q'[ AND "k_c_d" < DATE ']'||TO_CHAR(DATECUTOFFDATE,'YYYY-MM-DD')||q'[')]'||
                             q'[ OR (( "a_" = 4 OR "a_" = 7 )]'||
                             q'[ AND ( "d_t" <> '3' OR "k_c_s" = 'Y' OR "r_t" = '0' OR "r_t" = '2' OR "r_t" = '3' )]'||
                             q'[ AND "d_d" < DATE ']'||TO_CHAR(DATECUTOFFDATE,'YYYY-MM-DD')||q'[']'||
                             q'[ AND "k_c_d" < DATE ']'||TO_CHAR(DATECUTOFFDATE,'YYYY-MM-DD')||q'[']'||
                             q'[ AND "r_d" < DATE ']'||TO_CHAR(DATECUTOFFDATE,'YYYY-MM-DD')||q'[']'||
                             q'[ AND "s_d" < DATE ']'||TO_CHAR(DATECUTOFFDATE,'YYYY-MM-DD')||q'[')]';
                        TESTSTRING := 'CREATE TABLE '||UCASEXTABLENAMETEMP||' AS SELECT * FROM '||UCASEXTABLENAME||'@'||XLINKNAME;
                        DBMS_OUTPUT.PUT_LINE(TESTSTRING);
                        DBMS_OUTPUT.PUT_LINE(TESTWHERE);
                        EXECUTE IMMEDIATE TESTSTRING||' '||TESTWHERE;

  • SELECT COUNT(*)  bug

    I have a table named comments, with a column labeled book_id. In this column I have non-unique integer values (we'll say 2 rows contain the number 9)
    import flash.events.*;
    import flash.data.*
    import fl.controls.ComboBox;
    import flash.filesystem.File
    //Open database-------------------------------------------------------------
    var conn:SQLConnection = new SQLConnection();
    conn.addEventListener(SQLEvent.OPEN, openHandler);
    var dbFile:File = File.desktopDirectory.resolvePath("tarot.db");
    conn.openAsync(dbFile);
    //authorsCB.addEventListener(Event.CHANGE, loadBooks);
    function openHandler(event:SQLEvent):void
    var selectStmt:SQLStatement = new SQLStatement();
    selectStmt.sqlConnection = conn;
    // define the SQL text
    selectStmt.text = "SELECT COUNT(*) FROM comments2 WHERE book_id = 9";
    // register listeners for the result and failure (status) events
    selectStmt.addEventListener(SQLEvent.RESULT, readResultHandler);
    // execute the statement
    selectStmt.execute();
    // collect author data: author name and author ID. Populate authorCB with author name. authorID is used to match publications for the booksCB in the loadBooks() function
    function readResultHandler(event:SQLEvent):void
    var result:SQLResult = event.target.getResult();
    var numResults:int = result.data.length;
    for (var i:int = 0; i < numResults; i++)
    var row:Object = result.data[i];
    var bookID:uint = row.book_id;
    var book:String = row.book;
    var authorID:uint = row.author_id;
    //combo box named authorsCB
    authorsCB.addItem({label:bookID}); //assign table data to list box
    addChild(authorsCB);
    This code returns '0' even though my table contains two matching rows.
    If I change my select statement to "SELECT * FROM comments WHERE book_id = 9", that works.
    I'm trying to implement a query that will tell me if a particular value appears in this column. If that value appears in the table, then I want to run another query to extract the associated data.
    Ultimately I'm loading combo box 1 with author names, and combo box 2 with book titles. I then want to run a 3rd query against my comments table. My comments table contains notes about the various books, but I don't have notes about every title, so I need to test if there are comments in the table before I try to extract those comments in order to avoid throwing an error.

    Okay, I got it.
    It's very difficult to find documentation on precisely HOW Adobe AIR implements some of the more obscure functions in SQLite. Even though SELECT COUNT(*) works in the Firefox SQLite Manager, it doesn't work the same way in AIR.
    Through reviewing  the COUNT(*) function in "Learning SQL" by O'Reilly, there was an example utilized in which you point to the column you want counted BEFORE the COUNT(*) function.
    So, it becomes:
    SELECT columnName, COUNT(*)  someColumnName (optional) FROM someTable etc, etc.
    After the FROM clause you could use a WHERE, or a GROUP BY.
    Keep in mind that a GROUP clause runs after a WHERE clause.

  • Select Count(*) and actual row are differ: 136 rows vs 65k x 7 rows

    Dear All,
    Good morning. Need your advices. We had a view which is running and producing output to excel files. But recently after one of ours database migration, it were producing differ result: Select Count(*) and actual row are differ: 136 rows vs 65k x 7 rows. Error happen when we export out the row to csv file is produced 65000 rows x 7 worksheep. But when perform select count(*) from RTNEWWIP, result return: 136 rows.
    Is there any way to trace below sql to find where go wrong?
    The Veiw as below:
    CREATE OR REPLACE VIEW RTNEWWIP
    (FAB_ID, PO, PRD_NO, SHP_PRD_NO, LOT,
    WIP_QTY, ROUTEDESC, IN_TIME, STAY_DAY, BACK_DAY,
    WO_FCST_DATE, SHIP_FCST_DATE, SHIP_CONF_DATE, WS_DATE, ROUTERATIO,
    PROCESS, LOTSTATUS, LOTTYPE, RETICLEVERSION, PROCESSVERSION,
    ROUTESEQUENCE, PRIORITY, PROCESSGEN, PROCESSFAMILY)
    AS
    select
    --ord.order_no,
    'SILTERRA' FAB_ID,
    wip.PO_NUMBER PO,
    wip.FW_DEVICE PRD_NO,
    wip.USER_ITEM_DESCRIPTION SHP_PRD_NO,
    wip.LOT_ID LOT,
    wip.CURR_QTY WIP_QTY,
    wip.STEP_DESC ROUTEDESC,
    to_char(wip.RECORD_START_DATE,'DD-MON-YYYY HH24:MI:SS') IN_TIME,
    to_char((sysdate - wip.RECORD_START_DATE),'9999D99') STAY_DAY,
    to_char((wip.SCHEDULED_COMPLETE_DATE - sysdate),'9999D99') BACK_DAY,
    -- (sysdate - wip.RECORD_START_DATE) STAY_DAY,
    -- (wip.SCHEDULED_COMPLETE_DATE - sysdate) BACK_DAY,
    to_char(wip.SCHEDULED_COMPLETE_DATE,'DD-MON-YYYY') WO_FCST_DATE,
    to_char((wip.SCHEDULED_COMPLETE_DATE + 1),'DD-MON-YYYY') SHIP_FCST_DATE,
    --nvl(oel.attribute15, to_char(sysdate+3650,'DD-MON-YYYY')) SHIP_CONF_DATE,
    to_char(nvl(to_date(oel.attribute15,'DD-MON-YYYY'), sysdate+3650),'DD-MON-YYYY') SHIP_CONF_DATE,
    to_char(wip.LOT_START_DATE,'DD-MON-YYYY') WS_DATE,
    --wip.MASK_NO || '/' || wip.MASK_TOTAL ROUTERATIO,
    '''' ||wip.MASK_NO || '/' || wip.MASK_TOTAL ROUTERATIO,
    wip.PLAN_NAME_ACTIVE PROCESS,
    wip.LOT_STATUS LOTSTATUS,
    wip.LOT_TYPE LOTTYPE,
    0 RETICLEVERSION,
    wip.PLAN_VERSION_ACTIVE PROCESSVERSION,
    0 ROUTESEQUENCE,
    wip.PRIORITY PRIORITY,
    ' ' PROCESSGEN,
    ' ' PROCESSFAMILY
    from wip_report wip, lot_fact lf, order_fact orf, order_dim ord,
    apps.oe_order_headers_all@prod_myfabetl oeh,
    apps.oe_order_lines_all@prod_myfabetl oel
    where wip.CUSTNAME like 'Realtek%'
    --AND WIP.FW_DEVICE like '%R25C'
    and wip.ACTIVE_FACT_KEY = lf.RECORD_KEY
    and lf.ORDER_FACT_KEY = orf.RECORD_KEY
    and orf.ORDER_KEY = ord.RECORD_KEY
    and ord.ORDER_NO = to_char(oeh.order_number)
    and oeh.header_id = oel.header_id
    and orf.LINE_ITEM_NUMBER = to_char(oel.line_number)
    and orf.ITEM_SCHEDULE = to_char(oel.shipment_number)
    and wip.LOT_TYPE in ('ENX','PRA','PRD','PRT','CSK','MPW')
    union all
    select --od.order_no,'
    'SILTERRA' FAB_ID,
    od.CUST_PO PO,
    imd.FW_DEVICE_ID PRD_NO,
    nvl(orf.USER_ITEM_DESCRIPTION, nvl(imd.CUST_DEVICE_ID, imd.FW_DEVICE_ID)) SHP_PRD_NO,
    sfl.LOTID LOT,
    sfl.currentcompqty WIP_QTY,
    'CREATED' ROUTEDESC,
    to_char(to_date(substr(recordstartdate,1, 14), 'yyyymmddhh24miss'), 'DD-MON-YYYY HH24:MI:SS') IN_TIME,
    --sysdate - to_date(substr(recordstartdate,1, 14), 'yyyymmddhh24miss') STAY_DAY,
    --to_date(sfl.scheduledcompletedate,'yyyymmdd') - sysdate BACK_DAY,
    to_char(sysdate - to_date(substr(recordstartdate,1, 14), 'yyyymmddhh24miss'),'9999D99') STAY_DAY,
    to_char(to_date(sfl.scheduledcompletedate,'yyyymmdd') - sysdate,'9999D99')BACK_DAY,
    to_char(to_date(sfl.scheduledcompletedate,'yyyymmdd'),'DD-MON-YYYY') WO_FCST_DATE,
    to_char(to_date(sfl.scheduledcompletedate,'yyyymmdd') + 1, 'DD-MON-YYYY') SHIP_FCST_DATE,
    --nvl(oel.attribute15, to_char(sysdate+3650,'DD-MON-YYYY')) SHIP_CONF_DATE,
    to_char(nvl(to_date(oel.attribute15,'DD-MON-YYYY'), sysdate+3650),'DD-MON-YYYY') SHIP_CONF_DATE,
    to_char(to_date(sfl.startdate,'yyyymmdd'), 'DD-MON-YYYY') WS_DATE,
    ' ' ROUTERATIO,
    sfl.tempprocessplan PROCESS,
    sfl.currentstatus LOTSTATUS,
    sfl.currenttype LOTTYPE,
    0 RETICLEVERSION,
    0 PROCESSVERSION,
    0 ROUTESEQUENCE,
    ' ' PRIORITY,
    ' ' PROCESSGEN,
    ' ' PROCESSFAMILY
    from SIL_FW_LOTCREATED_VIEW sfl, order_dim od, order_fact orf, item_master_dim imd,
    apps.oe_order_headers_all@prod_myfabetl oeh,
    apps.oe_order_lines_all@prod_myfabetl oel
    where substr(sfl.salesorderno,1,instr(sfl.salesorderno,'-',1,1)-1)= to_char(od.ORDER_NO)
    and od.RECORD_KEY = orf.ORDER_KEY
    and od.RECORD_CURRENT_FLAG = 1
    and orf.RECORD_CURRENT_FLAG =1
    and to_char(orf.LINE_ITEM_NUMBER) = substr(sfl.salesorderno,instr(sfl.salesorderno, '-',1,1) +1, (instr(sfl.salesorderno, '.',1,1) -1) - instr(sfl.salesorderno, '-',1,1))
    and to_char(orf.ITEM_SCHEDULE) = substr(sfl.salesorderno,instr(sfl.salesorderno, '.',1,1) +1, length(salesorderno) - instr(sfl.salesorderno, '.',1,1))
    and orf.ITEM_MASTER_KEY = imd.RECORD_KEY
    and sfl.customername = 'Realtek'
    and od.ORDER_NO = to_char(oeh.order_number)
    and oeh.header_id = oel.header_id
    and orf.LINE_ITEM_NUMBER = to_char(oel.line_number)
    and orf.ITEM_SCHEDULE = to_char(oel.shipment_number);
    select count(*) from rtnewwip;
    COUNT(*)
    136
    1 row selected

    query might be referring to different environment/schema as you are using database link to access some tables.
    getting result/count from view means executing query which forms that view. try to run that query separately and see the output.
    it may help you to debug

Maybe you are looking for

  • Oracle 9i Database Registration Key Needed

    Greetings, please email the registration key for the Oracle 9i database software installation so that I may proceed. I received a page not found error when attempting to register.

  • LSO - Course follow up

    Hi, In LSO_PV15 there are two fields namely 1) Participation confirmed (field = CONFIRMED) and 2) Course Passed (field= PASSED). I suppose the field 'Participation confirmed' refers to learners attended the course and the 'course passed' refers to th

  • HT201210 error 'frmware file not compatitble' how do i fix this?

    i am trying to update iphone and error 'frmware file not compatible', pleae help                   

  • Getting Error when executing Web Service Model method in WD Application

    hi ,    I have written WD Application which has Web Service Model(Deprecated). I did the context mapping between WS Model-->Comp Controller --> iView Controller. When i try to execute a method in Web Service method in Component Controller after bindi

  • Purpose of client creation

    Hi Can anyone tell me what is the purpose of creating the additional client in SAP/3. Kindly tell me the reasons. Thanks. ARun