int function

Hello everyone

IM using oracle 11gRev 2.

IM migrating an application of VBA to PLSQL.

I need to know if some body knows where can I find the translation of the vba INT plsql function.

Can anyone help?

Thank you in advance and best regards eveybody.

Hello

Sorry, I'm not VBA myself.

This site: http://www.techonthenet.com/excel/formulas/int.php said INT (x) returns an integer less than or equal to x, while x<>

The equivalent Oracle SQL function is GROUND.

As Pablolee said, people who use this forum necessarily don't know what than VBA.  It would be better if you posted some examples of data, such as

CREATE TABLE sample_data (x NUMBER);

INSERT INTO sample_data (x) VALUES (-1.5);
INSERT INTO sample_data (x) VALUES (-1.1);
INSERT INTO sample_data (x) VALUES (-1);
INSERT INTO sample_data (x) VALUES (-. 9);
INSERT INTO sample_data (x) VALUES (-. 5);
INSERT INTO sample_data (x) VALUES (-. 49);
INSERT INTO sample_data (x) VALUES (0);
INSERT INTO sample_data (x) VALUES (. 49);
INSERT INTO sample_data (x) VALUES (. 5);
INSERT INTO sample_data (x) VALUES (1);
INSERT INTO sample_data (x) VALUES (1.5);
INSERT INTO sample_data (x) VALUES (2.5);

and the results you get from INT in VBA (x) in each case and ask how to get the same results in Oracle.

You can also just try all the different solutions proposed so far in Oracle

SELECT x
FLOOR (x) AS floor_x
TRUNC (x) AS trunc_x
CAST (x AS INT) AS cast_x
OF sample_data
ORDER BY x
;

and compare the output:

X FLOOR_X TRUNC_X CAST_X

---------- ---------- ---------- ----------

-1.5         -2         -1         -2

-1.1         -2         -1         -1

-1         -1         -1         -1

-.9         -1          0         -1

-.5         -1          0         -1

-.49         -1          0          0

0          0          0          0

.49          0          0          0

.5          0          0          1

1          1          1          1

1.5          1          1          2

2.5          2          2          3

to see which one fits with VBA

Tags: Database

Similar Questions

  • MDX - Int function


    How to use the INT() function with mdx?

    I am trying to execute the Int(104.504) function of EAS (essbase administration console services - file\editors\mdx script editor), exactly the same thing that is in the Ref guide Oracle technology, but I get a syntax error. What I am doing wrong?

    You're welcome - it's interesting.  It works for me in Sample.Basic:

    WITH MEMBER Measures.TestFunction AS 'Int(Sum(Children([Profit])))'
    SELECT {Measures.TestFunction} ON COLUMNS
    FROM Sample.Basic
    

    I don't like the multiple levels in your specifications WITH Essbase.  Measure.Profit.TestFunction does not for me either, for example.

    The WITH clause sets up a 'virtual' member - it makes sense to think of it as belonging to a dimension, but it is not really supposed to think of it as having a special position in this dimension.  Even if it was a valid syntax, there is no difference between Measures.TestFunction and Measures.Profit.TestFunction.  The functions of metadata as a Parent do not work with calculated members - at least, not according to the MDX with Section technical reference entry.

  • Variable function names

    What I'm trying to do is to add event listeners for each position up to the sum of compPositions. In this way, each will have a dynamic function name. Right now, they are all launching function "clicked1" but I can't figure out how to dynamically add numbers function name. Is there a different method I should use to achieve this?

    Right now, compPosition = 5, so we need to create 5 event listeners, but I want that they each have their own function they exucute.

    var i;

    for (i = 1; i < compPositions + 1; i ++)

    {

    currentPos = "pos" + i;

    This ["pos" + i] .addEventListener (MouseEvent.CLICK, clicked1)

    }

    Edit:

    Actually, after thinking about this topic, I think it's a better approach, but I do not know how to pass a variable using a click event.

    var i;

    for (i = 1; i < compPositions + 1; i ++)

    {

    var currentPos; now, it is private to this loop for

    currentPos = "pos" + i;

    This ["pos" + i] .addEventListener (MouseEvent.CLICK, posClicked)

    }

    In this version, I just need to move the currentPos variable to the function, but I don't know if it's possible.

    Thank you

    Corey

    Before the resolution of problems, I would like to warn why you need to have a single unique function name. You should be able to have all hit them the same function and do a different logic depending on the target.

    That said, you could do something like this:

    for (i = 1; i< comppositions="" +1;="">

    {

    currentPos = "pos" + i;

    This ["pos" + i] .addEventListener (MouseEvent.CLICK, this ["clicked" + i])

    }

    However, you will have to manually set each function. You can also use closures:

    for (i = 1; i< comppositions="" +1;="">

    {

    currentPos = "pos" + i;

    This ["pos" + i] .addEventListener (MouseEvent.CLICK, getFunction (i))

    }

    function getFunction(i:int):Function

    {

    return function(e:MouseEvent):void {trace ("Clicked" + i) ;};

    }

    EDIT:

    Using the close method, you can also pass the current pos if you need to:

    for (i = 1; i< comppositions="" +1;="">

    {

    currentPos = "pos" + i;

    This ["pos" + i] .addEventListener (MouseEvent.CLICK, getFunction (i, currentPos))

    }

    function getFunction(i:int,_currentPos:String):Function

    {

    return function(e:MouseEvent):void {trace ("Clicked" + i + "currentPos =" + currentPos) ;};

    }

  • External DLL with struct array

    I am train (new to this) call an external dll.  The function prototype looks like this:

    int FUNCTION (int * count, struct List_t * list);

    Count is of type Long

    List_t is a structure that looks like:

    typedef struct List_t
    {
    char name [MAXCHARS];
    char file [MAXCHARS];
    double length;
    bool wired;
    bool DDD;
    };

    and the list is an array of length (MAX-1), where MAX is defined as 10 and MAXCHARS is 48.

    This is my last try:

    and I have the List parameter as "adapt to the type" and "pointer of table data.

    I get correct data, but not all.

    Thank you

    And increasingly what said tbob, you better make sure the entrance of County is never greater than 1, as the function could otherwise try to fill only element that you pass and what can AND will damage your memory eventually causing some breaks down, but has no need to plant immediately beyond the end of the table.

    What you should probably do is to replace the node Build array by Array Node initialization and son County control also at the entrance to the size of it. Set the number at 10 and use the number of output to resize the table using table to reshape the size that was filled in.

  • DLL and array of pointers to incomplete struct

    I think that this has probably been dealth with before, but I tried searching and have not found an answer that solved my problem.

    I have a function implemented in a DLL that returns a pointer to an incomplete structure.  Everything works very well.

    Now, I want to write a function that passes an array of the DLL (pre-allocated in LV) and fills that table with a set of pointers to the incomplete struct (same data as type works well on it).

    I can't get this to work.

    I tried:

    int function (struct incompletestruct * table) as a function prototype, but I get complaints of "unknown of the incomplete struct size" if I then try to reference table [value].

    I tried

    int function (struct incompletestruct * array []) as a prototype of function, but the LV crashes hard when what I call with setting "a pointer to the data in the table.

    I tried

    int function (struct incompletestruct * array [16]) as a prototype function, but even lock as indicated above.

    What combination of prototype of function and the convention in DLL call BT need me for this?

    I use LV 2009 SP1 and CVI 9.0.

    Shane

    I am not able to solve the complete problem, but can at least give a few tips:

    * Array of pointers is an array of I32 (I guess that's not true 64-bit more).

    * Hidden in the LabVIEW.exe there is some undocumented functions that allow to perform pointer operations. Somewhere, there should be a LabVIEW.h file. And just type in labview under the name of the dll in the call library node.

    * So the full concept would be to deal with pointers as I32 pass inside the LV and get pointer to data via these functions build-in

    Felix

  • LabWindows CVI 2010 and GetProcessAddress()

    I use v10.0.1 Labwindows CVI 2010 after the upgrade to version 2010 CVI v10.0.0. After the upgrade, I have a compilation error of a statement that compiles fine in the previous version. The error is:

    «= Operands are types illegal "pointer to __stdcall int function (int, pointer to char, char pointer, pointer to char, int, pointer to char, pointer to char)' and"FARPROC".»

    What causes this error is the following statement in the code:

    my_FP = GetProcAddress (dll_handle, "DLL_FUNCT");

    and the definition of my_FP is:

    int __stdcall (* my_FP) (int x, y of char [], char [z], char * m, int g, char A [], char [] B);

    (the parameters and the function names have been changed for simplicity)

    As I said, this line compiles fine in the 10.0.0, version but not in 10.0.1. Y at - it a specific update to the compiler that will cause this error? What can be done to fix this?

    I thank very you much for your time and your help.

    You are right. This was caused by a change in the SDK Windows CVI headers that took place in the 2010 SP1 version. The change has been associated with bug fix #275934. Unfortunately, this bug fix introduced this unwanted side effect to require a cast for any function that returns a function (such as GetProcAddress) FARPROC poinrter. On reflection, this side effect is unacceptable and needs to be fixed in the next version. This is followed internally with bug ID #336341.

    I'm really sorry for this inconvenience. Until the problem is solved using the typedef & cast you have already implemented is a valid alternative.

    Another solution, if you're worried about other projects or other functions, where this error can also appear, is to edit CVI2010\sdk\include\windef.h and replace the following definitions of FARPROC (line 226 and 230, respectively):

    typedef INT_PTR (away from WINAPI * FARPROC) (void);

    typedef int (away from WINAPI * FARPROC) (void);

    with:

    typedef INT_PTR (away from WINAPI * FARPROC) ();

    typedef int (away from WINAPI * FARPROC) ();

    This will avoid the problem throughout a facility given to the CVI.

    Luis

    NEITHER

  • Preloader does not properly

    I know, Preloader another post. We asked me to problem solve why a preloader appears sometimes, but mostly doesn't, leaving the viewer puzzled as to what they are looking at a blank page for a long time, waiting for something happens. It is, I'm not very well informed in flash.

    Here is the code I have asked me to work with. The client wanted the entire site to preload; animation opening and videos on the site. My boss actually ended by complete this code, but is also not a flash guru, so it is out of ideas.

    I don't really know what it is, and most of the tutorials that I looked up treats them with a different code.

    stop(); var nc:NetConnection = new NetConnection(); nc.connect (null); var ns:NetStream = new NetStream (nc); var videoPlayer:Video = new Video(); videoPlayer.attachNetStream (ns) ns.play ("http://www.missionpublicaffairs.com/MPA-031813.flv" ""); NS.pause (); var SWFtotal:int; var VIDEOtotal: int; var AVGtotal: int; function checkLoad (): void {trace ("video bytes loaded:" + ns.bytesLoaded);} trace ("SWF loaded bytes:" + this.stage.loaderInfo.bytesLoaded); SWFtotal = int(((this.stage.loaderInfo.bytesLoaded/this.stage.loaderInfo.bytesTotal)*100)); VIDEOtotal = int(((ns.bytesLoaded/ns.bytesTotal)*100)); AVGtotal = int (((SWFtotal + VIDEOtotal)/2)) //MattText.text = "video Loaded:"+ VIDEOtotal + '%'; '. SWFText.text = ' SWF bytes loaded: "+ SWFtotal + '%'; '. TotalText.text = "Total loaded:"+ AVGtotal + '%'; '.           If ((ns.bytesLoaded == ns.bytesTotal) & & (this.stage.loaderInfo.bytesLoaded == this.stage.loaderInfo.bytesTotal)) {clearInterval (myInterval);           this.gotoAndPlay (2); }} var myInterval:uint = setInterval (checkLoad, 200);

    The link of the site is here, if necessary. Again, sometimes it shows, sometimes not. Please let me know if you need to reply to give me pointers. Thanks in advance.

    M!

    Add this to your code:

    NS.client = This;

    function onXMPData(e:*):void {}

    }

  • Package builder

    Hello

    In a package after declaring a list of procedures and functions, we give the Sub statement as

    BEGIN
    ProcFromItsOwnPackage;
    TestPack END;

    We call it as a constructor. Here, it will be executed when we call any procedure or function of packaging
    for the first time.

    Do we not have any method of destroyer available here.

    Do we not have any method of destroyer available here.

    If you mean to initialize the State once again you can do it with dbms_session.reset_package (calling)

    SQL> create or replace package pkg
    as
     g int;
     function add return int;
    end pkg;
    /
    Package created.
    SQL> create or replace package body pkg
    as
     function add return int as begin g := g + 1; return g; end add;
    begin
     g := 0;
    end pkg;
    /
    Package body created.
    
    SQL> exec dbms_output.put_line(pkg.add)
    1
    PL/SQL procedure successfully completed.
    SQL> exec dbms_output.put_line(pkg.add)
    2
    PL/SQL procedure successfully completed.
    SQL> exec dbms_output.put_line(pkg.add)
    3
    PL/SQL procedure successfully completed.
    SQL> exec dbms_session.reset_package()
    PL/SQL procedure successfully completed.
    SQL> exec dbms_output.enable() ---- must also be enabled again because of the call before
    PL/SQL procedure successfully completed.
    SQL> exec dbms_output.put_line(pkg.add)
    1
    PL/SQL procedure successfully completed.
    
  • Internal CLOB.getAsciiStream in GR 11, 2 problem with temp CLOB JVM

    Hello

    I have a problem with the help of a temporary CLOB in PL/SQL that will be written with the Java Code that runs inside the Oracle (internal JVM) database. The code works without problem in Oracle 11 g R1 (11.1.0.7.0) but not with Oracle 11 g R2 (12.2.0.1.0). The example follows:

    < b > Table Description: < /b >

    NAME Null? Type
    ------------------------------- --------- -----
    ID NOT NULL NUMBER(*,0)
    TYPE_DE_FICHIER NOT NULL NUMBER(*,0)
    INSERT_DATE NOT NULL DATE
    NUMBER(*,0) NULL UNPROCESSED
    LFIELD001 CLOB (4000)
    BFIELD001 BLOB (4000)
    FILE_NAME VARCHAR2 (4000)


    < b > PL/SQL example Run: < /b >

    DECLARE
    CLB CLOB.
    p_result NUMBER; p_err VARCHAR2 (4000);
    t the BLOB;
    BEGIN
    SELECT bfield001
    T
    OF file_data
    ID WHERE = 200;

    CTR: = java_utils.clob_zipdecompress (t, 'BANKFILE_', p_result);

    -The output results
    dbms_output.put_line (SubStr ('p_result =' |)) To_char (p_result), 1, 255));
    dbms_output.put_line (SubStr ('p_err =' | p_err, 1, 255));
    dbms_output.put_line (SubStr ('p_return_clob =' |)) SUBSTR (CTR, 1 255), 1, 255));
    END;


    < b > example < /b > package
    PACKAGE JAVA_UTILS
    IS
    -Unzip a BLOB in format ZIP to a CLOB and return it with the file name specified figure
    FUNCTION clob_zipdecompress (p_blob IN BLOB, p_fname IN VARCHAR2, p_result OUT NUMBER)
    CLOB RETURN;


    END JAVA_UTILS;

    JAVA_UTILS PACKAGE BODY
    IS

    -Unzip a BLOB in format ZIP to a CLOB and return it with the file name specified figure
    FUNCTION clob_zipdecompress (p_blob IN BLOB, p_clob IN CLOB, p_fname IN VARCHAR2)
    RETURN NUMBER
    AS the JAVA LANGUAGE NAME "java_utils.Compress.ZipDecompress (oracle.sql.BLOB, oracle.sql.CLOB, java.lang.String) return int";

    FUNCTION clob_zipdecompress (p_blob IN BLOB, p_fname IN VARCHAR2, p_result OUT NUMBER)
    RETURN THE CLOB
    IS
    l_clob CLOB. l_result NUMBER;
    BEGIN
    IF p_blob IS NULL THEN
    RETURNS A NULL VALUE.
    END IF;

    DBMS_LOB.CREATETEMPORARY (l_clob, TRUE);
    p_result: = clob_zipdecompress (p_blob, l_clob, p_fname);

    RETURN l_clob;
    END clob_zipdecompress;
    END JAVA_UTILS;



    < b > function < /b > simplified example Java

    package java_utils;
    import java.lang. *;
    Oracle.sql import. *;
    import java. IO;
    java.util.zip import. *;
    public class Compress
    {
    /**
    * Uncompresses the BLOB in CLOB
    *
    @param blob the BLOB source (compressed binary data)
    @param clob CLOB target (hold plain text), it should be an empty CLOB recovered for
    example with dbms_lob.createtemporary (l_clob, true);
    * @throws exception for most of I/O exceptions if ever
    */
    public static int ZipDecompress (String fname, String [] err, BLOB, CLOB clob blob object)
    {
    OutputStream out; ZipInputStream z; Ze ZipEntry. String zeName; Byte [] buffer; int cnt;
    Boolean found = false;

    try {}
    out = clob.setAsciiStream(0L); Here, it fails
    }
    catch (Exception ex) {err [0] = ex.getMessage (); return-1 ;}}

    return 0;
    }


    }



    Running the example works well when 11 GR 1 material but 11 GR 2 returns an error: < b > not valid or the arguments in the call. < /b >


    No idea why this is happening?
    Any help will be appreciated.

    Ms.

    Hi MS:
    Replace:
    clob.setAsciiStream(0L); Here, it fails
    by:
    clob.setAsciiStream(1L);
    the CLOB Api went from quick implementation of Oracle to the implementation of the standard.
    HTH, Marcelo.

  • A button next to a table of content coding buttons table

    I have a movieclip buttons table which is a table of contents for a module. I use a loop function to maintain their downward when clicked. All event listeners for each heading in the table of contents are encoded outside the loop, and each of them load an external swf file (in a table). I also have 'previous' and 'next' buttons that advance loading external swf files, but I also want the table of buttons to move forward and to highlight the next section. How to move the button outside its loop function table? I appreciate any idea.

    var buttonsArray:Array = [toc_mc.intro_mc, toc_mc.gen_mc, toc_mc.dist_mc, toc_mc.hered_mc, toc_mc.one_mc, toc_mc.two_mc, toc_mc.anim_mc, toc_mc.three_mc, toc_mc.four_mc, toc_mc.five_mc, toc_mc.six_mc, toc_mc.seven_m c, toc_mc.sevenB_mc, toc_mc.sevenC_mc, toc_mc.eight_mc, toc_mc.therapy_mc, toc_mc.therapyB_mc, t oc_mc.nine_mc, toc_mc.ten_mc];
    var i: int;
    function setButtons (): void {}
    for (i = 0; i < buttonsArray.length; i ++) {}

    buttonsArray [i] user.user = i;
    buttonsArray [i] .buttonMode = true;
    buttonsArray [i] .mouseChildren = false;
    buttonsArray [i] .mouseEnabled = true;
    buttonsArray [i] .addEventListener (MouseEvent.ROLL_OVER, playOver);
    buttonsArray [i] .addEventListener (MouseEvent.ROLL_OUT, playOut);
    buttonsArray [i] .addEventListener (MouseEvent.CLICK, doClick);
    }
    }

    function playOver(event:MouseEvent):void {}
    event.currentTarget.gotoAndStop (2);
    }

    function playOut(event:MouseEvent):void {}
    event.currentTarget.gotoAndStop (1);
    }

    function doClick(event:MouseEvent):void {}
    var currentBtn:int = event.currentTarget.id;
    setSelectedBtn (currentBtn);
    }
    function setSelectedBtn(id:int):void {}
    for (var i: int = 0; i < buttonsArray.length; i ++) {}
    If (id == i) {}
    buttonsArray [i] .gotoAndStop (3);
    buttonsArray [i] .buttonMode = false;
    buttonsArray [i] .mouseEnabled = false;
    buttonsArray [i] .removeEventListener (MouseEvent.ROLL_OVER, playOver);
    buttonsArray [i] .removeEventListener (MouseEvent.ROLL_OUT, playOut);
    buttonsArray [i] .removeEventListener (MouseEvent.CLICK, doClick);
    } else {}
    If (.currentFrame buttonsArray [i] == 3) {}
    buttonsArray [i] .gotoAndStop (1);
    }
    buttonsArray [i] .buttonMode = true;
    buttonsArray [i] .mouseEnabled = true;
    buttonsArray [i] .addEventListener (MouseEvent.ROLL_OVER, playOver);
    buttonsArray [i] .addEventListener (MouseEvent.ROLL_OUT, playOut);
    buttonsArray [i] .addEventListener (MouseEvent.CLICK, doClick);
    }
    }
    }

    setButtons();

    medPlay_mc.prev_btn.addEventListener (MouseEvent.CLICK, prev_onClick);

    medPlay_mc.next_btn.addEventListener (MouseEvent.CLICK, next_onClick);

    function next_onClick(event:MouseEvent):void {}


    current index refers to the table of swf file

    currentIndex ++;
    removeChild (loader);
    modBan_mc.visible = false;
    If (currentIndex > urlArray.length - 1) {}
    currentIndex = 0;
    }
    Loader.Load (new URLRequest (urlArray [currentIndex]));
    addChild (loader);
    addChild (toc_mc);
    addChild (medPlay_mc);
    }


    function prev_onClick(event:MouseEvent):void {}
    currentIndex-;
    removeChild (loader);
    If (currentIndex < 0) {}
    currentIndex = urlArray.length - 1;
    }
    Loader.Load (new URLRequest (urlArray [currentIndex]));
    addChild (loader);
    addChild (toc_mc);
    addChild (medPlay_mc);
    }

    use:

    var buttonsArray:Array = [toc_mc.intro_mc, toc_mc.gen_mc, toc_mc.dist_mc, toc_mc.hered_mc, toc_mc. one_mc, toc_mc.two_mc, toc_mc.anim_mc, toc_mc.three_mc, toc_mc.four_mc, OCD _mc.five_mc, toc_mc.six_mc, toc_mc.seven_mc, toc_mc.sevenB_mc, toc_mc.seve, nC_mc, toc_mc.eight_mc, toc_mc.therapy_mc, toc_mc.therapyB_mc, toc_mc.nine _mc, toc_mc.ten_mc];
    var i: int;
    function setButtons (): void {}
    for (i = 0; i
     
    buttonsArray [i] user.user = i;
    buttonsArray [i] .buttonMode = true;
    buttonsArray [i] .mouseChildren = false;
    buttonsArray [i] .mouseEnabled = true;
    buttonsArray [i] .addEventListener (MouseEvent.ROLL_OVER, playOver);
    buttonsArray [i] .addEventListener (MouseEvent.ROLL_OUT, playOut);
    buttonsArray [i] .addEventListener (MouseEvent.CLICK, doClick);
    }
    }

    function playOver(event:MouseEvent):void {}
    event.currentTarget.gotoAndStop (2);
    }

    function playOut(event:MouseEvent):void {}
    event.currentTarget.gotoAndStop (1);
    }

    function doClick(event:MouseEvent):void {}
    var currentBtn:int = event.currentTarget.id;
    setSelectedBtn (currentBtn);
    }
    function setSelectedBtn(id:int):void {}

    loadF (id);

    for (var i: int = 0; i< buttonsarray.length;="" i++)="">
    If (id == i) {}
    buttonsArray [i] .gotoAndStop (3);
    buttonsArray [i] .buttonMode = false;
    buttonsArray [i] .mouseEnabled = false;
    buttonsArray [i] .removeEventListener (MouseEvent.ROLL_OVER, playOver);
    buttonsArray [i] .removeEventListener (MouseEvent.ROLL_OUT, playOut);
    buttonsArray [i] .removeEventListener (MouseEvent.CLICK, doClick);
    } else {}
    If (.currentFrame buttonsArray [i] == 3) {}
    buttonsArray [i] .gotoAndStop (1);
    }
    buttonsArray [i] .buttonMode = true;
    buttonsArray [i] .mouseEnabled = true;
    buttonsArray [i] .addEventListener (MouseEvent.ROLL_OVER, playOver);
    buttonsArray [i] .addEventListener (MouseEvent.ROLL_OUT, playOut);
    buttonsArray [i] .addEventListener (MouseEvent.CLICK, doClick);
    }
    }
    }

    setButtons();

    medPlay_mc.prev_btn.addEventListener (MouseEvent.CLICK, prev_onClick);

    medPlay_mc.next_btn.addEventListener (MouseEvent.CLICK, next_onClick);

    function next_onClick(event:MouseEvent):void {}

    current index refers to the table of swf file

    currentIndex ++;
    removeChild (loader);
    modBan_mc.visible = false;
    If (currentIndex > urlArray.length - 1) {}
    currentIndex = 0;
    }
    loadF (currentIndex);

    setSelectedBtn (currentIndex);

    }

    function prev_onClick(event:MouseEvent):void {}
    currentIndex-;
    removeChild (loader);
    If (currentIndex< 0)="">
    currentIndex = urlArray.length - 1;
    }
    loadF (currentIndex);

    setSelectedBtn (currentIndex);

    }

    function loadF(i:int):void {}

    Loader.Load (new URLRequest (urlArray [i]));

    addChild (loader);

    addChild (toc_mc);

    addChild (medPlay_mc);

    }

  • XML slideshow with preloader bar

    I use the following code to create a simple slide show:

    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    import fl.transitions.TweenEvent;

    var my_speed:Number;
    var my_count:Number;
    var my_images:XMLList;

    var my_loaders_array:Array=[];
    var my_success_counter:Number=0;
    var my_playback_counter:Number=0;

    var my_slideshow:Sprite = new Sprite();
    var my_image_slides:Sprite = new Sprite();
    var my_preloader:TextField;

    var my_timer:Timer;
    var my_prev_tween:Tween;
    var my_tweens_array:Array=[];

    var my_xml_loader:URLLoader = new URLLoader();
    my_xml_loader.load(new URLRequest("theme1.xml"));
    my_xml_loader.addEventListener(Event.COMPLETE, preXML);

    next_mc.addEventListener(MouseEvent.CLICK, timerListener);
    prev_mc.addEventListener(MouseEvent.CLICK, goBack);

    function preXML(e:Event):void {
        var my_xml:XML=new XML(e.target.data);
        my_speed=my_xml.@SPEED;
        my_images=my_xml.IMAGE;
        my_count=my_images.length();

        loadImages();

        my_xml_loader.removeEventListener(Event.COMPLETE, preXML);
        my_xml_loader=null;
    }

    function loadImages():void {
        for (var i:Number = 0; i < my_count; i++) {
            var my_url:String=my_images[i].@URL;
            var my_loader:Loader = new Loader();
            my_loader.load(new URLRequest(my_url));
            my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
            my_loaders_array.push(my_loader);

        }

        my_preloader = new TextField();
        my_preloader.text="Loading";
        my_preloader.autoSize=TextFieldAutoSize.CENTER;
        my_preloader.x = (stage.stageWidth - my_preloader.width)/2;
        my_preloader.y = (stage.stageHeight - my_preloader.height)/2;
        addChild(my_preloader);

    }

    function onComplete(e:Event):void {

        my_success_counter++;
        if (my_success_counter==my_count) {
            startShow();
        }

        var my_loaderInfo:LoaderInfo=LoaderInfo(e.target);
        my_loaderInfo.removeEventListener(Event.COMPLETE, onComplete);

    }

    function startShow():void {

        removeChild(my_preloader);
        my_preloader=null;

        addChild(my_slideshow);
        my_slideshow.addChild(my_image_slides);

        nextImage();

        my_timer=new Timer(my_speed*2000);
        my_timer.addEventListener(TimerEvent.TIMER, timerListener);
        my_timer.start();

    }

    function nextImage():void {

        var my_image:Loader=Loader(my_loaders_array[my_playback_counter]);
        my_image_slides.addChild(my_image);
        my_image.x = (stage.stageWidth - my_image.width)/2;
        my_image.y = (stage.stageHeight - my_image.height)/2;
        my_tweens_array[0]=new Tween(my_image,"alpha",Strong.easeOut,0,1,1,true);

       
    }

    function timerListener(e:Event):void {
       
        hidePrev();

        my_playback_counter++;
        if (my_playback_counter==my_count) {
            my_playback_counter=0;
        }
       
        if(e.currentTarget is MovieClip)
        {
            my_timer.reset();
            my_timer.start();
        }
        nextImage();
    }

    function goBack(e:MouseEvent):void
    {
        hidePrev();
        my_playback_counter--;
        if (my_playback_counter<0) {
            my_playback_counter=my_count-1;
        }
        nextImage();
       
        my_timer.reset();
        my_timer.start();
    }

    function hidePrev():void {

        var my_image:Loader=Loader(my_image_slides.getChildAt(0));
        my_prev_tween=new Tween(my_image,"alpha",Strong.easeOut,1,0,1,true);
        my_prev_tween.addEventListener(TweenEvent.MOTION_FINISH, onFadeOut);

    }

    function onFadeOut(e:TweenEvent):void {
        my_image_slides.removeChildAt(0);
    }

    I would change "loading" to a preloader bar. How can I insert a preloader bar in this code? I add these lines:

    var total:Number=this.stage.loaderInfo.bytesTotal;
        var loaded:Number=this.stage.loaderInfo.bytesLoaded;
        var percent:Number=loaded/total;[/b]
        my_preloader = new TextField();
        my_preloader.text=(Math.round(percent * 100)) + "%";
        my_preloader.autoSize=TextFieldAutoSize.CENTER;
        my_preloader.x = (stage.stageWidth - my_preloader.width)/2;
        my_preloader.y = (stage.stageHeight - my_preloader.height)/2;
        addChild(my_preloader);

    But only show a static '100% '.

    Thank you guys!

    you will need to change your basic configuration of all these images in a loop for their loading in load order.  so, to get started:

    var loadIndex:int;
    
    function preXML(e:Event):void {    var my_xml:XML=new XML(e.target.data);    my_speed=my_xml.@SPEED;    my_images=my_xml.IMAGE;    my_count=my_images.length();loadIndex=0;    loadImages();
    
        my_xml_loader.removeEventListener(Event.COMPLETE, preXML);    my_xml_loader=null;}
    
    function loadImages():void {var i:int=loadIndex;        var my_url:String=my_images[i].@URL;        var my_loader:Loader = new Loader();        my_loader.load(new URLRequest(my_url));        my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete); my_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
    
            my_loaders_array.push(my_loader);y_preloader = new TextField();
    
        my_preloader.x = (stage.stageWidth - my_preloader.width)/2;    my_preloader.y = (stage.stageHeight - my_preloader.height)/2;    addChild(my_preloader);
    
        }
    
    function onProgress(e:ProgressEvent):void{var total:Number=e.bytesTotal;    var loaded:Number=e.bytesLoaded;    var percent:Number=loaded/total;[/b]    my_preloader.text=100*loadIndex/my_count+(Math.round(percent * 100))/my_count + "%";    my_preloader.autoSize=TextFieldAutoSize.CENTER;}
    
    function onComplete(e:Event):void {
    
        loadIndex++;    if (loadIndex==my_count) {        startShow();    }
    
        var my_loaderInfo:LoaderInfo=LoaderInfo(e.target);    my_loaderInfo.removeEventListener(Event.COMPLETE, onComplete);loadImage();}
    
  • Odd error using XMLType()

    Hello

    I have a procedure (listed below) that takes a sql query and create an xmltype to place on an advanced queue. With the help of DBMS_XMLGEN, the query is executed and returned as a CLOB. A new CLOB is created, as we must insert a header before the generated XML code and add a footer.

    * There is probably a better way to do it.

    However, the query that we execute returns 16 ranks. When I run into my 10g XE development environment, it works fine. However when I run the procedure in the environment of QA (10g company), it will fail, indicating the XML is malformed. If I limit the lines max int function setMaxRows at the 11 - it works. What I noticed with dbms_output, is that if the length of the XML file is greater than 8K, it fails. I tried various queries and results are the same.

    Does anyone have an idea why this is happening?

    Thanks in advance.


    * XML_HEADER and XML_FOOTER contain only root for the doc

    Definitions of constants
    --------------------------------------------
    XML_ROWSET_TAG = 'DATA '.
    XML_ROW_TAG = "DATA_ITEM.
    XML_HEADER_OFFSET = 22
    XML_MAX_ROWS = 200
    --------------------------------------------

    qryCtx: = dbms_xmlgen.newContext (sql_query);
    DBMS_XMLGEN.setRowSetTag (qryCtx, XML_ROWSET_TAG);
    DBMS_XMLGEN.setRowTag (qryCtx, XML_ROW_TAG);
    DBMS_XMLGEN.setMaxRows (qryCtx, XML_MAX_ROWS);
    LOOP
    -Save the XML code in the CLOB result.
    xmlgen_result: = DBMS_XMLGEN.getXML (qryCtx);
    xml_structure: = XML_HEADER
    || DBMS_LOB.substr (xmlgen_result, (xmlgen_result), XML_HEADER_OFFSET length)
    || XML_FOOTER;
    donnees_xml: = XMLType (xml_structure);
    -If no line does not exist, the output before the queue data
    WHEN the OUTPUT DBMS_XMLGEN.getNumRowsProcessed (qryCtx) = 0;
    ENQUEUE_OBJECT (donnees_xml, correlation);
    END LOOP;
    dbms_xmlgen.closeContext (qryCtx);
    DBMS_LOB.freeTemporary (xml_structure);

    Let the results of dbms_xmlgen.getXML as an XMLTYPE and do something like the following:

    select appendchildxml(XMLElement("root"),  -- whatever your root element is
                          '/root',
                          xmlelement("Hold",1))  -- your returned XMLType here
      from dual;
    

    creates
    1
    This avoids the conversion of XMLType to CLOB to XMLType.

  • Subtraction of dates in Essbase

    Hi all! :) I created three dimension, say Date1, Date2and months. The data type of Date1 and Date2 is 'Date' and the data type of the month is NonCurrency. The date format is dd-mm-aa. I need to subtract from Date1 Date2 and turn the resulting in the number of months months analytical number. When I entered 10.01.09 Date1 and the 31.01.09 to Date2, the formula than date2 - Date1 calculated the difference of 21 which I think is probably the difference in days. But once I entered the 01.02.09 to Date2, Date2 - Date1 formula gave the result of 91 instead of 22! I just need correctly calculate the difference between Date1 and Date2 in whatever units - can anyone give me a hint on who? Thank you very much in advance!

    Edited by: user10129034 the 18.05.2009 01:26

    Edited by: user10129034 the 18.05.2009 01:28

    Hello

    When you set the data with the intention of being essbase Date type stores this as a numeric value in the format YYYYMMDD, e.g. 10.01.2009 is stored as 20090110, 31.01.09 20090131 and as 20090201 01.02.2009.

    If you subtract just one another so if in the same month it should work, but as soon as it crosses the end of the month he will not as it jumps to the next hundred i.e. 20090131 to 20090201 (difference of 70 no 1).

    The way that this is handled in version 9.3 is to use the @INT function to separate the days, months and years to date, and to calculate, but it's messy and even in capital investment planning module that they usually only attempt to do a month!

    In version 11, however, they introduced some new functions of calculation, for example @DATEDIFF which should do is much easier. I did have the chance to try them yet but it reads as if it works the same as excel (for the dates of the 01.01.1970 at the 01.01.2038).

    Check the documentation / technical reference to learn more about these functions.

    Hope this helps
    Stuart

  • DB handle insert faster the cursor inserts?

    I want to just make sure that I'm not missing something, but it seems that Db::put() is faster than using a Dbc::put()?

    I had come up with the idea, since then I insert an already ordered list (keys are integers (ints), using a comparison of integers (ints) function), you use a cursor would eventually be faster as each subsequent insertion would not need that cross all BTree (which is what Db::put(), no?).

    Instead, I find that it is still about 20% slower.

    Maybe I am doing something wrong?

    Test the code demonstrating the behavior:

    Truncate db
    Insert 6000 integers (1-30000 by 5)
    engage.
    insert/update, integers (1-30000 by 4)

    It makes both back to back and timekeeping product. It is built on Solaris 10, so your deck do not have hrtime_t and gethrtime()

    My results (consistantly) are:
    100 ms using Db::put()
    120ms using the::get() Dbc and Dbc::put()
    (also, I use a 512 MB cache)

    -----
    #include & lt; sys/time.h & gt;
    #include & lt; iostream & gt;
    #include & lt; db_cxx.h & gt;
    #include & lt; sys/stat.h & gt;


    int bdbKeyCompare (Db *, const dbt2 dbt1, const Dbt Dbt)
    {

    int * ip1 = (int *) dbt1 - & gt;get_data();
    int * ip2 = (int *) dbt2 - & gt;get_data();

    If (* ip1 & gt; * ip2)
    Return 1;
    ElseIf (* ip1 & lt; * ip2)
    Returns - 1;
    on the other
    return 0;

    }


    void errCb (const env, const char prefix DbEnv, const char * msg)
    {
    std::CERR & lt; & lt; "[BDB ERROR]" & lt; & lt; MSG & lt; & lt; std::ENDL;
    }

    DbEnv * openBerkeleyEnv(char *envLoc)
    {
    DbEnv * env = new DbEnv (0);

    Try
    {

    env - & gt; set_errcall (errCb);
    env - & gt; set_lk_detect (DB_LOCK_YOUNGEST);


    env - & gt; Open (envLoc, DB_CREATE |) DB_INIT_MPOOL | DB_INIT_TXN |
    DB_INIT_LOG | DB_INIT_LOCK | DB_SYSTEM_MEM |
    DB_THREAD | DB_RECOVER | DB_REGISTER, 0);

    }
    catch (DbException & dbex)
    {
    printf ("[FATAL] BDB exception caught while trying to open the environment (%s)": %s ", envLoc, dbex.what ()");
    Remove env;
    Returns false;
    }




    return the env;
    }

    int main()
    {



    DbEnv * env = openBerkeleyEnv("./testEnv");
    DbTxn * txn = NULL;
    DB * dbh = new Db (env, 0);
    DBH - & gt;get_env() - & gt; txn_begin (NULL, & txn, 0);
    DBH - & gt; set_pagesize (512);
    DBH - & gt; set_bt_compare (bdbKeyCompare);
    DBH - & gt; Open (txn, "test.db", NULL, DB_BTREE, DB_CREATE |) DB_THREAD, S_IRUSR | S_IWUSR);
    TXN - & gt; validation (0);
    TXN = NULL;

    uint32_t c = 0;

    DBH - & gt;get_env() - & gt; txn_begin (NULL, & txn, 0);
    DBH - & gt; truncate (txn, & c, 0);
    TXN - & gt; commit (0);

    DBC * cursor = NULL;

    DBT gKey;
    DBT gValue.
    TXN = NULL;
    DBH - & gt;get_env() - & gt; txn_begin (NULL, & txn, 0);


    int v;

    int rc;
    v = 1;
    int count = 0;

    Key to DBT (& County, 4);
    Key.set_flags (DB_DBT_USERMEM);
    Key.set_ulen (4);

    Value of DBT (& v, 4);
    value.set_flags (DB_DBT_USERMEM);
    value.set_ulen (4);

    for (count = 0; count & lt; = 30000; count += 5)
    {
    DBH - & gt; put (txn, & key and value, 0);
    }

    TXN - & gt; commit (0);

    int ret = 0;
    curV int = 0;

    departure from hrtime_t = gethrtime();
    DBH - & gt;get_env() - & gt; txn_begin (NULL, & txn, 0);
    for (count = 0; count & lt; = 30000; count += 4)
    {
    RET = DBH - & gt; put (txn, & key and value, DB_NOOVERWRITE);
    If (ret is DB_KEYEXIST)
    {
    DBH - & gt; get (txn, & key and value, 0);
    v += 1;
    DBH - & gt; put (txn, & key and value, 0);
    v = 1;
    }

    }
    TXN - & gt; commit (0);
    end of hrtime_t = gethrtime();
    hrtime_t diff1 = end - start;



    DBH - & gt;get_env() - & gt; txn_begin (NULL, & txn, 0);
    DBH - & gt; truncate (txn, & c, 0);
    TXN - & gt; commit (0);

    DBH - & gt;get_env() - & gt; txn_begin (NULL, & txn, 0);
    for (count = 0; count & lt; = 30000; count += 5)
    {
    DBH - & gt; put (txn, & key and value, 0);
    }

    TXN - & gt; commit (0);

    int kCount = 0;
    Key.SET_DATA (& kCount);
    Start = gethrtime();
    DBH - & gt;get_env() - & gt; txn_begin (NULL, & txn, 0);
    DBH - & gt; cursor (txn, & slider, 0);



    for (count = 0; count & lt; = 30000; count += 4)
    {
    kCount = count;
    RC = cursor - & gt; get (key, & value, DB_SET_RANGE);

    DBH - & gt; put (txn, & key and value, 0);

    If (rc! = DB_NOTFOUND)
    {


    If (* (int *) key.get_data () == count) / / it is already in the db
    {
    std::cout & lt; & lt; "found the key/value, update in place" & lt; & lt; std::ENDL;
    v += 1;
    cursor - & gt; put (key, & value, DB_CURRENT);
    v = 1;
    }
    on the other
    {
    std::cout & lt; & lt; "Found key/value, but not this one" & lt; & lt; std::ENDL;
    kCount = count;
    v = 1;
    cursor - & gt; put (key, & value, DB_KEYLAST);
    }

    }
    Else if (rc == DB_NOTFOUND)
    {
    std::cout & lt; & lt; "Nothing in the DB, insert" & lt; & lt; std::ENDL;
    kCount = count;
    v = 1;
    cursor - & gt; put (key, & value, DB_KEYFIRST);
    }

    }



    cursor - & gt;close();
    TXN - & gt; commit (0);

    end = gethrtime();
    hrtime_t diff2 = end - start;



    printf ("loading time: %dms\n", diff1/1000000);
    printf ("loading time: %dms\n", diff2/1000000);

    DBH - & gt; closed (0);
    env - & gt; closed (0);

    exit (1);
    }

    Published by: user4205883 on December 29, 2008 10:23

    Hello.

    Using a slider you cannot avoid the tree research on the successive entries. The tree could have changed since the cursor last use, due to deletions or insertions of other sliders or directly handles Db, so it is not prudent for the cursor directly access the last worksheet page he used (this page can no longer exists)! The sliders are really designed to allow access to the duplicates and iterating over all the elements.

    That said, the numbers in your test are biased because cursors do not support your workload as easily as using a Db handle is. The loop using Db::put operation 1 of BDB 80% of the time and BDB 3 operations of 20% of the time, an average of 1.4 in. BDB per iteration. The loop using Dbc::put performs operations of BDB 2 each iteration. I would bet that you would see similar to Db::put and Dbc::put numbers if you were to use the same steps for the handful of the Db.

    Ben Schmeckpeper

  • How to access vector &lt; int &gt; data passed to the function of iteration?

    So, basically, I have all the work by accomplished Supercomputing in the Render() function and threw a vector < int > (with all my final pixel already calculated and stored inside values) to the iteration function.

    However, when I go to assign: output-> red-> green, out-> blue, out-> alpha , result is a revamped image:Screen Shot 2015-07-03 at 2.33.53 AM.png

    My pixel processing function that I pass to the iteration inside the function Render() function looks like this:

    IM with the final pixel data in a vector < int > called given that present a size() of (width * height * 4) with values in rgba order.

    public static PF_Err

    () drawTriangles8

    void * Conref.

    A_long xL,

    A_long yL,

    PF_Pixel8 * inP,

    PF_Pixel8 * output)

    {

    PF_Err err = PF_Err_NONE

    TriangulateInfo * tInfo = reinterpret_cast<TriangulateInfo* > (Conref);

    if (tInfo) {

    Output->Red tInfo->data= [(int) ((xL * 4) + (yL * tInfo->width * 4))];

    Output->Green tInfo->data= [(int) ((xL * 4 + 1) + (yL * tInfo->width * 4))];

    Output->Blue tInfo->data= [(int) ((xL * 4 + 2) + (yL * tInfo->width * 4))];

    Output->alpha tInfo->data= [(int) ((xL * 4 + 3) + (yL * tInfo->width * 4))];

    }

    return err;

    }

    I tried just to save the values of the original image with no calculations done RGBA and try them back on the resulting image so that it remains unchanged and I get always the same the smeared image search. No idea what's going on?

    This is not the point of my last answer.

    my point was that you store in your vector, the pixels in this order:

    x0y0 x0y1, x0y2... x1y0, x1y1, x1y2...

    Maybe the way you shoot you pixels from the vector assume they are

    ordered:

    x0y0 x1y0, x2y0... x0y1, x1y1, x2y1...

    If that's true, which would explain the image being on his side, and the

    the offset to the line you see.

Maybe you are looking for