How best can i optimise this script

I have a script the loops through a table and function. it works fine but it takes a longer time complete even though resources are given. the code below is just the same code i used how best can i represent it for speed even though i have all resources.
For each_member in ( select from MemberTable where MemberID = 'ALL')*
Loop
Begin
if Age >= 18 then
hold:= 'Adult'
end if;
For Each_history in (select Acct,fx_function(each_member.ID,each_member.Acct) BR,
Movement from History a where history_ID =each_member.Id)
loop
Begin
insert into NewFilteredData (act,BR,mvt)
values (Each_history.Acct,Each_history.BR,Each_history.Movement);
end loop;
end loop;
end loop;
commit;
How best can i optimize this script to move data faster because they are a lot about 6000000 records to be moved.
please help.
Edited by: kama021 on Aug 25, 2009 12:48 PM
Edited by: kama021 on Aug 25, 2009 12:48 PM

Unless something is horribly wrong (i.e. the optimizer picks a radically incorrect plan), if you can do something in SQL, it will always be faster to do it in SQL. Doing things in PL/SQL, particularly using cursor FOR loops and single row inserts, is the slowest possible way to do anything (well, other than having nested FOR loops).
Long before you start looking at things like the APPEND hint, I would focus on implementing a single SQL statement that generates the correct results. Once you have that and you have a benchmark, you can decide whether it is "fast enough". If it is (and I suspect it will be), you don't have to delve any deeper. If you need more performance, you can start looking into parallelism, the APPEND hint, etc. but be aware that this generally increases the complexity of the system.
Justin

Similar Messages

  • I want to set-up a network with our current two laptops for a family of 4 w/unique 4 profiles. I'd like everyone to be agnostic about which computer to log into and use but still have private docs and apps (i.e.mail/facebook). How best can I do this?

    I want to set-up a network with our current two laptops for a family of 4 with unique 4 profiles.  I'd like everyone to be agnostic about which computer to log into and use but still have private docs and apps (i.e. mail/facebook).  How best can I do this?

    iCloud Photo Sharing FAQ - Apple Support
    http://www.fatcatsoftware.com/iplm/Help/accessing%20an%20iphoto%20library%20on%2 0another%20mac.html

  • Hi, Can anyone recommended software to import dvd to iMovies. I need to import about a dozen homemade DVD's and edit them into a single DVD comprising the 'best bits'. How best can I do this. I have an external hard drive available for the job

    Hi, Can anyone recommended software to import dvd to iMovies. I need to import about a dozen homemade DVD's and edit them into a single DVD comprising the 'best bits'. How best can I do this. I have an external hard drive available for the job

    You need to convert the VOB files in the TS-Folder of the DVD back to DV which iMovie is designed to handle. For that you need mpegStreamclip:
    http://www.squared5.com/svideo/mpeg-streamclip-mac.html
    which is free, but you must also have the  Apple mpeg2 plugin :
    http://store.apple.com/us/product/D2187Z/A/quicktime-mpeg-2-playback-component-f or-mac-os-x
    (unless you are running Lion in which case see below))
    which is a mere $20.
    Another possibility is to use DVDxDV:
    http://www.dvdxdv.com/NewFolderLookSite/Products/DVDxDV.overview.htm
    which costs $25.
    For the benefit of others who may read this thread:
    Obviously the foregoing only applies to DVDs you have made yourself, or other home-made DVDs that have been given to you. It will NOT work on copy-protected commercial DVDs, which in any case would be illegal.
    And from the TOU of these forums:
    Keep within the Law
    No material may be submitted that is intended to promote or commit an illegal act.
    Do not submit software or descriptions of processes that break or otherwise ‘work around’ digital rights management software or hardware. This includes conversations about ‘ripping’ DVDs or working around FairPlay software used on the iTunes Store.
    If you are running Lion or later:
    From the MPEG Streamclip homepage
    The installer of the MPEG-2 Playback Component may refuse to install the component in Lion. Apple states the component is unnecessary in Lion onwards, however MPEG Streamclip still needs it. See this:
    http://support.apple.com/kb/HT3381
    To install the component in Lion, please download MPEG Streamclip 1.9.3b7 beta above; inside the disk image you will find the Utility MPEG2 Component Lion: use it to install the MPEG-2 Playback Component in Lion. The original installer's disk image (QuickTimeMPEG2.dmg) is required.
    The current versions of MPEG Streamclip cannot take advantage of the built-in MPEG-2 functionality of Lion. For MPEG-2 files you still need to install the QuickTime MPEG-2 Playback Component, which is not preinstalled in Lion. (The same applies to Mountain Lion even though that has it preinstalled.) You don't have to install QuickTime 7.

  • How best can I become proficient in Adobe photoshop?

    How best can I be more proficient in the adobe Photoshop?
    In the tutorials, they talk so fast and assume a lot that the beginner is left wondering and usually at a loss.
    Why not make it simple and do not talk as if you are talking to an expert or yourself.
    Thank you.

    Hi Ben,
    I'm sorry that the Getting Started tutorial isn't working for you.Maybe check out our Photography Jump Start page. Hopefully you'll be able to find some that suit your needs.
    Also, if you go to this page, you will see our entire set of tutorials, in a variety of formats.
    Best regards,
    Randy Nielsen
    Senior Content Manager, Creative Cloud Learn
    Adobe

  • I'm unable to download iMovie/iphoto, as i didn't buy the mac brand new, it only gives me the 'accept' button when i try to download, i don't mind purchasing, it just doesn't give me the option. any ideas how i can get around this?

    I recently purchased a second hand new macbook air, although it was second hand to me the previous owner had never actually turned it on. So i went through all the set up steps when switching it on for the first time.
    My problem is that iPhoto and iMovie are not installed, and when i go to the app store the icons have an accept button, it then prompts me for my apple ID, obviously these a registered to the original owner, and says i need that ID in order to download them, or i'll have to purchase them.
    I'm happy to purchase them, but it doesn't give me that option, every time i search for them in the app store they always come up with the accept option and no purchase option.
    Any idea how i can get round this would be great fully appreciated.

    I recently purchased a second hand new macbook air, although it was second hand to me the previous owner had never actually turned it on.
    Something doesn't make sense here, though I'm not saying the previous owner is lying....
    Time to send your serial # to iTS and let them see what's happening here.
    iTunes Store Support
    http://www.apple.com/emea/support/itunes/contact.html

  • Can i use this script in illustrator?

    can i use this script in illustrator?
    Newsgroup_User

    // This script exports extended layer.bounds information to [psd_file_name].xml
    // by pattesdours
    function docCheck() {
        // ensure that there is at least one document open
        if (!documents.length) {
            alert('There are no documents open.');
            return; // quit
    docCheck();
    var originalRulerUnits = preferences.rulerUnits;
    preferences.rulerUnits = Units.PIXELS;
    var docRef = activeDocument;
    var docWidth = docRef.width.value;
    var docHeight = docRef.height.value;
    var mySourceFilePath = activeDocument.fullName.path + "/";
    //  Code to get layer index / descriptor
    cTID = function(s) { return app.charIDToTypeID(s); };
    sTID = function(s) { return app.stringIDToTypeID(s); };
    function getLayerDescriptor (doc, layer) {
        var ref = new ActionReference();
        ref.putEnumerated(cTID("Lyr "), cTID("Ordn"), cTID("Trgt"));
        return executeActionGet(ref)
    function getLayerID(doc, layer) {
      var d = getLayerDescriptor(doc, layer);
      return d.getInteger(cTID('LyrI'));
    var stackorder = 0;
    // function from Xbytor to traverse all layers
    traverseLayers = function(doc, ftn, reverse) {
      function _traverse(doc, layers, ftn, reverse) {
        var ok = true;
        for (var i = 1; i <= layers.length && ok != false; i++) {
          var index = (reverse == true) ? layers.length-i : i - 1;
          var layer = layers[index];
          //  alert("layer.typename  >>> "+layer.typename ); 
          if (layer.typename == "LayerSet") {
            ok = _traverse(doc, layer.layers, ftn, reverse);
          } else {
      stackorder = stackorder + 1;
            ok = ftn(doc, layer, stackorder);
        return ok;
      return _traverse(doc, doc.layers, ftn, reverse);
    // create a string to hold the data
    var str ="";
    // class using a contructor
    function cLayer(doc, layer) {
    //this.layerID = Stdlib.getLayerID(doc, layer);
      this.layerID = getLayerID(doc, layer);
      //alert("layer ID: " + this.layerID);
      this.layerWidth = layer.bounds[2].value - layer.bounds[0].value;
          this.layerHeight = layer.bounds[3].value - layer.bounds[1].value;
      // these return object coordinates relative to canvas
          this.upperLeftX = layer.bounds[0].value;
          this.upperLeftY = layer.bounds[1].value;
          this.upperCenterX = this.layerWidth / 2 + layer.bounds[0].value;
          this.upperCenterY = layer.bounds[1].value;
          this.upperRightX = layer.bounds[2].value;
          this.upperRightY = layer.bounds[1].value;
          this.middleLeftX = layer.bounds[0].value;
          this.middleLeftY = this.layerHeight / 2 + layer.bounds[1].value;
          this.middleCenterX = this.layerWidth / 2 + layer.bounds[0].value;
          this.middleCenterY = this.layerHeight / 2 + layer.bounds[1].value;
          this.middleRightX = layer.bounds[2].value;
          this.middleRightY = this.layerHeight / 2 + layer.bounds[1].value;
          this.lowerLeftX = layer.bounds[0].value;
          this.lowerLeftY = layer.bounds[3].value;
          this.lowerCenterX = this.layerWidth / 2 + layer.bounds[0].value;
          this.lowerCenterY = layer.bounds[3].value;
          this.lowerRightX = layer.bounds[2].value;
          this.lowerRightY = layer.bounds[3].value;
       // I'm adding these for easier editing of flash symbol transformation point (outputs a 'x, y' format)
       // because I like to assign shortcut keys that use the numeric pad keyboard, like such:
       // 7 8 9
       // 4 5 6
       // 1 2 3
          var windowW=2048;
          var windowH=1536;
       this.leftBottom = this.lowerLeftX + ", " + (windowH-this.lowerLeftY);
       this.bottomCenter = this.lowerCenterX + ", " +  (windowH-this.lowerCenterY);
       this.rightBottom = this.lowerRightX + ", " + this.lowerRightY;
       this.leftCenter = this.middleLeftX + ", " + this.middleLeftY;
       this.center = this.middleCenterX + ", " + this.middleCenterY;
       this.rightCenter = this.middleRightX + ", " + this.middleRightY;
       this.leftTop = this.upperLeftX + ", " + this.upperLeftY;
       this.topCenter = this.upperCenterX + ", " + this.upperCenterY;
       this.rightTop = this.upperRightX + ", " + this.upperRightY;
      // these return object coordinates relative to layer bounds
          this.relUpperLeftX = layer.bounds[1].value - layer.bounds[1].value;
          this.relUpperLeftY =  layer.bounds[0].value - layer.bounds[0].value;
          this.relUpperCenterX = this.layerWidth / 2;
          this.relUpperCenterY = layer.bounds[0].value - layer.bounds[0].value;
          this.relUpperRightX = this.layerWidth;
          this.relUpperRightY = layer.bounds[0].value - layer.bounds[0].value;
          this.relMiddleLeftX = layer.bounds[1].value - layer.bounds[1].value;
          this.relMiddleLeftY = this.layerHeight / 2;
          this.relMiddleCenterX = this.layerWidth / 2;
          this.relMiddleCenterY = this.layerHeight / 2;
          this.relMiddleRightX = this.layerWidth;
      this.relMiddleRightY = this.layerHeight / 2;
          this.relLowerLeftX = layer.bounds[1].value - layer.bounds[1].value;
          this.relLowerLeftY = this.layerHeight;
          this.relLowerCenterX = this.layerWidth / 2;
      this.relLowerCenterY = this.layerHeight / 2;
          this.relLowerRightY = this.layerHeight;
          this.relLowerRightX = this.layerWidth;
          this.relLowerRightY = this.layerHeight;
      return this;
    // add header line
    str = "<psd filename=\"" + docRef.name + "\" path=\"" + mySourceFilePath + "\" width=\"" + docWidth + "\" height=\"" + docHeight + "\">\n";
    // now a function to collect the data
    var isParentAvailable=false;
    var prevLayerSetName="";
    function exportBounds(doc, layer, i) {
        var isVisible = layer.visible;
        var layerData = cLayer(doc, layer);
    //alert("layer.name  >>> "+layer.name );
    //alert("typename >>> "+layer.typename);
    /*if(layer.parent.name == "ParentTest"){
    for(var i in layer.parent){
        alert(" III >>> "+i+"<<<layer.parent>>"+layer.parent[i]);
      if(isVisible){
    // Layer object main coordinates relative to its active pixels
    var startStr="";
        if(layer.parent.typename=="LayerSet"){
            if(prevLayerSetName!="LayerSet")    {
                startStr="\t<parentlayer id='"+layer.parent.name+"'>\n\t";
            }else{
                   startStr="\t";
            // endStr="\t</parentlayer>\n";
             prevLayerSetName=layer.parent.typename;
          }else{
               if(prevLayerSetName=="LayerSet"){
                    startStr="\t</parentlayer>\n";
                prevLayerSetName="";
      var positionStr=layer.name.split(".")[0].substr(layer.name.split(".")[0].length-3,layer.name. split(".")[0].length);
      var assetPosition=leftTop;
      if(positionStr=="L_B"){
      assetPosition=leftBottom;
      }else if(positionStr=="B_C"){
      assetPosition=bottomCenter;
      }else if(positionStr=="R_B"){
      assetPosition=rightBottom;
      }else if(positionStr=="L_C"){
      assetPosition=leftCenter;
      }else if(positionStr=="C"){
      assetPosition=center;
      }else if(positionStr=="R_C"){
      assetPosition=rightCenter;
      }else if(positionStr=="L_T"){
      assetPosition=leftTop;
      }else if(positionStr=="T_C"){
      assetPosition=topCenter;
      }else if(positionStr=="R_T"){
      assetPosition=rightTop;
      var str2 =startStr+ "\t<layer name=\"" + layer.name
      + "\" stack=\"" + (i - 1) // order in which layers are stacked, starting with zero for the bottom-most layer
      + "\" position=\"" + assetPosition // this is the
      + "\" layerwidth=\"" + layerData.layerWidth
      + "\" layerheight=\"" + layerData.layerHeight
      + "\" transformpoint=\"" + "center" + "\">" // hard-coding 'center' as the default transformation point
      + layer.name + ".png" + "</layer>\n" // I have to put some content here otherwise sometimes tags are ignored
    str += str2.toString();
    // call X's function using the one above
    traverseLayers(app.activeDocument, exportBounds, true);
    // Use this to export XML file to same directory where PSD file is located
        var mySourceFilePath = activeDocument.fullName.path + "/";
    // create a reference to a file for output
        var csvFile = new File(mySourceFilePath.toString().match(/([^\.]+)/)[1] + app.activeDocument.name.match(/([^\.]+)/)[1] + ".xml");
    // open the file, write the data, then close the file
    csvFile.open('w');
    csvFile.writeln(str + "</psd>");
    csvFile.close();
    preferences.rulerUnits = originalRulerUnits;
    // Confirm that operation has completed
    alert("Operation Complete!" + "\n" + "Layer coordinates were successfully exported to:" + "\n" + "\n" + mySourceFilePath.toString().match(/([^\.]+)/)[1] + app.activeDocument.name.match(/([^\.]+)/)[1] + ".xml");

  • Hi. I have purchased Lego Indiana Jones for my Macbook Pro. On trying to install it, it is telling me it encountering an error. Does anyone know how I can get around this? Cheers

    Hi. I have purchased Lego Indiana Jones for my Macbook Pro. On trying to install it, it is telling me it encountering an error. Does anyone know how I can get around this? Cheers

    I have this problem too the error message for me is error 36
    (It works on my Macbook but not my Macbook pro)
    Any help you could give would be great

  • Hi iam using IPHONE4 , when i coonect it to my PC , itunes get hang and don't detect my iphone , how i can sort out this issue plz help me

    Hi iam using IPHONE4 , when i coonect it to my PC , itunes get hang and don't detect my iphone , how i can sort out this issue plz help me

    iPhone, iPad, or iPod touch not appearing in iTunes

  • I can't get this script to produce output to the screen or a log file

    I can't get this script to produce output to the screen or a log file of the select statement results as they are executed.
    SET SERVEROUTPUT ON size 100000
    DECLARE
    v_schema     Varchar2(50);
    v_statement      Varchar2(500);
    v_name varchar2(30);
    v_id varchar2(8);
    v_pwd varchar2(16);
    v_acct varchar2(16);
    CURSOR get_schemas IS
    SELECT DISTINCT owner
    FROM all_tables
    WHERE table_name = 'USERID'
    ORDER BY owner;
    BEGIN
    OPEN get_schemas;
    LOOP
    FETCH get_schemas INTO v_schema;
    EXIT WHEN get_schemas%NOTFOUND;
              v_statement := 'SELECT name,usid,passwd,acctnum INTO v_name,v_id,v_pwd,v_acct FROM '||v_schema||'.userid';
              execute immediate v_statement;
              DBMS_OUTPUT.PUT_LINE('Name='||v_name||' ID='||v_id||' PW='||v_pwd||' AC='||v_acct);          
    END LOOP;
    CLOSE get_schemas;
    END;
    /

    Duplicate post.
    When I run this script nothing is output to the screen or spooled to a file

  • I have a 1st generation AirPort Extreme and want to create a guest network, can I? If so, how? Can I do this by adding an Airport Express?

    I have a 1st generation AirPort Extreme and want to create a guest network, can I? If so, how? Can I do this by adding an Airport Express?

    I have a 1st generation AirPort Extreme and want to create a guest network, can I?
    This version of the AirPort Extreme does not have guest network capability.
    Can I do this by adding an Airport Express?
    Why not simply buy a new Airport Express.....which does have main and guest network capability*.....and sell the AirPort Extreme?
    * The AirPort Express will need to connect to a simple modem.....not a modem/router or gateway type of device.....for the guest network feature to work correctly.

  • Just tell me how I can type on this thing...

    tell me how i can tyep on this thing?  I don't have the time to play around...
    Message was edited by: kewodignet

    As noted above, If you have access to your computer. But that is a Very Bad Idea. That is how passwords get forgotten especially when you need to remember it.
    What you don't like typing in a few letters when you start you computer? That also opens up the system from anyone walking buy and turn it on. It give them full acces to your private files.
    Whatever.

  • Hello, when i download app, the app save in my id (in purchased), so how i can to delete this

    hello, when i download app, the app save in my id (in purchased), so how i can to delete this??

    You can't.
    This allows for being able to redownload a purchased app without having to pay for it again in the event the app was deleted.

  • I accidently deleted Safari and now I can't reinstall because it keeps telling me there is a newer version on my computer.  The issue is my system does not support the newer version.  Does anyone know how I can get around this?

    I accidently deleted Safari and now I can't reinstall because it keeps telling me there is a newer version on my computer.  The issue is my system does not support the newer version.  Does anyone know how I can get around this?

    Apple wanted to charge me 50 bucks jsut to talk to someone! 
    I believe you may be referring to the $49 ASL agreement at AppleCare? That is only when/if you are out of AppleCare Protection.
    Can you get to an AppleStore Genius Bar?
    They may be able to fix this for you. No charge.
    I highly doubt that. There is a $70 charge for troubleshooing software issues, EVEN IF there is AppleCare Warranty on the hardware.
    However, since there is no charge for an appointment at a Bar, go make one, and see what options they give you. Let us know how it goes.

  • How can I modify this script to return only certain rows of my mySQL table?

    Hi there,
    I have a php script that accesses a mySQL database and it was generated out of the Flex Builder wizard automatically. The script works great and there are no problems with it. It allows me to perform CRUD on a table by calling it from my Flex app. and it retrieves all the data and puts it into a nice MXML format.
    My question, currently when I call "findAll" to retrieve all the data in the table, well, it retrieves ALL the rows in the table. That's fine, but my table is starting to grow really large with thousands of rows.
    I want to modify this script so that I can pass a variable into it from Flex so that it only retrieves the rows that match the "$subscriber_id" variable that I pass. In this way the results are not the entire table's data, only the rows that match 'subscriber_id'.
    I know how to pass a variable from Flex into php and the code on the php side to pick it up would look like this:
    $subscriberID = $_POST['subscriberID'];
    Can anyone shed light as to the proper code modification in "findAll" which will take my $subscriberID variable and compare it to the 'subscriber_id' field and then only return those rows that match? I think it has something to do with lines 98 to 101.
    Any help is appreciated.
    <?php
    require_once(dirname(__FILE__) . "/2257safeDBconn.php");
    require_once(dirname(__FILE__) . "/functions.inc.php");
    require_once(dirname(__FILE__) . "/XmlSerializer.class.php");
    * This is the main PHP file that process the HTTP parameters,
    * performs the basic db operations (FIND, INSERT, UPDATE, DELETE)
    * and then serialize the response in an XML format.
    * XmlSerializer uses a PEAR xml parser to generate an xml response.
    * this takes a php array and generates an xml according to the following rules:
    * - the root tag name is called "response"
    * - if the current value is a hash, generate a tagname with the key value, recurse inside
    * - if the current value is an array, generated tags with the default value "row"
    * for example, we have the following array:
    * $arr = array(
    *      "data" => array(
    *           array("id_pol" => 1, "name_pol" => "name 1"),
    *           array("id_pol" => 2, "name_pol" => "name 2")
    *      "metadata" => array(
    *           "pageNum" => 1,
    *           "totalRows" => 345
    * we will get an xml of the following form
    * <?xml version="1.0" encoding="ISO-8859-1"?>
    * <response>
    *   <data>
    *     <row>
    *       <id_pol>1</id_pol>
    *       <name_pol>name 1</name_pol>
    *     </row>
    *     <row>
    *       <id_pol>2</id_pol>
    *       <name_pol>name 2</name_pol>
    *     </row>
    *   </data>
    *   <metadata>
    *     <totalRows>345</totalRows>
    *     <pageNum>1</pageNum>
    *   </metadata>
    * </response>
    * Please notice that the generated server side code does not have any
    * specific authentication mechanism in place.
    * The filter field. This is the only field that we will do filtering after.
    $filter_field = "subscriber_id";
    * we need to escape the value, so we need to know what it is
    * possible values: text, long, int, double, date, defined
    $filter_type = "text";
    * constructs and executes a sql select query against the selected database
    * can take the following parameters:
    * $_REQUEST["orderField"] - the field by which we do the ordering. MUST appear inside $fields.
    * $_REQUEST["orderValue"] - ASC or DESC. If neither, the default value is ASC
    * $_REQUEST["filter"] - the filter value
    * $_REQUEST["pageNum"] - the page index
    * $_REQUEST["pageSize"] - the page size (number of rows to return)
    * if neither pageNum and pageSize appear, we do a full select, no limit
    * returns : an array of the form
    * array (
    *           data => array(
    *                array('field1' => "value1", "field2" => "value2")
    *           metadata => array(
    *                "pageNum" => page_index,
    *                "totalRows" => number_of_rows
    function findAll() {
         global $conn, $filter_field, $filter_type;
          * the list of fields in the table. We need this to check that the sent value for the ordering is indeed correct.
         $fields = array('id','subscriber_id','lastName','firstName','birthdate','gender');
         $where = "";
         if (@$_REQUEST['filter'] != "") {
              $where = "WHERE " . $filter_field . " LIKE " . GetSQLValueStringForSelect(@$_REQUEST["filter"], $filter_type);     
         $order = "";
         if (@$_REQUEST["orderField"] != "" && in_array(@$_REQUEST["orderField"], $fields)) {
              $order = "ORDER BY " . @$_REQUEST["orderField"] . " " . (in_array(@$_REQUEST["orderDirection"], array("ASC", "DESC")) ? @$_REQUEST["orderDirection"] : "ASC");
         //calculate the number of rows in this table
         $rscount = mysql_query("SELECT count(*) AS cnt FROM `modelName` $where");
         $row_rscount = mysql_fetch_assoc($rscount);
         $totalrows = (int) $row_rscount["cnt"];
         //get the page number, and the page size
         $pageNum = (int)@$_REQUEST["pageNum"];
         $pageSize = (int)@$_REQUEST["pageSize"];
         //calculate the start row for the limit clause
         $start = $pageNum * $pageSize;
         //construct the query, using the where and order condition
         $query_recordset = "SELECT id,subscriber_id,lastName,firstName,birthdate,gender FROM `modelName` $where $order";
         //if we use pagination, add the limit clause
         if ($pageNum >= 0 && $pageSize > 0) {     
              $query_recordset = sprintf("%s LIMIT %d, %d", $query_recordset, $start, $pageSize);
         $recordset = mysql_query($query_recordset, $conn);
         //if we have rows in the table, loop through them and fill the array
         $toret = array();
         while ($row_recordset = mysql_fetch_assoc($recordset)) {
              array_push($toret, $row_recordset);
         //create the standard response structure
         $toret = array(
              "data" => $toret,
              "metadata" => array (
                   "totalRows" => $totalrows,
                   "pageNum" => $pageNum
         return $toret;
    * constructs and executes a sql count query against the selected database
    * can take the following parameters:
    * $_REQUEST["filter"] - the filter value
    * returns : an array of the form
    * array (
    *           data => number_of_rows,
    *           metadata => array()
    function rowCount() {
         global $conn, $filter_field, $filter_type;
         $where = "";
         if (@$_REQUEST['filter'] != "") {
              $where = "WHERE " . $filter_field . " LIKE " . GetSQLValueStringForSelect(@$_REQUEST["filter"], $filter_type);     
         //calculate the number of rows in this table
         $rscount = mysql_query("SELECT count(*) AS cnt FROM `modelName` $where");
         $row_rscount = mysql_fetch_assoc($rscount);
         $totalrows = (int) $row_rscount["cnt"];
         //create the standard response structure
         $toret = array(
              "data" => $totalrows,
              "metadata" => array()
         return $toret;

    Hi there,
    I have a php script that accesses a mySQL database and it was generated out of the Flex Builder wizard automatically. The script works great and there are no problems with it. It allows me to perform CRUD on a table by calling it from my Flex app. and it retrieves all the data and puts it into a nice MXML format.
    My question, currently when I call "findAll" to retrieve all the data in the table, well, it retrieves ALL the rows in the table. That's fine, but my table is starting to grow really large with thousands of rows.
    I want to modify this script so that I can pass a variable into it from Flex so that it only retrieves the rows that match the "$subscriber_id" variable that I pass. In this way the results are not the entire table's data, only the rows that match 'subscriber_id'.
    I know how to pass a variable from Flex into php and the code on the php side to pick it up would look like this:
    $subscriberID = $_POST['subscriberID'];
    Can anyone shed light as to the proper code modification in "findAll" which will take my $subscriberID variable and compare it to the 'subscriber_id' field and then only return those rows that match? I think it has something to do with lines 98 to 101.
    Any help is appreciated.
    <?php
    require_once(dirname(__FILE__) . "/2257safeDBconn.php");
    require_once(dirname(__FILE__) . "/functions.inc.php");
    require_once(dirname(__FILE__) . "/XmlSerializer.class.php");
    * This is the main PHP file that process the HTTP parameters,
    * performs the basic db operations (FIND, INSERT, UPDATE, DELETE)
    * and then serialize the response in an XML format.
    * XmlSerializer uses a PEAR xml parser to generate an xml response.
    * this takes a php array and generates an xml according to the following rules:
    * - the root tag name is called "response"
    * - if the current value is a hash, generate a tagname with the key value, recurse inside
    * - if the current value is an array, generated tags with the default value "row"
    * for example, we have the following array:
    * $arr = array(
    *      "data" => array(
    *           array("id_pol" => 1, "name_pol" => "name 1"),
    *           array("id_pol" => 2, "name_pol" => "name 2")
    *      "metadata" => array(
    *           "pageNum" => 1,
    *           "totalRows" => 345
    * we will get an xml of the following form
    * <?xml version="1.0" encoding="ISO-8859-1"?>
    * <response>
    *   <data>
    *     <row>
    *       <id_pol>1</id_pol>
    *       <name_pol>name 1</name_pol>
    *     </row>
    *     <row>
    *       <id_pol>2</id_pol>
    *       <name_pol>name 2</name_pol>
    *     </row>
    *   </data>
    *   <metadata>
    *     <totalRows>345</totalRows>
    *     <pageNum>1</pageNum>
    *   </metadata>
    * </response>
    * Please notice that the generated server side code does not have any
    * specific authentication mechanism in place.
    * The filter field. This is the only field that we will do filtering after.
    $filter_field = "subscriber_id";
    * we need to escape the value, so we need to know what it is
    * possible values: text, long, int, double, date, defined
    $filter_type = "text";
    * constructs and executes a sql select query against the selected database
    * can take the following parameters:
    * $_REQUEST["orderField"] - the field by which we do the ordering. MUST appear inside $fields.
    * $_REQUEST["orderValue"] - ASC or DESC. If neither, the default value is ASC
    * $_REQUEST["filter"] - the filter value
    * $_REQUEST["pageNum"] - the page index
    * $_REQUEST["pageSize"] - the page size (number of rows to return)
    * if neither pageNum and pageSize appear, we do a full select, no limit
    * returns : an array of the form
    * array (
    *           data => array(
    *                array('field1' => "value1", "field2" => "value2")
    *           metadata => array(
    *                "pageNum" => page_index,
    *                "totalRows" => number_of_rows
    function findAll() {
         global $conn, $filter_field, $filter_type;
          * the list of fields in the table. We need this to check that the sent value for the ordering is indeed correct.
         $fields = array('id','subscriber_id','lastName','firstName','birthdate','gender');
         $where = "";
         if (@$_REQUEST['filter'] != "") {
              $where = "WHERE " . $filter_field . " LIKE " . GetSQLValueStringForSelect(@$_REQUEST["filter"], $filter_type);     
         $order = "";
         if (@$_REQUEST["orderField"] != "" && in_array(@$_REQUEST["orderField"], $fields)) {
              $order = "ORDER BY " . @$_REQUEST["orderField"] . " " . (in_array(@$_REQUEST["orderDirection"], array("ASC", "DESC")) ? @$_REQUEST["orderDirection"] : "ASC");
         //calculate the number of rows in this table
         $rscount = mysql_query("SELECT count(*) AS cnt FROM `modelName` $where");
         $row_rscount = mysql_fetch_assoc($rscount);
         $totalrows = (int) $row_rscount["cnt"];
         //get the page number, and the page size
         $pageNum = (int)@$_REQUEST["pageNum"];
         $pageSize = (int)@$_REQUEST["pageSize"];
         //calculate the start row for the limit clause
         $start = $pageNum * $pageSize;
         //construct the query, using the where and order condition
         $query_recordset = "SELECT id,subscriber_id,lastName,firstName,birthdate,gender FROM `modelName` $where $order";
         //if we use pagination, add the limit clause
         if ($pageNum >= 0 && $pageSize > 0) {     
              $query_recordset = sprintf("%s LIMIT %d, %d", $query_recordset, $start, $pageSize);
         $recordset = mysql_query($query_recordset, $conn);
         //if we have rows in the table, loop through them and fill the array
         $toret = array();
         while ($row_recordset = mysql_fetch_assoc($recordset)) {
              array_push($toret, $row_recordset);
         //create the standard response structure
         $toret = array(
              "data" => $toret,
              "metadata" => array (
                   "totalRows" => $totalrows,
                   "pageNum" => $pageNum
         return $toret;
    * constructs and executes a sql count query against the selected database
    * can take the following parameters:
    * $_REQUEST["filter"] - the filter value
    * returns : an array of the form
    * array (
    *           data => number_of_rows,
    *           metadata => array()
    function rowCount() {
         global $conn, $filter_field, $filter_type;
         $where = "";
         if (@$_REQUEST['filter'] != "") {
              $where = "WHERE " . $filter_field . " LIKE " . GetSQLValueStringForSelect(@$_REQUEST["filter"], $filter_type);     
         //calculate the number of rows in this table
         $rscount = mysql_query("SELECT count(*) AS cnt FROM `modelName` $where");
         $row_rscount = mysql_fetch_assoc($rscount);
         $totalrows = (int) $row_rscount["cnt"];
         //create the standard response structure
         $toret = array(
              "data" => $totalrows,
              "metadata" => array()
         return $toret;

  • How can I change this script so it doesn't load into a new window?

    I have this script on an invisible button on a banner ad, but the client doesn't want the linked page to open in a new window, but rather load over the page in same window. How can I change the script to accomplish this, thanks!
    link_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
    function mouseDownHandler(event:MouseEvent):void {
        navigateToURL(new URLRequest("http://www.sdesignsstore.com/store.html"));

    Try...
    navigateToURL(new URLRequest("http://www.sdesignsstore.com/store.html"), "_self");

Maybe you are looking for