Only ints return from SQLite queries with calculations

Howdy.  Hope I have the right forum for this question.
I'm on a project using a SQLite database in Flex 4 and I'm using the following SQL query:
SELECT max(totalScore) AS score,
               max(longestStreak) AS streakLen,
               max((correctNotes * 100) / totalNotes) AS accuracyPercent
FROM main.practiceRecord rec
JOIN main.lessonSession sess
ON rec.sessionGuid = sess.guid
WHERE sess.purchasedLessonID = :lessonId
The query is working fine as it is written.  The problem is that when I do the calculation ((correctNotes * 100) / totalNotes) to return a percent value, I'd like to do it without having to multiply by 100, since I generally treat percentages as numbers between 0 and 1 (.68 = 68%).  If I don't multiple by 100 in the query, however, I get a "0" for anything less than 1, so only 100% returns with the correct value.  It appears that this kind of calculation only returns an int, as opposed to a REAL (or its AS3 corresponding "Number").
Is there something that I can do to return a value between 0 and 1 for this percentage so that I don't have to multiply by 100 in the query and then divide by 100 when I get the result?  Is there a function that allows me to specify the precision for the returned value?
Thanks for your time,
Bryan

Maybe Tom Kyte's "trick" of the "select pl_sql_function () from dual" to invoke scalar subquery caching can help you:
select ename
  from emp, dept
where (select dname_lookup(emp.deptno) from dual) = 'SALES'
   and dept.deptno = 30
   and emp.deptno = dept.deptno;http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1547006324238
As Tom says, in 11g you'll be able to cache that function (new 11g feature) which removes the need for the "trick":
Oracle® Database PL/SQL Language Reference 11g Release 1 (11.1)
- 8 Using PL/SQL Subprograms
-- Using the Cross-Session PL/SQL Function Result Cache
http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/subprograms.htm#BABFHACJ
"On the PL/SQL Function Result Cache" by Steven Feuerstein
http://www.oracle.com/technology/oramag/oracle/07-sep/o57plsql.html
Regards,
Zlatko

Similar Messages

  • I just returned from air travel with my macbook pro. It does not start up. Completely black, no sound, no life.

    I just returned from air travel with my macbook pro. It does not start up. Completely black, no sound, no life. I tried command-option-power. Still dead.

    SheilaArl wrote:
    I just returned from air travel with my macbook pro. It does not start up. Completely black, no sound, no life. I tried command-option-power. Still dead.
    I have a 2007 Macbook, so it's probably a lot older than your Macbook Pro, but it sounds like what happened to me, except that mine hadn't travelled anywhere. I pulled out the ram and blew out some dust, popped them back in, and wha-la! it turned back on and worked better than ever! Or otherwise you've got a dud/old/warped/fried battery, which is also what happened to my laptop - it got so  bad it did what your laptop is doing. Ordered a new battery online and all good since then. Or otherwise, like the previous post asked, 'is it plugged in?'

  • Adobe is grabbing 'rowid' not specified PK 'int' column in SQLite queries !!

    When I execute the following query in Flex and/or Lita:
    select wrdid, uspelling from WRD WHERE uspelling = 'wingeard'
    the results are:
    uspelling...wrdid
    wingeard   3137
    Look at what comes back when I execute this query using .NET provider by  Robert Simpson for SQLite and SQLite Manager by Mrinal Kant:
    SELECT     rowid, wrdid, uspelling
    FROM         WRD
    WHERE     (uspelling = 'wingeard')
    rowid.......wrdid...........uspelling
    3137........3042............wingeard
    No wonder none of my queries with joins is working correctly in Flex.
    wrdid is defined as "int" not INTEGER.
    http://www.sqlite.org/lang_createtable.html  (see INTEGER PRIMARY KEY section):
    "The special behavior of INTEGER PRIMARY KEY is only available if the type name is exactly "INTEGER" (in any mixture of upper and lower case.)  Other integer type names like "INT" or "BIGINT" or "SHORT INTEGER" or "UNSIGNED INTEGER" causes the primary key column to behave as an ordinary table column with integer affinity and a unique index, not as an alias for the rowid."  [emphasis added]
    Now, I happen to think the SQLite developers made a mistake here in failing to follow standards, preferring not to break legacy code. They'd rather break current code instead???  I would not characterize this as a "corner case" and the bug-at-hand is de facto evidence of that.

    Based on your idea, i've intercepted the click event and I use stopImmediatePropagation.
    THen i added an image to sort the column. So if the image is clicked the sort is ok.

  • Laptop returned from service depot with a missing cap

    I just had a ThinkPad T410s returned from a service depot here in Canada.  It was sent in to replace a small part on the underside of the laptop, which was repaired.  However, it came back with one of the screws on the display missing it's cover.  Based on some other posts I had read on here, I took pictures of the laptop when I packed it to go to the depot, so I know 100% that this part wasn't missing when I sent it in for service.
    Link to picture
    I've called support and I asked them to just send me the cover so that I could snap it on.  However, they said they could not find a part # for it, so I'd have to send the laptop back to the depot for service again.  Can anyone on identify the kit that would contain this part so that I can avoid this?  In the service manual I see three different kits that include "Screw cap, thin" but I'm not sure if that's the part I need or not:
    75Y4472  Screw kit for T410s and T410si
    45M2673  Seal kit
    45M2674  LCD miscellaneous parts
    I'm quite irritated that I have to deal with this at all.
    1) I don't know why they would have touched the LCD screen in the first place to replace a part on the bottom of the laptop.
    2) It demonstrates a lack of detail on the service depot's part: a workbench should be checked to make sure no parts are leftover that weren't there when the laptop was unpacked.  And even if the part was missing when it arrived, good customer service would be to replace it.
    Moderator note; picture(s) totalling >50K converted to link(s) Forum Rules
    Current: ThinkPad Tablet 2 | 64GB // ThinkPad T440s | i7-4600U | 12GB | 512GB SSD | FHD MT
    Previous: ThinkPad T420s // ThinkPad T410s
    Solved!
    Go to Solution.

    Lookup a local service authorized dealer in your area (lists from this site). Take it in and/or call and see what they can do. I would not let it out of my hands again or at least not to the same location.
    T520 Model 4239 Intel(R) Core(TM) i7-2860QM CPU @ 2.50GHz
    Intel Sandy Bridge & Nvidia NVS 4200M graphics Intel N 6300 Wi-Fi adapter
    Windows 7 Home Prem - 64bit w/8GB DDR3

  • Problem saving queries with calculated key figures

    Hello Experts,
    I am analyzing this problem since many hours during the last weeks and I don't know, what else to do.
    The problem is saving a key user query containing a calculated key figure in the production system (BW 3.5 SP SAPKW35015). The Error 'The query could not be saved due to a problem in transport' occures.
    If I exclude the KF from the query, saving is possible, so the calculated KF must be the source of the problem.
    The system is set to not changeable, but the 'Object Changeability' of 'Query Elements' in 'RSA1' --> 'Transport Connection' is set to 'Changeable Original'. If I set this option to 'Everything changeable', saving of the query works, but this is not possible in production, because transported standard queries would also be changeable.
    For saving queries, die authorization object S_RS_COMP and S_RS_COMP1 is included completely with *, but this does not help.
    I also transported the query and the KF again from development system ... no change, same problem.
    I found the SAP note 533413, but what does this mean? "This problem can only be solved in the next BW release ..." I heard from colleagues, that BW 7.0 has the same problems.
    Does anyone have an idea, how to solve this problem?
    I would be very thankful for any reply...
    Hannes
    Edited by: Hannes Heidrich on Jun 23, 2008 12:07 PM

    Thank you for your answer, but I have set the Object Changeability to Everything Changeable and restricted the user with S_RS_COMP. So only certain query names can be used and changed. Experiences from collegues said, that deleting and transporting again would not help.
    Best Regards,
    Hannes

  • Notebook returned from "HP Support" with dvr missing and will not power on

    I had originally called in to support to ask them to help me stop the automatic update from Windoze 8 to Windoze 8.1 and to also shut off the reminder notices about that.  Tech support supposedly walked me through that, but after that, the next time I booted up the notebook, it automatically updated to 8.1 anyway, and there was no way to stop it.
    Shortly thereafter, the notebook could only boot to BIOS, or error code 3F0, but Windoze 8.1 had predictably self destructed and could no longer be found.
    Which is also btw how I discovered that they had apparently also not installed the UEFI that they said was "installed on every laptop" blah blah blah...
    By this time, I was out of warranty, but I was offered a service "deal" that seemed to make sense for the cost v.time to do it myself factor, so I took them up on it.   But I was told that if the hard drive needed to be replaced, they would not return my old hd to me, so I first had a local tech attempt data recovery on that.  He didn't have time, and couldn't get it done, and asked me to try to get the hd back anyway.  He also checked out some basic connections inside and stuff, to see if there was something obvious and easy he could fix. 
    But he also told me that a) there was a brown concrete hardened paste like substance on the back of the keyboard that would not clean off, he thought it was either some sort of plastic glue or thermal paste that had baked.  and b)  99.9% of all manufacturer "technicians" will declare "liquid damage" (or some other fault of the user) and he thought I was wasting my time to send it in and they would not perform the repair.   We even bet lunch on that.  BUT... I was to pay for this repair, so I decided to send it in anyway.  And... he took pictures of certain things to help me if they did as he said they would.   
    Then, just as my local technician predicted,  the notebook came back today from HP's generous service offer, not only NOT fixed, but also no longer powers up at all and no longer even has a DVR, and covered in what looks like white plaster dust.  Oh and without the recovery media.  I haven't opened it up to see what else is missing, but I am furious that they sent it back in worse condition.   I don't know how HP will remedy this, but I can promise you that my personal remedy will not be to purchase a new HP notebook PC.  Ever. 

    lol.  I did get a PM from support person asking for my serial number and stuff, and after I responded, I got this reponse:
    Thank you for visiting the HP Support Forums. I'm sorry to inform you that your image was rejected because it does not relate to any HP Support Forum Question or it may have contained personal information (serial # visible in image). From our Rules of Participation:
    Protect privacy - yours and others'. Don't share anything about yourself that you would not want to see on a road-side billboard. Don't post contact or other personal information-your own or anyone else's-or any content that you receive in one-to-one communications without the author's consent. For example, don’t post your computer’s serial # or contact information publicly, and do not allow someone you don’t know to remotely take control of your computer.
    Sharing serial numbers or product keys, personal email addresses, telephone numbers, and last names is not allowed for your safety.
    Please remove or otherwise hide any serial numbers and then repost your image.
    Thank you
    So.   It seems to me that HP employed people should KNOW THIS when they ask for this information this way!  For the 4th(?) time... I would like to know how HP plans to actually RESOLVE the issue, since we can't seem to get beyond basic introductions?

  • Handling event listeners - returns from async queries...

    i'm a longtime programmer, but relatively new to async calls.
    so i think i'm missing something basic...
    when my current flex screen loads, it performs three queries
    to pre-populate the screen. first query is the "header" record,
    second query gets the "line item" records, and the third query gets
    values for a picklist which will be in the data grid. (note that
    i'm querying a web service - although i doubt that matters much...)
    when each query is finished and the local objects
    (ArrayCollections, etc) are populated, i want to perform a specific
    action. So my first thought is to write three
    "handle*QueryComplete" methods, and add an event listener to the
    connection before each query. So these three lines will appear in
    my code:
    apex.addEventListener(QueryEvent.QUERY_EVENT,
    handleHeaderQueryCompleted);
    apex.addEventListener(QueryEvent.QUERY_EVENT,
    handleLineItemQueryCompleted);
    apex.addEventListener(QueryEvent.QUERY_EVENT,
    handleProdQueryCompleted);
    But then when one qeury finishes, it will call all three
    handle* methods, right? How am I supposed to do this so that when
    each query completes, it performs the proper action?
    thanks for your time
    chris

    In order to identify a result with its call, to perform some
    specific processing, you can use the AsyncToken. Below is some
    sample code.
    Tracy
    Sample code using HTTPService, e4x, handler function to
    populate a list item.
    Also shows usage of AsyncToken.
    The DataGrid tag:
    <mx:DataGrid id="dg" dataProvider="{_xlcMyListData}"
    .../>
    The HTTPService tag:
    <mx:HTTPService id="service" resultFormat="e4x"
    result="onResult(event)" fault="..../>
    Script block declaration:
    import mx.rpc.Events.ResultEvent;
    [Bindable]private var _xlcMyListData:XMLListCollection;
    Invoke send:
    var oRequest:Object = new Object();
    oRequest.Arg1 = "value1";
    var callToken:AsyncToken = service.send(oRequest);
    token.callId = "myQuery1";
    Result Handler function:
    private function onResult(oEvent:ResultEvent):void {
    var xmlResult:XML = XML(event.result); //converts result
    Object to XML. can also use "as" operator
    var xlMyListData:XMLList = xmlResult.myListData; //depends
    on xml format, is row data
    _xlcMyListData = new XMLListCollection(xlMyListData); //wrap
    the XMLList in a collection
    trace(_xlcMyListData.toXMLString()); //so you can see
    exactly how to specify dataField or build labelFunction
    var callToken:AsyncToken = oEvent.token;
    var sCallId = callToken.callId; //"myQuery1"
    switch(sCallId) { //Process the result conditionally
    case "myQuery1":
    doQuery2(); //do whatever. this example calls another data
    service query
    break;
    }//onResult

  • Why can I only delete music from my phone (with itunes match) when "show all music" is selected

    This is pretty messed up... I can't delete any music from my phone unless I have the "show all music" command turned on.  This is the complete opposite from how it should be.  Please get it together, Apple!

    Thanks for your reply.  I mean that only when all of my music in the cloud is shown on my phone can I delete the music stored on my phone.  I should be able to delete music that is stored on my phone when I can view ONLY the music that is taking up the phone's memory.

  • Getting "Network Connection Failure 903" *only* when connecting from a LAN with a similar setup

    Hello there, We recently bought a WD My Cloud EX2100 for family storage and we're quite happy with it. We configured the Android mobile app and it works perfectly either in the local network, from the WiFi at work or from the 4G networks in our smartphones. However, we live in two houses with very similar network configurations (same IP range, same IPs assigned to similar devices, e.g. 192.168.1.1 is the router in both places and 192.168.1.254 are other network gadgets, specifically at one house the WD NAS device, and at the other a WiFi repeater). The problem is that at the house with the WiFi repeater in the same IP address as the NAS in the other house, we cannot use the Android or Windows apps to connect to My Cloud services. Everywhere else, it works just fine, but not there. I believe it's wrongly detecting the network as the home network for the NAS device and tries to connect through 192.168.1.254 (haven't had the time to test this though). Have you had any similar issues? What can I do to fix this? Is there any documentation on it? Thanks! Best regards,José Devezas

    I have checked it and the issue really is the local network with a similar configuration. I disconnected the WiFi repeater using the same IP address as the NAS on the other network and it worked just fine. It's quite a stupid bug, that needs fixing.

  • How to install windows 7 when an error occurs: "Not Found returned from legacy loader" with refit?

    SOLUTION FOR THIS QUESTION :
    before you need to create a Windows partition ( boot camp assistant for example) and install rEFIt
    1-  download SLAX LIVE CD -->http://www.slax.org/
    2- burn cd with slax
    3- run slax live cd without reFIT ... press Option key ( ALT )
    4- when slax operative system is open, turn off the computer!
    5- donload UBuntu Live cd --> http://www.ubuntu.com/download/ubuntu/download
    6- burn cd with ubuntu.
    7- run ubuntu live cd and  open without installing
    8 - open administration --> partition and format the actual partition ( fat32 ) created on MAC OS X to NTFS.
    9 - Restart computer and run REFIT (  press Option key ( ALT ) ). run live cd or USB pen with windows 7, xp or VIsta.
    Note:
    I use a external DVD drive -Samsung SE-S084D
    Ubuntu version 9.04.

    .

  • Powerbook returns from warranty service with dent

    Well... lost my hard drive after gradual slow down... did the whole applecare routine. Reinstalled the system 3 times, etc. startup got slower and slower.
    Then the HD failed totally. Applecare sends me to the genius bar... they tell me there is no way to recover anything (yeah... shoulda backed it up...). I lost everything. Big lesson learned here.
    So, they send it out. week and half later, I get a call its back. Drive up to the apple store in WoodCliff Lake, NJ... the guy hands it to me. apparently, I got it back with an extra bonus... small scratch and nice dent in the edge of the cover. Apparently... it took an impact somewhere between when I left it and saw it 9 days later at the genius bar.
    Genius guy says they will send it out for a new case... this just scares me that now I have a 'fooled-with' machine that took a decent impact... no longer a factory-fresh unit.
    Disappointed to say the least. now I'm out for yet another week.

    I am a lucky customer of two of these storms....once which arent 3 weeks old and the first one the one that was my phone locked up in the first week and i was mashing the screen not hard and the **bleep** thing broke...well verizon says you have 30 days till you can no longer buy the phone insurance and who would of thought in my first week the **bleep** touch screen would break by me tapping on it trying to get the locked up software to respond....and guess what verizon said there is nothing they can do  to a phone with a cracked screen....and also both phones blackberrry storms that were sent to me were used equipement.  but  I am still repsponsible for the two contract agreement and I cant even use the **bleep** phone...also they say you can add insurance within 30 days of new purcchase not the phone that was malfuntioned and the screen cracked....but they let me add it to the second line....i think its very dirty of verizon to send used phones with two contracts to someone and it malfuntion like that and not replace the phone...and still hold the customer responsible for two year contract...after all the **bleep** trouble the storms have been giving customers...thats why they are sending the **bleep** things out free of charge...dont get scammed and screwed like I did go with Tmobile or att..

  • Download only selected record from ALV

    Hi
      I want to download only selected records from ALV output with button.
    i hav to fix the button on ALV screen using &ZDL whenever user presses the button record should be downloaded.
    Pl with coding
    its very very urgent.

    Hi ,
    i dont have the exact code which suits to your requirement
    but declare the internal table
    like
    data: begin of itab occurs 0,
      check type c,
    fields
    end of itab.
    while filling the field catalog
    fieldcatalog-checkbox = 'X'
    for this check field.
    and display the grid
    now write this subroutine
    *&      Form  USER_COMMAND
          Called from within the ALV processes. Currently, '&IC1' is used
          to process the hotspot and display the document 'picked' by the
          user.
          PV_UCOMM    contains the sy-ucomm from ALV
          SELFIELD is a structure that contains all the data required to
                   process a user selection. The following is an example
                   of the SELFIELD structure and sample values:
    FORM USER_COMMAND USING PV_UCOMM LIKE SY-UCOMM
                            SELFIELD TYPE SLIS_SELFIELD.
      CASE PV_UCOMM.
        WHEN '&IC1'.
          loop at itab where check = 'X'.
    append all these records to another internal table itab1
         endloop.
    call function gui_download.
    pass the internal table itab1 in the tables statement
    and also you have to give the file path that may be static or dynamic
    if dynamic you have to call the function module
    f4_filename
    and get the filename and pass the same value to gui_download
    that will be download to the above said path
    endcase.
    end form.
    reward points if helpful,
    thanks & regards,
    venkatesh

  • Mail redirect rule only redirects mail from certain domain!!!

    Hi all,
    I set up a rule in Mail to redirect EVERY message to a certain email address (for backup/storage purposes) However it only redirects emails from email addresses with the same domain as my email (eg will redirect mydomainname.com but not otherdomainname.com
    Why is this??? Any ideas on how to fix it??? It is getting the mail from an Exchange server if that helps any...

    Thanks for the welcome!
    Ok so here are some screenshots...
    Here is the screenshot of the rule details
    Here is the main rules window
    And here is a screenshot showing how some are redirected and some are not (the ones that are redirected (and the one that shows the forward icon (it was forwarded before I set up the redirect rule)) are all from the same domain as my email account.
    Any ideas? Thanks!

  • Returning int array from C to Java as method parameter

    Hello,
    I've been trying to accomplish this
    Java
    int[] myArray = ... (filled with some data);
    int retCode = myNativeCall(myArray);
    if(retCode == 0)
    doSomethingWith(myArray); //myArray gets overwritten with new data (with new size also) during the native call...
    C
    JNIEXPORT jint JNICALL Java_GenChav_rsaEncrypt(JNIEnv *env, jobject obj, jintArray myArray){
    jintArray outbuf;
    int[] new_array = .. // some function will fill this....
    int new_array_length = ...//some function will give me the new size, not big, 512 max...
    jint tmp[new_array_length]; //allocate..need something more ??
    memcpy(tmp, new_array, new_array_lenght);
    outbuf=(*env)->NewIntArray(env, new_array_length);
    (*env)->SetIntArrayRegion(env, outbuf, 0, new_array_length, tmp);
    myArray=outbuf;
    I tought this way I would have a updated myArray ints on the Java program...
    Any thought??

    user5945780 wrote:
    Ok, let's try to be constructive here...
    How I do implement a return type for my method like a int array ?First realized it has nothing to do with JNI. So the same question and answer applies to java only.
    >
    like:
    int[] return = myNativeCall();
    Yes.
    Then I will look for return[0], if it is == to 0, fine, it means a successful calculation by the native code. Not sure what that means. The structure of what you return it up to you.
    It can help when you are unsure of what to do in JNI....write a pseudo representation of what you want to do in a java method. Then translate that java method into JNI, everything in the pseudo method must be in the JNI code.

  • Datas return from Blob data type in Sqlite

    i am using sqlitejdbc-v053.jar through get SQLITE BLOB data type data. But i cannot data return from Blob type.
    Error will be display from :
    not implemented by SQLite JDBC driver
    and point out error line
    blob = rs.getBlob("NGP_REPDATA");
    {try {
                   Class.forName("org.sqlite.JDBC");
                    conn = DriverManager.getConnection("jdbc:sqlite:test.DB");
                    stmt = conn.createStatement();
                    rs = stmt.executeQuery("SELECT * FROM sometable");
                    System.out.println("==============");
                    while(rs.next()) {
                         blob = rs.getBlob("blobDATA");//
                         is = blob.getBinaryStream();
              catch(SQLException e) {
                   e.printStackTrace();
              }}any sample or solution pls give
    sqlite with BLOB sample there pls give link                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    There explicitly tells you that the JDBC driver that you are using will not do the method that you are calling.
    Thus you cannot use that method.
    There is another way to extract blobs which involves using a stream. You can search for that.
    If your blobs are actually short and only have character data then you might be able to use getString() as well.

Maybe you are looking for

  • Creation of Billing with reference to the Sales Order

    Dear Friends, I need your suggestion for the following scenario. Client wants to create the Billing Document with reference to the Sales order.I mean when he is entering sales Order while creating the billing document ,the system should generate the

  • How to use fdisk -e in terminal?

    My problem is bit complicated, I will try explain this simple as possible. It started because disk drive random eject, detail on this thread: http://discussions.apple.com/message.jspa?messageID=13106931#13106931 Now one of my partition didn't mount.

  • Myspace music wont play in safari?

    On myspace, at one time, safari would play music attached to someones site. now it does not. i CAN get it to work in firefox. any ideas? Mac Book Pro, CD2, 15" 2.13ghz 1GB Ram   Mac OS X (10.4.8)  

  • Clicking on user photo does not log in or display password window

    I have a 1-week old MacBook Air w Lion OS which was set up at the Apple Store so I could log on without a password. Doing so brought me immediately to my Desktop.  After installing MS Office via download, at the next boot up I got a grey screen with

  • Trying to install Flash Player 11 and it times out everytime

    Why is Flash Player install timing out at 7% every time I try to install it? I have even tried getting it from mirror sites and it still times out at 7% on the install panel.