Associative array comparison and INSERT upon IF condition

Hi Guys,
I have written this pl sql code to identify non existing sellers and insert their sales channel information into the dimension table (dimensional table update).
Somehow,......nothing is inserted and this script runs for 12 hours+ without any result. the sql autotrace shows no result and the explain plan (button on sql developer throws upon clicking "missing keyword". I have no
information what is going on/wrong. Does anyone spot an error?
UNDEFINE DimSales;
UNDEFINE FactTable;
DEFINE DimSales = 'testsales';
DEFINE FactTable = 'testfact';
DECLARE
v_SellerNo VarChar(9);
v_error_code T_ERRORS.v_error_code%TYPE;
v_error_message T_ERRORS.v_error_message%TYPE;
TYPE assoc_array_str_type1 IS TABLE OF VARCHAR2(32) INDEX BY PLS_INTEGER;
     v1 assoc_array_str_type1;
TYPE assoc_array_str_type2 IS TABLE OF VARCHAR2(32) INDEX BY PLS_INTEGER;
     v2 assoc_array_str_type2;
BEGIN
--Collect all distinct SellerNo into associative array (hash table)
select distinct SellerNo bulk collect into v1 from &FactTable;
select distinct seller_id bulk collect into v2 from &DimSales;
v_SellerNo := v1.first;
loop
exit when v1 is null;
--1 Check if v_SellerNo already exists in DIM_Sales (if NOT/FALSE, its a new seller and we can insert all records for that seller
if (v2.exists(v_SellerNo)=false) THEN
INSERT INTO &DimSales (K_Sales,REG,BVL,DS, VS,RS,GS,VK)
(SELECT DISTINCT trim(leading '0' from RS||GS) ,REG BVL,DS,VS,RS,GS,VK from &FactTable where SellerNo =v_SellerNo);
--ELSE
end if;
v_SellerNo := v1.next(v_SellerNo);
end loop;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
--v_error_code := SQLCODE
--v_error_message := SQLERRM
--INSERT INTO t_errors VALUES ( v_error_code, v_error_message);
END;
---------------------------------------------------------------

Distinct clause requires a sort. Sorts can be very expensive.
Bulk collects that are not constrained in fetch size, can potentially fetch millions of rows - requiring that data to be wholly read into server memory. I have seen how this can degrade performance so badly that the kernel reboots the server.
Using PL/SQL loops to process and insert/update/delete data is often problematic due to its row-by-row approach - also called slow-by-slow approach. It is far more scalable letting SQL do the "loop" processing, by using joins, sub-selects and so on.
Where the conditional processing is too complex for SQL to handle, then PL/SQL is obviously an alternative to use. Ideally one should process data sets as oppose to rows in PL//SQL. Reduce context switching by using bulk fetches and bulk binds.
But PL/SQL cannot execute in parallel as the SQL it fires off can. If after all the optimisation, the PL/SQL process still needs to hit a million rows to process, it will be slow irrespective of how optimal that PL/SQL approach and design - simply because of the number of rows and the processing overheads per row.
In that case, the PL/SQL code itself need to be parallelised. There are a number of ways to approach this problem - the typical one is to create unique and distinct ranges of rows to process, spawn multiple P/SQL processes, and provide each with a unique range of rows to process. In parallel.
So you need to look close at what you are trying to achieve, what the workloads are, and how to effectively decrease the workloads and increase the processing time of a workload.
For example - finding distinct column values. You can pay for that workload when wanting that distinct list. And each time afterward repeat that workload when wanting that distinct list. Or you can pay for that workload up-front with the DML that creates/updates those values - and use (for example) a materialised view to maintain a ready to use distinct list of values.
Same workload in essence - but paying once for it and up-front as oppose to each time you execute your code that needs to dynamically build that distinct list.
Kent Crotty did tests and showed stunning performance improvements with bulk collect and forall, up to 30x faster:Bulk processing is not a magical silver bullet. It is a tool. And when correctly use, the tool does exactly what it was designed to do.
The problem is using a hammer to drive in screws - instead of a screwdriver. There's nothing "stunning" about using a screwdriver. It is all about using the correct tool.
If the goal of the swap daemon is to free up "idle" chunks of memory, and try to use that memory for things like file cache instead, what does that have to do with bulk processing?The swap daemon reads virtual memory pages from swap space into memory, and writes virtual pages from memory to swap space.
What does it have to do with bulk processing? A bulk fetch reads data from the SGA (buffer cache) into the PGA (private process memory space). The larget the fetch, the more memory is required. If for example 50% of server memory is required for a bulk collection that is 2GB in size, then that will force in-use pages from memory to swap space.. only to be swapped back again as it is needed, thereby forcing other in-use pages to swap. The swap daemon will consume almost all the CPU time swapping hot pages continually in and out of memory.

Similar Messages

  • How to use Associative Array in sql query?

    Hello,
    I have a problem on using Associative Array variable on query; and my query is similar to the one below;
    TYPE OTHERGENERICS IS TABLE OF NUMBER(10) INDEX BY BINARY_INTEGER;
    othersGenerics OTHERGENERICS;
    CURSOR cursor_othersGenerics IS
    select master.GENERICCODEID
    from ASMTRG_ARTICLEMASTER master
    join ASMTRG_ARTICLEMAP map on MAP.ARTICLECODEID = MASTER.ID
    group by MASTER.GENERICCODEID
    minus
    select FGG.GENERICCODEID
    from asmtrg_icfocusgroup fg
    join asmtrg_icfocusgrpchannel fgc on FGC.GROUPID = FG.ID and fgc.isactive=1
    join asmtrg_icfocusgengroup fgg on FGG.GROUPID = FG.ID and FGg.ISACTIVE=1
    where fgc.channelid=1 and fg.isactive = 1
    group by FGG.GENERICCODEID;
    BEGIN
    OPEN cursor_othersGenerics;
    FETCH cursor_othersGenerics BULK COLLECT INTO othersGenerics;
    CLOSE cursor_othersGenerics;
    SELECT icfrd.*,
    CASE
    WHEN EXISTS(select ta.genericcodeid from <???XXX???> ta where ta.genericcodeid = icfgrp.genericcodeid) THEN -1
    ELSE icfrd.icfgroupid
    END CLASSIFICATION
    FROM ASMTRGVIW_ICFOCUSREPORTDATA icfrd
    LEFT JOIN ASMTRG_ICFOCUSGROUP icfgrp on icfrd.ICFGROUPID = icfgrp.ID
    WHERE (channelId IS NULL OR icfrd.CHANNELID = channelId)
    AND (asmCodeId IS NULL OR icfrd.ASMCODEID = asmCodeId)
    AND (yearId IS NULL OR icfrd.YEARID = yearId)
    AND (monthId IS NULL OR icfrd.MONTHID = monthId)
    END;
    By the way this is a part of my function.
    The "othersGenerics" is my associative array variable and <???XXX???> is the place where I need to use my "othersGenerics" array to check. So far I've tried
    "select ta.genericcodeid from table(cast(otherGenerics as OTHERGENERICS)) ta where ta.genericcodeid = icfgrp.genericcodeid",
    "select ta.genericcodeid from table(otherGenerics) ta where ta.genericcodeid = icfgrp.genericcodeid",
    "select ta.genericcodeid from otherGenerics ta where ta.genericcodeid = icfgrp.genericcodeid"
    and these are not working.
    What is your suggestions?

    Your type will have to be created as an independent object in your schema. So CREATE TYPE cannot be in your function declaration, it has to be outside it. (And then the line inside your declaration that defines the type will have to be removed.)
    But now I can see that you use this array as a kind of "temporary lookup table" - you populate the array and then use it for lookup in your select statement. An alternative way of doing this could be like this completely without arrays:
    with othergenerics as (
      select master.GENERICCODEID
      from ASMTRG_ARTICLEMASTER master
      join ASMTRG_ARTICLEMAP map on MAP.ARTICLECODEID = MASTER.ID
      group by MASTER.GENERICCODEID
      minus
      select FGG.GENERICCODEID
      from asmtrg_icfocusgroup fg
      join asmtrg_icfocusgrpchannel fgc on FGC.GROUPID = FG.ID and fgc.isactive=1
      join asmtrg_icfocusgengroup fgg on FGG.GROUPID = FG.ID and FGg.ISACTIVE=1
      where fgc.channelid=1 and fg.isactive = 1
      group by FGG.GENERICCODEID
    SELECT icfrd.*,
    CASE
    WHEN EXISTS(select ta.genericcodeid from othergenerics ta where ta.genericcodeid = icfgrp.genericcodeid) THEN -1
    ELSE icfrd.icfgroupid
    END CLASSIFICATION
    FROM ASMTRGVIW_ICFOCUSREPORTDATA icfrd
    LEFT JOIN ASMTRG_ICFOCUSGROUP icfgrp on icfrd.ICFGROUPID = icfgrp.ID
    WHERE (channelId IS NULL OR icfrd.CHANNELID = channelId)
    AND (asmCodeId IS NULL OR icfrd.ASMCODEID = asmCodeId)
    AND (yearId IS NULL OR icfrd.YEARID = yearId)
    AND (monthId IS NULL OR icfrd.MONTHID = monthId)
    ...The with clause (subquery factoring) you can think of as a kind of temp table called othergenerics created "on-the-fly".
    The optimizer may decide to actually create a temp table for you and use in the lookup, or it may decide to rewrite the query into suitable joins or nested loops or hashing - whatever the optimizer decides will be the optimal way of doing things :-)
    So unless you use your array other places in your function, I would recommend dropping the array completely, skip populating an array, and instead use a with clause for your temporary lookup.

  • User exit for Price Conditions in VA02 (update,insert or delete conditions)

    Hi folks. I would like to know if anyone of you has already worked with transaction VA02...I need a user exit, which could be capable to: Erase, Update and Insert new Price Conditions.
    Scenario: The user will not enter into the Price Conditions Tab. He will only make some modifications to the document via VA02 and when he saves the document, then the user exit should update, erase or include new conditions based on some logic that the user exit will implement. does anyone know a user exit for this particular case, please !
    Thanks in advance.

    HI,
    Check this.
    V60F0001                                SD Billing plan (customer enhancement) diff. to billing plan 
    V46H0001                                SD Customer functions for resource-related billing           
    V45W0001                                SD Service Management: Forward Contract Data to Item         
    V45S0004                                Effectivity type in sales order                              
    V45S0003                                MRP-relevance for incomplete configuration                   
    V45S0001                                Update sales document from configuration                     
    V45P0001                                SD customer function for cross-company code sales            
    V45L0001                                SD component supplier processing (customer enhancements)     
    V45E0002                                Data transfer in procurement elements (PRreq., assembly)     
    V45E0001                                Update the purchase order from the sales order               
    V45A0004                                Copy packing proposal                                        
    V45A0003                                Collector for customer function modulpool MV45A              
    V45A0002                                Predefine sold-to party in sales document                    
    V45A0001                                Determine alternative materials for product selection        
    SDTRM001                                Reschedule schedule lines without a new ATP check                                                                               
    Business Add-in                                                                               
    BADI_SD_SCH_GETWAGFZ                    Scheduling Agreement: Read WAGFZ from S073                   
    BADI_SD_V46H0001                        SD Customer functions for resource-related billing           
    Regards
    Rajendra

  • Associative array two variable comparison :update table error

    Hi,
    i am using associative array to update the version number of table
    -i declare two associative array to compare the column from two table (temp,main tables)values in loop
    -if id's of both variable(for temp and main table) are equal and column of either of table not matching then it should update the version no of temp table
    -if id's not equal i.e record only exists temp table then update null version number annd increment it by 1
    -following is the structure and procedure --it shows the matching and non matching records but for the update statement it not giving expected output i.e it updates all records irrespective of the condition provided
    -i tried to put condition in update as well as in the  if statement but it updates all record
    ....suggestion and help highly appreciate. thankx in advance !!!
    /*--table structure and data--*/
    CREATE TABLE "TEMP_TABLE"
       ( "ID" NUMBER NOT NULL ENABLE,
      "COL1" VARCHAR2(20 BYTE),
      "COL2" VARCHAR2(20 BYTE),
      "VERSION" NUMBER
       INSERT INTO TEMP_TABLE VALUES (101,'A','B',NULL);
       INSERT INTO TEMP_TABLE VALUES (102,'x','y',NULL);
       INSERT INTO TEMP_TABLE VALUES (103,'r','t',NULL);
       CREATE TABLE "MAIN_TABLE"
       ( "ID" NUMBER NOT NULL ENABLE,
      "COL1" VARCHAR2(20 BYTE),
      "COL2" VARCHAR2(20 BYTE),
      "VERSION" NUMBER
       INSERT INTO MAIN_TABLE VALUES (101,'A','B',1);
    /*------update version procedure----------*/
    DECLARE
      TYPE T_tmp_table IS TABLE OF tmp_table %ROWTYPE INDEX BY PLS_INTEGER;
      TYPE T_main_table IS TABLE OF main_table%ROWTYPE INDEX BY PLS_INTEGER;
      l_tmp_table T_tmp_table;
      l_main_table T_main_table;
      BEGIN
        SELECT * BULK COLLECT INTO l_tmp_table FROM tmp_table;
        SELECT * BULK COLLECT INTO l_main_table FROM main_table;
        FOR i IN 1 .. l_tmp_table.count
        LOOP
          FOR j IN 1 .. l_main_table.count
         LOOP
      if(l_tmp_table(i).ID = l_main_table(j).ID AND l_tmp_table(i).VERSION IS NULL) then     
      ---this first if loop updates temp table version irrespective of l_tmp_table.ID=l_main_table.ID orl_tmp_table. ID<>l_main_table.ID  .it display proper matching and non-matching records.
       dbms_output.put_line('matching ids from tmp and main are :'||l_tmp_table(i).ID||'  '||l_main_table(j).ID);
       UPDATE tmp_table SET VERSION = l_tmp_table(i).version +1;
       --where l_tmp_table(i).ID = l_main_table(j).ID     --
       end if;
      if (l_tmp_table(i).ID <> l_main_table(j).ID) then
       dbms_output.put_line('non matching ids from tmp and main are :'||l_tmp_table(i).ID||'  '||l_main_table(j).ID);
       UPDATE tmp_table SET VERSION = l_tmp_table(i).version +1;
       --where l_tmp_table(i).ID <> l_main_table(j).ID    
        end if;
              END LOOP;
              END LOOP;
        EXCEPTION
        WHEN OTHERS THEN
        DBMS_OUTPUT.PUT_LINE('OTHER');
    END;

    Hello user8937641
    I think there is a problem with the logic of your SQL-Code.
    But maybe in this formatted structure you can see where your problem is. -> I can not say it because I do not know what is the requirement.
    I hope it helps...
    /*------update version procedure----------*/
    DECLARE
      TYPE T_tmp_table IS TABLE OF tmp_table %ROWTYPE INDEX BY PLS_INTEGER;
      TYPE T_main_table IS TABLE OF main_table%ROWTYPE INDEX BY PLS_INTEGER;
      l_tmp_table T_tmp_table;
      l_main_table T_main_table;
      BEGIN
        SELECT * BULK COLLECT INTO l_tmp_table FROM tmp_table;
        SELECT * BULK COLLECT INTO l_main_table FROM main_table;
        FOR i IN 1 .. l_tmp_table.count
        LOOP
          FOR j IN 1 .. l_main_table.count
          LOOP
            IF     l_tmp_table(i).ID = l_main_table(j).ID
               AND l_tmp_table(i).VERSION IS NULL
             THEN
                 ---this first if loop updates temp table version irrespective of l_tmp_table.ID=l_main_table.ID orl_tmp_table. ID<>l_main_table.ID  .it display proper matching and non-matching records.
                 dbms_output.put_line('matching ids from tmp and main are :'||l_tmp_table(i).ID||'  '||l_main_table(j).ID);
                 UPDATE tmp_table
                    SET version = l_tmp_table(i).version +1;
                  WHERE id = l_tmp_table(i).ID
            END IF;
            IF l_tmp_table(i).ID <> l_main_table(j).ID
             THEN
               dbms_output.put_line('non matching ids from tmp and main are :'||l_tmp_table(i).ID||'  '||l_main_table(j).ID);
               -- Maybe you do not need this update:
               UPDATE tmp_table
                  SET version = l_tmp_table(i).version +1;
                WHERE id =  l_tmp_table(i).ID
            END IF;
            COMMIT;
           END LOOP;
        END LOOP;
      EXCEPTION WHEN OTHERS THEN
        DBMS_OUTPUT.PUT_LINE('Error at Executing the PLSQL-Block - ' || SQLERRM);
    END;

  • Inserting a associative array into a table

    Hi,
    I am working on a process where I want to store the temporary results in an associative array. At the end of the process I plan to write the contents of the array into a table that has the same structure. (the array is defined as a %rowtype of the table)
    Is it possible to execute ONE sql statement that transfers the array into the table? I am on 10g (10.2.0.4.0)
    Here's what I have now:
    declare
      type t_emp is table of emp%rowtype index by pls_integer;
      v_emp t_emp;
    begin
      -- a process that fills v_emp with lots of data
      for i in v_emp.first .. v_emp.last
      loop
        insert into emp values v_emp(i);
      end loop;  
    end;But it would be better if the loop could be replaced by sql one statement that inserts all of v_emp into emp. Is that possible?
    Thanks!
    PS: I'm not sure whether it's a good idea to use this approach... building a table in memory and inserting it into the database at the end of the process. Maybe it's better to insert every record directly into the table... but in any case I'm curious to see if it is possible in theory :)
    Edited: Added version info

    True, SQL cannot access the PL/SQL type.
    So you can not do something like this:
    insert into emp
    select * from table(v_emp)That is not possible.
    But FORALL is possible:
    FORALL i in v_emp.first .. v_emp.last
        insert into emp values v_emp(i);FORALL makes just one "round trip" to SQL bulk binding the entire contents of the array.
    It is much more efficient than the normal FOR loop, though it is mostly a PL/SQL optimization - even the FORALL actually inserts the rows "one at the time", it just hands the entire array to the SQL engine in one go.
    If the logic has to be done procedurally, FORALL is efficient.
    If the logic can be changed so arrays can be avoided completely and everything done in a single "insert into ... select ..." statement, that is the most efficient.

  • How do I create a 1d array that takes a single calculation and insert the result into the first row and then the next calculation the next time the loop passes that point and puts the results in thsecond row and so on until the loop is exited.

    The attached file is work inprogress, with some dummy data sp that I can test it out without having to connect to equipment.
    The second tab is the one that I am having the problem with. the output array from the replace element appears to be starting at the index position of 1 rather than 0 but that is ok it is still show that the new data is placed in incrementing element locations. However the main array that I am trying to build that is suppose to take each new calculation and place it in the next index(row) does not ap
    pear to be working or at least I am not getting any indication on the inidcator.
    Basically what I am attempting to do is is gather some pulses from adevice for a minute, place the results for a calculation, so that it displays then do the same again the next minute, but put these result in the next row and so on until the specifiied time has expired and the loop exits. I need to have all results displayed and keep building the array(display until, the end of the test)Eventually I will have to include a min max section that displays the min and max values calculated, but that should be easy with the min max function.Actually I thought this should have been easy but, I gues I can not see the forest through the trees. Can any one help to slear this up for me.
    Attachments:
    regulation_tester_7_loops.vi ‏244 KB

    I didn't really have time to dig in and understand your program in depth,
    but I have a few tips for you that might things a bit easier:
    - You use local variables excessively which really complicates things. Try
    not to use them and it will make your life easier.
    - If you flowchart the design (very similar to a dataflow diagram, keep in
    mind!) you want to gather data, calculate a value from that data, store the
    calculation in an array, and loop while the time is in a certain range. So
    theres really not much need for a sequence as long as you get rid of the
    local variables (sequences also complicate things)
    - You loop again if timepassed+1 is still less than some constant. Rather
    than messing with locals it seems so much easier to use a shiftregister (if
    absolutely necessary) or in this case base it upon the number of iterations
    of the loop. In this case it looks like "time passed" is the same thing as
    the number of loop iterations, but I didn't check closely. There's an i
    terminal in your whileloop to read for the number of iterations.
    - After having simplified your design by eliminating unnecessary sequence
    and local variables, you should be able to draw out the labview diagram.
    Don't try to use the "insert into array" vis since theres no need. Each
    iteration of your loop calculates a number which goes into the next position
    of the array right? Pass your result outside the loop, and enable indexing
    on the terminal so Labview automatically generates the array for you. If
    your calculation is a function of previous data, then use a shift register
    to keep previous values around.
    I wish you luck. Post again if you have any questions. Without a more
    detailed understanding of your task at hand it's kind of hard to post actual
    code suggestions for you.
    -joey
    "nelsons" wrote in message
    news:[email protected]...
    > how do I create a 1d array that takes a single calculation and insert
    > the result into the first row and then the next calculation the next
    > time the loop passes that point and puts the results in thsecond row
    > and so on until the loop is exited.
    >
    > The attached file is work inprogress, with some dummy data sp that I
    > can test it out without having to connect to equipment.
    > The second tab is the one that I am having the problem with. the
    > output array from the replace element appears to be starting at the
    > index position of 1 rather than 0 but that is ok it is still show that
    > the new data is placed in incrementing element locations. However the
    > main array that I am trying to build that is suppose to take each new
    > calculation and place it in the next index(row) does not appear to be
    > working or at least I am not getting any indication on the inidcator.
    >
    > Basically what I am attempting to do is is gather some pulses from
    > adevice for a minute, place the results for a calculation, so that it
    > displays then do the same again the next minute, but put these result
    > in the next row and so on until the specifiied time has expired and
    > the loop exits. I need to have all results displayed and keep building
    > the array(display until, the end of the test)Eventually I will have to
    > include a min max section that displays the min and max values
    > calculated, but that should be easy with the min max function.Actually
    > I thought this should have been easy but, I gues I can not see the
    > forest through the trees. Can any one help to slear this up for me.

  • Associative Array and Blob

    I’m currently working on a system that allows the users to upload an Excel spreadsheet (.xls) in the system. The upload page is a PL/SQL cartridge. Then I’ve written a Java servlet (using Oracle Clean Content) to convert the XLS into a CSV and store it back in the database. (it is stored in the “uploaded_files” table as a blob). I’m trying to create another procedure to read the contents of the blob and display a preview of the data on the screen (using an html table (will be done using cartridge)). After the preview, the user can choose to submit the data into the database into the “detail_records” table or simply discard everything.
    I've been trying to use an associative array to grab all the data from the blob but I’m getting confused about how to implement it in my situation.
    Can someone provide any examples of this nature?
    Any help is greatly appreciated.

    I decided to create a "record" type with all the columns from my excel spreadsheet. Then I will create a table type of records
    I am doing something like this:
    declare
    type s_record is record
                            (l_name varchar2(100),
                             f_code varchar2(4) ,
                             l_code varchar2(6),
                             d_date varchar2(5),
                             d_type varchar2(5),
                             price number,
                             volume number,
                             tax number,
                             amount_paid number
    type s_data_tab is table of s_record index by binary_integer;
    v_s_data s_data_tab;
    v_indx binary_integer :=0;
    begin
    end; I am getting confused about parsing an entire row of values separated by commas into a row in the temporary table created above.
    I know I need a loop, but from what I understand, the way to populate data needs to be something like this, for example:
    for v_indx in 0..data_size loop
       v_s_data(v_indx).l_name:= 'Company A';
       v_s_data(v_indx).f_code := '2700';
    end loop; But I'm not sure how this approach should be used to parse an entire row at once.
    Any help appreciated.

  • Associative Array, Drp-DwnList and Accesing "SubArray" Values ?

    Based on the users selection on a drop-down box, I need to be able to access different elements associated with that selection (elements of a subArray, so to speak)
    I am not certain how to go about creating arrays in LiveCycle. I've tried a number of things including:
    putting the array name in the "variables tab" of the Form Properties, with a value of [] -- that doesn't seen to be the way to go, so I removed it
    using rounded brackets ( instead of square [
    declaring the arrays differently using var codeDetail = new Array(array,Values,Here);
    putting the code in a fragment--not sure how to reference the values,
    I have the following code residing in the "Exit" event for the drop-down box:
    var codeDetail = [];   //an associative array
    codeDetail["99999"] = ["None",null,null,null,null,null,null,null];
    codeDetail["78400"] = ["Trampoline",40,45,50,60,10,20,40];
    codeDetail["78020"] = ["Horse(s)",10,12,15,20,5,10, 20];
    codeDetail["78401"] = ["Horse Boarding (each)",19,23,28,39,17,24,48];
    codeDetail["78010"] = ["Watercraft - Outboard over 50 HP (each)",13,18,20,24,17,24,48];
    codeDetail["78011"] = ["Watercraft - Inboard or I/O over 50 HP (each)",30,35,40,50,17,24,48];
    codeDetail["78050"] = ["Recreational Vehicle: ATV (each)",40,51,61,84,9,11,22];
    codeDetail["78053"] = ["Recreational Vehicle: Snowmobiles (each)",36,46,55,76,9,11,22];
    codeDetail["78052"] = ["Recreational Vehicle: Golf Carts (each)",29,37,44,61,9,11,22];
    codeDetail["73000"] = ["Personal Injury",14,19,22,31,null,null,null];
    codeDetail["78030"] = ["Office, School or Studio",10,11,13,19,9,17,34];
    codeDetail["78060"] = ["Retail Sales",36,46,56,77,3,4,8];
    codeDetail["78061"] = ["Incidental Business Pursuits",36,46,56,77,3,4,8];
    codeDetail["78070"] = ["Additional Insured: Premises Only",8,10,12,17,null,null,null];
    codeDetail["78090"] = ["Additional Insured - Personal Libility",31,40,50,69,9,17,34];
    codeDetail["78040"] = ["Seasonal Residence Occupied by Insured",10,11,13,19,3,4,8];
    codeDetail["78041"] = ["Rented to Others: One Family",23,28,34,47,9,17,34];
    codeDetail["78042"] = ["Rented to Others: Two Family",29,35,43,61,11,23,45];
    codeDetail["78043"] = ["Rented to Others: Three Family",43,55,66,90,17,33,60];
    codeDetail["78044"] = ["Rented to Others: Four Family",67,83,100,139,24,50,80];
    codeDetail["76000"] = ["Waterbed Liability",10,12,13,19,null,null,null];
    codeDetail["78300"] = ["Non-Owned and Hired Auto Liability",56,69,80,92,17,24,48];
    itemChosen = [];  //a subArray
    var i = this.rawValue
    itemChosen = [codeDetail[i]];    //  values based on user's selection
    The goal is to now be able to use the itemChosen values and simply refer to them:
    this.rawValue = itemChosen[i]   or   this.rawValue = itemChosen[someField.rawValue]
    So if this drop-down box has a rawValue = "78400" then itemChosen[2] would have a value of 45 (see above).
    Am I anywhere close?
    Also, a couple of other questions:
    When using a variable.value or a field.rawValue as the index value for itemChosen[i]
    do you include "" or .value or .rawValue in the index brackets?
    Do you ever use .value when referencing an array as in: itemChosen[i].value
    How do I make sure arrays and variables created like this are global, or not? I tried with and without the "var" declaration
    Thanks much!
    Stephen

    I've just been playing with a similar thing.
    My code is based on a sample from WindJack Solutions, which is available here:
    http://www.acrobatusers.com/tutorials/2007/js_list_combo_livecycle
    Check this thread for a good sample from Bruce, he took my code and jacked it up considerably.
    http://forums.adobe.com/message/2203834#2203834
    If you google "multi dimensional javascript arrays" you'll find quite a bit of info too.

  • How to split the blob byte array and insert in oracle

    how to split the blob byte array and insert in oracle
    I am having a string which is of more than lenght 4000 so i am using BLOB datatype as input to get the string.
    need to split the blob in oracle and store in the different column
    The string is of bytearray i need to strore it in each column based on the byte array.

    this will be my input i need to split the above and store it in different columns in a table.
    for spliting say
    Column1 -1 byte
    Column2-3 byte
    Column3-5 byte
    ColumnN-5 byte
    Table will have corresponding data type
    Column1 - number(10,2)
    Column2 - Float
    Column3 - Float
    ColumnN-Float
    here Column2 datatype is float but it will always have 3 byte information.
    where as Column3 datatype is also float but it will always have 5 byte information.
    Say N is Column 120

  • Associative Array our only option?

    Hello,
    I'm having a problem accepting associative arrays as the only option I have for getting data from a stored procedure. I have a good reason for not wanting to use ref cursors as I am using the stored procedure to manipulate data which I in turn would like to pass back to VB through the stored procedure and would rather not have to insert he data into a table just to re-select it for a ref cursor.
    My main concern is that with associative arrays I am expected to define the number of return results before I even generate the data. Also from what I can see I am required to set the data length for each and every item in said array one at a time. All this overhead seems like more work than what I would have to do to utilizer a reference cursor. Is there a right way to do this? I would really like to do the most straight forward way I can without the extra processing.

    Hi,
    Here's a blog post of mine that illustrates using pipelined functions and PL/SQL to return results:
    http://oradim.blogspot.com/2007/10/odpnet-tip-using-pipelined-functions.html
    Not sure if that will be helpful in your case, but perhaps it might be a place to start anyway.
    - Mark

  • Associative Array vs Table Scan

    Still new to PL/SQL, but very keen to learn. I wondered if somebody could advise me whether I should use a collection (such as an associative array) instead of repeating a table scan within a loop for the example below. I need to read from an input table of experiment data and if the EXPERIMENT_ID does not already exist in my EXPERIMENTS table, then add it. Here is the code I have so far. My instinct is that it my code is inefficient. Would it be more efficient to scan the EXPERIMENTS table only once and store the list of IDs in a collection, then scan the collection within the loop?
    -- Create any new Experiment IDs if needed
    open CurExperiments;
    loop
    -- Fetch the explicit cursor
    fetch CurExperiments
    into vExpId, dExpDate;
    exit when CurExperiments%notfound;
    -- Check to see if already exists
    select count(id)
    into iCheckExpExists
    from experiments
    where id = vExpId;
    if iCheckExpExists = 0 then
    -- Experiment ID is not already in table so add a row
    insert into experiments
    (id, experiment_date)
    values(vExpId, dExpDate);
    end if;
    end loop;

    Except that rownum is assigned after the result set
    is computed, so the whole table will have to be
    scanned.really?
    SQL> explain plan for select * from i;
    Explained.
    SQL> select * from table( dbms_xplan.display );
    PLAN_TABLE_OUTPUT
    Plan hash value: 1766854993
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |   910K|  4443K|   630   (3)| 00:00:08 |
    |   1 |  TABLE ACCESS FULL| I    |   910K|  4443K|   630   (3)| 00:00:08 |
    8 rows selected.
    SQL> explain plan for select * from i where rownum=1;
    Explained.
    SQL> select * from table( dbms_xplan.display );
    PLAN_TABLE_OUTPUT
    Plan hash value: 2766403234
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |     1 |     5 |     2   (0)| 00:00:01 |
    |*  1 |  COUNT STOPKEY     |      |       |       |            |          |
    |   2 |   TABLE ACCESS FULL| I    |     1 |     5 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter(ROWNUM=1)
    14 rows selected.

  • Associative array type for each blob column in the table

    i am using the code in given link
    http://www.oracle.com/technology/oramag/oracle/07-jan/o17odp.html
    i chnages that code like this
    CREATE TABLE JOBS
    JOB_ID VARCHAR2(10 BYTE),
    JOB_TITLE VARCHAR2(35 BYTE),
    MIN_SALARY NUMBER(6),
    MAX_SALARY NUMBER(6),
    JOBPIC BLOB
    CREATE OR REPLACE PACKAGE associative_array
    AS
    -- define an associative array type for each column in the jobs table
    TYPE t_job_id IS TABLE OF jobs.job_id%TYPE
    INDEX BY PLS_INTEGER;
    TYPE t_job_title IS TABLE OF jobs.job_title%TYPE
    INDEX BY PLS_INTEGER;
    TYPE t_min_salary IS TABLE OF jobs.min_salary%TYPE
    INDEX BY PLS_INTEGER;
    TYPE t_max_salary IS TABLE OF jobs.max_salary%TYPE
    INDEX BY PLS_INTEGER;
    TYPE t_jobpic IS TABLE OF jobs.jobpic%TYPE
    INDEX BY PLS_INTEGER;
    -- define the procedure that will perform the array insert
    PROCEDURE array_insert (
    p_job_id IN t_job_id,
    p_job_title IN t_job_title,
    p_min_salary IN t_min_salary,
    p_max_salary IN t_max_salary,
    p_jobpic IN t_jobpic
    END associative_array;
    CREATE OR REPLACE package body SHC_OLD.associative_array as
    -- implement the procedure that will perform the array insert
    procedure array_insert (p_job_id in t_job_id,
    p_job_title in t_job_title,
    p_min_salary in t_min_salary,
    p_max_salary in t_max_salary,
    P_JOBPIC IN T_JOBPIC
    ) is
    begin
    forall i in p_job_id.first..p_job_id.last
    insert into jobs (job_id,
    job_title,
    min_salary,
    max_salary,
    JOBPIC
    values (p_job_id(i),
    p_job_title(i),
    p_min_salary(i),
    p_max_salary(i),
    P_JOBPIC(i)
    end array_insert;
    end associative_array;
    this procedure is called from .net. from .net sending blob is posiible or not.if yes how

    Ok, that won't work...you need to generate an image tag and provide the contents of the blob column as the src for the image tag.
    If you look at my blog entry -
    http://jes.blogs.shellprompt.net/2007/05/18/apex-delivering-pages-in-3-seconds-or-less/
    and download that Whitepaper that I talk about you will find an example of how to do what you want to do. Note the majority of that whitepaper is discussing other (quite advanced) topics, but there is a small part of it that shows how to display an image stored as a blob in a table.

  • Associative Array Assignment

    I have an associative array that is built on a record.
    TYPE LKey IS RECORD (
    lock_key locks.lock_key%TYPE,
    category_id_cd locks.category_id_cd%TYPE);
    TYPE LockKeys_t IS TABLE OF LKey
    INDEX BY PLS_INTEGER;
    v_LockKeys_arr LockKeys_t;
    How do I populate the elements of this array one row at a time within my cursor FOR loop? I just want to do something like this:
    SELECT v_lock_key, v_category_id_cd INTO v_LockKeys_arr FROM dual;
    When I try this I get : "expression v_LockKeys_arr in the INTO list is of wrong type."
    Then I will loop through the array and use each element one at a time:
    FOR j IN 1..v_LockKeys_arr.COUNT
    LOOP
    ReleaseLocks( v_LockKeys_arr(j).lock_key||'2:',
    v_Lockkeys_arr(j).category_id_cd,
    i_User, v_release_set );
    END LOOP;
    Thank you in advance for your time.

    DECLARE--CREATE RECORD
    TYPE CUSTOMER_RECORD IS RECORD (CUSTOMER_ACCT_ID NUMBER,
    CUSTOMER_NAME VARCHAR2(2000));
    --CREATE TABLE OF RECORD TYPE
    TYPE CUSTOMER_REC IS TABLE OF
    CUSTOMER_RECORD
    INDEX BY BINARY_INTEGER;
    --INSTANCE OF RECORD
    LREC_CUSTOMER_RECORD CUSTOMER_RECORD;
    --INSTANCE OF TABLE
    LT_CUSTOMER_REC CUSTOMER_REC;
    BEGIN
    --ASSIGN VALUES TO INSTANCE OF RECORD
    LREC_CUSTOMER_RECORD.CUSTOMER_ACCT_ID:=10;
    LREC_CUSTOMER_RECORD.CUSTOMER_NAME:='BHAGAT';
    --INSERT INTO TABLE, VALUES FROM RECORD INSTANCE
    LT_CUSTOMER_REC(1):=LREC_CUSTOMER_RECORD;
    --OUTPUT
    DBMS_OUTPUT.PUT_LINE(LT_CUSTOMER_REC(1).CUSTOMER_ACCT_ID);
    DBMS_OUTPUT.PUT_LINE(LT_CUSTOMER_REC(1).CUSTOMER_NAME);
    END;
    /

  • Associative Array with subsripts(Index) as Varchar2

    Hi All,     
    I m using Oracle Version 10.1.0.2.0 - Production     
    I have the following requirement:     
    The Associative array which holds the value with the subscripts(Index) as database table column.
    Create table Period_master
    Period_code_c Varchar2(10),
    Period_frm_dt Date,
    Period_to_dt Date,
    Year_code_c     Varchar2(10)
    Insert into period_master values ('10',to_date('01/01/2012','dd/mm/rrrr'),to_date('31/01/2012','dd/mm/rrrr'),'2011-2012');
    Insert into period_master Values ('11',to_date('01/02/2012','dd/mm/rrrr'),to_date('29/02/2012','dd/mm/rrrr'),'2011-2012');
    Insert into period_master Values ('12',to_date('01/03/2012','dd/mm/rrrr'),to_date('31/03/2012','dd/mm/rrrr'),'2011-2012');
    Insert into period_master Values ('13',to_date('01/04/2012','dd/mm/rrrr'),to_date('30/04/2012','dd/mm/rrrr'),'2012-2013');
    Insert into period_master Values ('14',to_date('01/05/2012','dd/mm/rrrr'),to_date('31/05/2012','dd/mm/rrrr'),'2012-2013');
    Commit;
    SQL > Select * from Period_Master;
    Period_code --- Period_frm_dt --- Period_to_dt ---- Year_code_c
    10     ---     01/01/2012 ---     31/01/2012     --- 2011-2012
    11     ---     01/02/2012 ---     29/02/2012     --- 2011-2012
    12     ---     01/03/2012 ---     31/03/2012     --- 2011-2012
    13     ---     01/04/2012 ---     30/04/2012     --- 2012-2013
    14     ---     01/05/2012 ---     31/05/2012     --- 2012-2013     
    My Requirement is get the Period_frm_dt,period_end_dt and yearcode based on period_code (which is input parameters from my procedure) by using Collections.
    I have to create one PLSQL table type which having the subscripts(Index) as period_code which is Varchar2 type;
    I have written follwing code ,but it's not giving the desired output:
    Declare
    iv_period Varchar2(10);
    Cursor cur_prd(cp_period Varchar2) is select * from Period_Master Where Period_code_c = cp_period;
    TYPE PRD_REC_TY IS TABLE OF cur_prd%ROWTYPE INDEX BY PLS_INTEGER;
    lv_prd_data prd_rec_ty;
    lv_prd PERIOD_MASTER.period_code_c%TYPE ;
    lv_frm_dt PERIOD_MASTER.Period_frm_dt%TYPE ;
    lv_to_dt PERIOD_MASTER.Period_to_dt%TYPE ;
    lv_yr_code PERIOD_MASTER.Year_code_c%TYPE ;
    Begin
    iv_period := :period;
    Open Cur_prd(iv_period);
    Loop
    Fetch cur_prd BULK COLLECT into lv_prd_data;
    EXIT WHEN cur_prd%NOTFOUND;
    End Loop;
    Close Cur_Prd;
    If lv_prd_data.COUNT > 0 THEN
    For i IN lv_prd_data.FIRST .. lv_prd_data.LAST
    LOOP
    lv_prd := lv_prd_data(i).pERIOD_cODE_C;
    lv_frm_dt := lv_prd_data(i).Period_frm_dt;
    lv_to_dt := lv_prd_data(i).Period_to_dt;
    lv_yr_code := lv_prd_data(i).Year_Code_c;
    Dbms_output.Put_line('For Period code : '||lv_prd||' the Year code is : '||lv_yr_code);
    Dbms_output.Put_line('For Period code : '||lv_prd||' the Period_from_dt is : '||lv_frm_dt);
    Dbms_output.Put_line('For Period code : '||lv_prd||' the Period_to_dt is : '||lv_to_dt);
    END LOOP;
    End if;
    Exception
    When Others Then
    Dbms_output.Put_line('Here Error Found: '||SQLERRM);
    End;
    But My requirement is to get the FRM_DT,TO_DT and YEAR CODE as per the following:
    For Period Code :*11* -- the YearCode is --- *2011-2012*
    For Period Code :*11* -- the From Dt is --- *01/02/2012*
    For Period Code :*11* -- the To Dt is --- *29/02/2012*
    for Period Code : *14* -- the Yearcode is --- *2012-2013*
    For Period Code : *14* -- the From Dt is --- *01/05/2012*
    For Period Code : *14* -- the To Dt is --- *31/05/2012*
    So on...
    Like:
    lv_yr_code := lv_period_data(iv_period).Year_code_c;
    lv_frm_dt := lv_period_data(iv_period).Period_frm_dt;
    lv_to_dt := lv_period_data(iv_period).Period_to_dt;
    Dbms_output.Put_line('For Period code : '||iv_period||' the Year code is : '||lv_yr_code);
    Dbms_output.Put_line('For Period code : '||iv_period||' the Period_from_dt is : '||lv_frm_dt);
    Dbms_output.Put_line('For Period code : '||iv_period||' the Period_to_dt is : '||lv_to_dt);
    How do i resolve the above scenario.Please help me to resove the above scenario.
    Regards,
    Prasanta

    Hi, Pransanta,
    Prasanta wrote:
    ... My Requirement is get the Period_frm_dt,period_end_dt and yearcode based on period_code (which is input parameters from my procedure) by using Collections.Sorry, I don't understand.
    What is the porocedure you mentioned? Do you mean the anonymous block that you posted? If not, post the procedure. How is it related to the anonymous block? E.g., does the anonymous block need to call the procedure?
    I have to create one PLSQL table type which having the subscripts(Index) as period_code which is Varchar2 type;
    I have written follwing code ,but it's not giving the desired output:
    Declare
    iv_period Varchar2(10);Please format your code, and use \ tags to keep the formatting when you post it on this site.
    See the forum FAQ {message:id=9360002}
    Cursor cur_prd(cp_period Varchar2) is select * from Period_Master Where Period_code_c = cp_period;You're only looking for a single given period_code_c.  If you want to get all rows, lose the WHERE clause.  If you want to multiple rows, but not all rows, then use an appropriate WHERE clause.
    TYPE PRD_REC_TY IS TABLE OF cur_prd%ROWTYPE INDEX BY PLS_INTEGER;
    lv_prd_data prd_rec_ty;
    lv_prd PERIOD_MASTER.period_code_c%TYPE ;
    lv_frm_dt PERIOD_MASTER.Period_frm_dt%TYPE ;
    lv_to_dt PERIOD_MASTER.Period_to_dt%TYPE ;
    lv_yr_code PERIOD_MASTER.Year_code_c%TYPE ;
    Begin
    iv_period := :period;Post the code that declares and sets :period.
    Open Cur_prd(iv_period);
    Loop
    Fetch cur_prd BULK COLLECT into lv_prd_data;
    EXIT WHEN cur_prd%NOTFOUND;
    End Loop;
    Close Cur_Prd;
    If lv_prd_data.COUNT > 0 THEN
    For i IN lv_prd_data.FIRST .. lv_prd_data.LAST
    LOOP
    lv_prd := lv_prd_data(i).pERIOD_cODE_C;
    lv_frm_dt := lv_prd_data(i).Period_frm_dt;
    lv_to_dt := lv_prd_data(i).Period_to_dt;
    lv_yr_code := lv_prd_data(i).Year_Code_c;If the block is just supposed to do what it's doing now; then you don't need all these local variables.  It's simpler just to teference lv_prd_data.
    If you're planning to add some other code to the block later, then the local variables could be useful.
    Dbms_output.Put_line('For Period code : '||lv_prd||' the Year code is : '||lv_yr_code);
    Dbms_output.Put_line('For Period code : '||lv_prd||' the Period_from_dt is : '||lv_frm_dt);
    Dbms_output.Put_line('For Period code : '||lv_prd||' the Period_to_dt is : '||lv_to_dt);
    END LOOP;
    End if;
    Exception
    When Others Then
    Dbms_output.Put_line('Here Error Found: '||SQLERRM);Only use an EXCEPTION section when you need to.  The EXCEPTION section above is only hiding some information about the error.
    End;
    But My requirement is to get the FRM_DT,TO_DT and YEAR CODE as per the following:
    For Period Code :*11* -- the YearCode is --- *2011-2012*
    For Period Code :*11* -- the From Dt is --- *01/02/2012*
    For Period Code :*11* -- the To Dt is --- *29/02/2012*
    for Period Code : *14* -- the Yearcode is --- *2012-2013*
    For Period Code : *14* -- the From Dt is --- *01/05/2012*
    For Period Code : *14* -- the To Dt is --- *31/05/2012*
    So on...
    Like:
    lv_yr_code := lv_period_data(iv_period).Year_code_c;
    lv_frm_dt := lv_period_data(iv_period).Period_frm_dt;
    lv_to_dt := lv_period_data(iv_period).Period_to_dt;
    Dbms_output.Put_line('For Period code : '||iv_period||' the Year code is : '||lv_yr_code);
    Dbms_output.Put_line('For Period code : '||iv_period||' the Period_from_dt is : '||lv_frm_dt);
    Dbms_output.Put_line('For Period code : '||iv_period||' the Period_to_dt is : '||lv_to_dt);
    How do i resolve the above scenario.Please help me to resove the above scenario.
    Regards,
    PrasantaIf the problem is that you need to show all period_code_cs, not just one, then you can do this:DECLARE
    CURSOR cur_prd
    IS SELECT *
         FROM     period_master
         ORDER BY period_code_c;
    TYPE prd_rec_ty IS TABLE OF cur_prd%ROWTYPE INDEX BY PLS_INTEGER;
    lv_prd_data prd_rec_ty;
    BEGIN
    OPEN cur_prd;
    FETCH cur_prd BULK COLLECT into lv_prd_data;
    CLOSE cur_prd;
    IF lv_prd_data.COUNT > 0
    THEN
    FOR i IN lv_prd_data.FIRST .. lv_prd_data.LAST
         LOOP
         dbms_output.put_line ( 'For Period code : '
                        || lv_prd_data(i).period_code_c
                        || ' the Year code is : '
                        || lv_prd_data(i).year_code_c
         dbms_output.Put_line ( 'For Period code : '
                        || lv_prd_data(i).period_code_c
                        || ' the Period_from_dt is : '
                        || lv_prd_data(i).period_frm_dt
         dbms_output.put_line ( 'For Period code : '
                        || lv_prd_data(i).period_code_c
                        || ' the Period_to_dt is : '
                        || lv_prd_data(i).period_to_dt
         END LOOP;
    END IF;
    END;

  • Form Email and Insert to DB

    I'm trying to get a form both - email and insert into a database the form information.  Below, you can see the code I am using.
    Here is my setup:
    1. I have a form where the action is a file called formmail.php
    2. This file inserts the data into a database and then includes another file called phpmail.php
    3. phpmail.php first looks in a file called zipcodes.php where I've set a number of arrays for various possible zipcodes.
    4. phpmail.php then emails the form data to the email addresses associated with those zipcodes.
    Without the formmail.php step - it works perfectly.
    With the formmail.php step - it inserts it into a database, checks if the email address is formatted correctly, but does not email anyone.
    Do you know why?   Below is the code for the various files:
    formail.php
    <?php
    $con = mysql_connect("localhost","user","password");
    if (!$con)
    die('Could not connect: ' . mysql_error());
    mysql_select_db("phtsystem", $con);
    $sql="INSERT INTO leads (firstname, lastname, address, city, `state`, zip, phone, email, comments, reason) VALUES ('$_POST[name2]','$_POST[last_name]','$_POST[address]','$_POST[city]','$_POST[state]','$_POST[zip]','$_POST[phone2]','$_POST[email]','$_POST[comments]','$_POST[reason]')";
    if (!mysql_query($sql,$con))
    die('Error: ' . mysql_error());
    include "phpmail.php";
    ?>
    phpmail.php
    <?php
    include("zipcodes.php");
    $zip=$_POST["zip"];
              if (in_array($zip, $Nashville)) {
    $my_email = "[email protected], [email protected], [email protected], [email protected]";
              }elseif (in_array($zip, $Knoxville)) {
    $my_email = "[email protected], [email protected], [email protected], [email protected]";
              }elseif (in_array($zip, $Huntsville)) {
    $my_email = "[email protected], [email protected], [email protected], [email protected]";
              }elseif (in_array($zip, $Florida)) {
    $my_email = "[email protected], [email protected], [email protected], [email protected]";
              }elseif (in_array($zip, $Georgia)) {
    $my_email = "[email protected], [email protected], [email protected], [email protected]";
              }elseif (in_array($zip, $SouthCarolina)) {
    $my_email = "[email protected], [email protected], [email protected], [email protected]";
              }elseif (in_array($zip, $NorthCarolina)) {
    $my_email = "[email protected], [email protected], [email protected], [email protected]";
              }elseif (in_array($zip, $Pennsylvania)) {
    $my_email = "[email protected], [email protected], [email protected]";
              }elseif (in_array($zip, $Maryland)) {
    $my_email = "[email protected], [email protected], [email protected], [email protected]";
               }elseif (in_array($zip, $Virginia)) {
    $my_email = "[email protected], [email protected], [email protected], [email protected]";
               }elseif (in_array($zip, $Texas)) {
    $my_email = "[email protected], [email protected], [email protected]";
    } else { $my_email = "[email protected], [email protected], [email protected]";
    $continue = "/";
    $errors = array();
    if(count($_COOKIE)){foreach(array_keys($_COOKIE) as $value){unset($_REQUEST[$value]);}}
    function recursive_array_check_header($element_value)
    global $set;
    if(!is_array($element_value)){if(preg_match("/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:)/i",$element_value)){$set = 1;}}
    else
    foreach($element_value as $value){if($set){break;} recursive_array_check_header($value);}
    recursive_array_check_header($_REQUEST);
    if($set){$errors[] = "You cannot send an email header";}
    unset($set);
    if(isset($_REQUEST['email']) && !empty($_REQUEST['email']))
    if(preg_match("/(%0A|%0D|\n+|\r+|:)/i",$_REQUEST['email'])){$errors[] = "Email address may not contain a new line or a colon";}
    $_REQUEST['email'] = trim($_REQUEST['email']);
    if(substr_count($_REQUEST['email'],"@") != 1 || stristr($_REQUEST['email']," ")){$errors[] = "Email address is invalid";}else{$exploded_email = explode("@",$_REQUEST['email']);if(empty($exploded_email[0]) || strlen($exploded_email[0]) > 64 || empty($exploded_email[1])){$errors[] = "Email address is invalid";}else{if(substr_count($exploded_email[1],".") == 0){$errors[] = "Email address is invalid";}else{$exploded_domain = explode(".",$exploded_email[1]);if(in_array("",$exploded_domain)){$errors[] = "Email address is invalid";}else{foreach($exploded_domain as $value){if(strlen($value) > 63 || !preg_match('/^[a-z0-9-]+$/i',$value)){$errors[] = "Email address is invalid"; break;}}}}}}
    if(!(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']))){$errors[] = "You must enable referrer logging to use the form";}
    function recursive_array_check_blank($element_value)
    global $set;
    if(!is_array($element_value)){if(!empty($element_value)){$set = 1;}}
    else
    foreach($element_value as $value){if($set){break;} recursive_array_check_blank($value);}
    recursive_array_check_blank($_REQUEST);
    if(!$set){$errors[] = "You cannot send a blank form";}
    unset($set);
    if(count($errors)){foreach($errors as $value){print "$value<br>";} exit;}
    if(!defined("PHP_EOL")){define("PHP_EOL", strtoupper(substr(PHP_OS,0,3) == "WIN") ? "\r\n" : "\n");}
    function build_message($request_input){if(!isset($message_output)){$message_output ="";}if(!is_array($request_input)){$message_output = $request_input;}else{foreach($request_input as $key => $value){if(!empty($value)){if(!is_numeric($key)){$message_output .= str_replace("_"," ",ucfirst($key)).": ".build_message($value).PHP_EOL.PHP_EOL;}else{$message_output .= build_message($value).", ";}}}}return rtrim($message_output,", ");}
    $message = build_message($_REQUEST) . "This email is from the website.  If it doesn't say specifically what the person is contacting us about, it is most likely a sales lead.";
    $message = $message . PHP_EOL.PHP_EOL."-- ".PHP_EOL."";
    $message = stripslashes($message);
    $subject = "New Lead from PHT.com";
    $headers = "From: " . $_REQUEST['email'];
    mail($my_email,$subject,$message,$headers);
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Dreamweaver Tutorial - Contact Form</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script type="text/javascript">
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-28969997-1']);
      _gaq.push(['_trackPageview']);
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    </script>
    </head>
    <body bgcolor="#ffffff" text="#000000">
    <div>
    <center>
    <b>Thank you <?php print stripslashes($_REQUEST['name']); ?></b>
    <br>Your message has been sent
    <p><a href="<?php print $continue; ?>">Click here to continue</a></p>
    </center>
    </div>
    </body>
    </html>
    zipcodes.php
    <?php
    $Nashville = array (37010, 37027, 37040, 37055, 37067, 37075, 37088, 37121, 37133, 37152, 37179, 37201, 37209, 37217, 37228, 37238, 37246, 37015, 37034, 37048, 37063, 37071, 37082, 37115, 37129, 37141, 37167, 37186, 37205, 37213, 37221, 37234, 37242, 37250, 38487, 37011, 37029, 37041, 37056, 37068, 37076, 37089, 37122, 37135, 37153, 37180, 37202, 37210, 37218, 37229, 37239, 37247, 37022, 37035, 37049, 37064, 37072, 37085, 37116, 37130, 37143, 37171, 37187, 37206, 37214, 37222, 37235, 37243, 38401, 37013, 37031, 37043, 37060, 37069, 37077, 37090, 37127, 37136, 37155, 37181, 37203, 37211, 37219, 37230, 37240, 37248, 37024, 37036, 37051, 37065, 37073, 37086, 37118, 37131, 37146, 37172, 37188, 37207, 37215, 37224, 37236, 37244, 38476, 37014, 37032, 37046, 37062, 37070, 37080, 37098, 37128, 37138, 37165, 37184, 37204, 37212, 37220, 37232, 37241, 37249, 37025, 37037, 37052, 37066, 37074, 37087, 37119, 37132, 37148, 37174, 37189, 37208, 37216, 37227, 37237, 37245, 38482);
    ?>
    <?php
    $Knoxville=array(37354, 37709, 37717, 37726, 37737, 37755, 37763, 37770, 37777, 37803, 37819, 37830, 37842, 37849, 37865, 37874, 37886, 37901, 37914, 37918, 37922, 37928, 37932, 37940, 37996, 38504, 37381, 37710, 37719, 37729, 37742, 37756, 37764, 37771, 37779, 37804, 37826, 37831, 37845, 37852, 37866, 37878, 37887, 37902, 37915, 37919, 37923, 37929, 37933, 37950, 37997, 38557, 37701, 37714, 37721, 37732, 37748, 37757, 37766, 37772, 37801, 37806, 37828, 37840, 37846, 37853, 37871, 37882, 37892, 37909, 37916, 37920, 37924, 37930, 37938, 37990, 37998, 38558, 37705, 37716, 37723, 37733, 37754, 37762, 37769, 37774, 37802, 37807, 37829, 37841, 37847, 37854, 37872, 37885, 37893, 37912, 37917, 37921, 37927, 37931, 37939, 37995, 37999);
    ?>
    etc...
    Message was edited by: Drymetal

    Scratch that.  It does work perfectly.   It just took the stupid server 20 minutes to send the emails. 

Maybe you are looking for

  • Does anyone have a PA271W, 2010 Mac Pro, and 5870 working via DisplayPort?

    Hi All, There are numerous threads about multi-monitor and resume-from-sleep issues with Mac Pro 2010 (5,1) and ATI 5870. There is also one thread in this forum with another user having problems with DisplayPort (henceforth, "DP") on his PA271W, but

  • Value type of Purchase order.

    Hi MM Experts, For a purchase order line items ME23N where can i see the Value type of the line items of a purchase order.(pls give step by step) i.e Value Type = 10 - Actual,20 - Plan, 50- Budget What is significance of following Value types 1. 40 -

  • Iweb won't post my snippet- newbie

    Hello all- kind of new to HTML. I have searched the discussions and have tried what I think are the answers, but to no avail. I have made a "how to" video using a program called Camtasia- http://www.techsmith.com/camtasiamac/ I export the video and s

  • Document.wwv_flow.submit is not a function -Error

    Hi All, Apex page have jquery,javescript etc..however..when i am trying ti hit the Button ..throwing error below like this.. document.wwv_flow.submit is not a function and no Action at all.. Please help me on this...

  • Selection of approvers for Bid

    Hello all, My one more thread is going on for Bid approval workflow problem. But since the subject requirement is different opened a new thread. Version: SRM 4.0SP08 SRM server 5.0 Set up: Strategic purchaser has role SAP_BBP_STAL_STRAT_PURCHASER and