SQL search problem

Hi,
I have this code:
// define an array of acceptable property types
$propTypes = array('Houses', 'Flats/Apartments',
'Bungalows','Commercial');
// if submitted value is in the array of acceptable types,
use it
// otherwise, use a wildcard character
if (isset($_REQUEST['PropType']) &&
in_array($_REQUEST['PropType'], $propTypes)) {
$PropType = "= '".$_REQUEST['PropType']."'";
} else {
$PropType = "LIKE '%'";
// check that the number of bedrooms is a number
// if it's zero, search for all numbers
if (isset($_REQUEST['NoBeds']) &&
is_numeric($_REQUEST['NoBeds']) &&
$_REQUEST['NoBeds'] == 0) {
$NoBeds = '> 0';
} elseif (isset($_REQUEST['NoBeds']) &&
is_numeric($_REQUEST['NoBeds']) &&
$_REQUEST['NoBeds'] > 0) {
$NoBeds = '= '.$_REQUEST['NoBeds'];
} else {
$NoBeds = '> 0';
// if minPrice is not a number, set it to zero
// otherwise, use the submitted value
if (isset($_REQUEST['minPrice']) &&
!is_numeric($_REQUEST['minPrice']) ||
!isset($_REQUEST['minPrice'])) {
$minPrice = 0;
} elseif (isset($_REQUEST['minPrice']) &&
is_numeric($_REQUEST['minPrice'])) {
$minPrice = $_REQUEST['minPrice'];
// if maxPrice is not a number, set it to 100 million
// otherwise, use the submitted value
if (isset($_REQUEST['maxPrice']) &&
!is_numeric($_REQUEST['maxPrice']) ||
!isset($_REQUEST['maxPrice'])) {
$minPrice = 100000000;
} elseif (isset($_REQUEST['maxPrice']) &&
is_numeric($_REQUEST['maxPrice'])) {
$minPrice = $_REQUEST['maxPrice'];
mysql_select_db($database_db, $db);
$query_Recordset1 = "SELECT * FROM property WHERE B_R = 'BUY'
AND Accepted = 'Yes' AND
(City = '$_POST
quote:
') Or Postcode LIKE '%$q' Or Area = '$_POST
quote:
' AND
PropType $PropType AND NoBeds $NoBeds AND Country = 'UK' AND
Cost BETWEEN $minPrice AND $maxPrice ORDER BY Cost $sort";
But I do not get the right search values from my form. It
will still display a property, if it meets one of the search
options.

Any help?

Similar Messages

  • NEED HELP IN SQL HOMEWORK PROBLEMS

    I NEED HELP IN MY SQL HOMEWORK PROBLEMS....
    I CAN SEND IT VIA EMAIL ATTACHMENT IN MSWORD....

    Try this:
    SELECT SUBSTR( TN,
                   DECODE(LEVEL, 1, 1, INSTR(TN, '#', 1, LEVEL-1) + 1),
                   DECODE( INSTR(TN, '#', 1, LEVEL) , 0 ,
                           LENGTH(TN) + 1, INSTR(TN, '#', 1, LEVEL) )
                   - DECODE(LEVEL, 1, 1, INSTR(TN, '#', 1, LEVEL-1 ) + 1)
           ) xxx
    FROM (
        SELECT '234123#1254343#909823#908232#12345' TN FROM DUAL
    CONNECT BY LEVEL <= LENGTH(TN) - LENGTH(REPLACE(TN,'#')) + 1
    XXX                               
    234123                            
    1254343                           
    909823                            
    908232                            
    12345
    SELECT regexp_substr(tn, '[^#]+', 1, level) xx
    FROM (
        SELECT '234123#1254343#909823#908232#12345' TN FROM DUAL
    CONNECT BY LEVEL <= LENGTH(TN) - LENGTH(REPLACE(TN,'#')) + 1
    XX                                
    234123                            
    1254343                           
    909823                            
    908232                            
    12345 

  • SQL injection problem

    hi
    How can we solve SQL injection problem in JDBC ?
    this means if we have a form with text field and the user must enter a number say 4 , instead he entered "4 or true" this will concatenated with the SQL query and return all records because of "or true"....
    is there any solutions ?
    i tried PreparedStatment and it words but not alwayes
    good luck

    i clearfied this in my first post
    if u didnt got what i mean u can google it
    http://www.google.com
    thanksYou didn't gently provide keywords, like I always do, so I cannot learn from you.
    Well, with a "reproduceable example" I mean that you have to post a short but complete working code snippet which reproduces the problem. So that we can copy'n'paste it in our environment here and test/debug it ourself and then eventually confirm the SQL injection.

  • Not Converted : Free-hand SQL connection problem

    While converting a Free Hand SQL report from Desktop Intelligence to Web Intelligence report in BI XI 3.1, I am faced with the problem
    Not Converted : <REPNAME> - Free-hand SQL connection problem
    It is be noted that there are some other Free Hand SQL Reports, that go converted and published without any error. The subject report has two Data Providers; one referring to the Universe and other from the Free Hand SQL tagged to a DB Connection

    Ajay,
    Some more points that can be of consideration to you to help understand my problems.
    The conversion from DeskI to WebI is in the same version BI XI 3.1 and not to BI 4.0 in which Free Hand SQLs is not supported.
    I have converted one other Free Hand SQL Report with an error "Partially Converted : <REPNAME2> - Conditional or permanent Hide Header not available in Web Intelligence", for which I had to edit the report in InfoView and un-tick the "Show When Empty" property of the table ( http://www.forumtopics.com/busobj/viewtopic.php?t=197157&view=next&sid=e6840aafa2d1267c66dae164d1dbf9db ). I think the solution mentioned in this link does not meet the purpose as the table is not displayed in the design time after the above untick.
    Coming back to our issue, further probing into this aspect I stumbled upon this link meant for RCT for BI 4.0 version
    https://csdwportal.dhhs.state.nc.us/downloads/Business%20Objects%20XI%20R4.0%20Docs/SAP%20BusinessObjects%20Report%20Con…
    where in Section 3.4.9, there is a mention of the limitation in conversion as under
    "Conversion of reports with free-hand SQL or stored procedures is only possible in Connected mode, since the Report Conversion Tool needs to use the secured connection to the database that is saved in the CMS."
    I want to how the secured connection to the database in REPNAME2 is different from the subject report REPNAME1 as REPNAME2 got partially converted. The error reported for Subject report is "Free Hand SQL Connection Problem" and not conversion problem which can occur after the connection is established.
    I did check the security properties of various FHSQL connections in the CMC and all of them are identical in nature.
    Please advise

  • SQL Command problem in Application Express 3.2.0.00.27

    To Oracle Application Express Development Team,
    Yesterday I installed Oracle Application Express 3.2.0.00.27.
    While doing my r&d, I came across one problem in SQL Command.
    For example I wanted to run sql "select * from tab"
    When I checked "Autocommit" checkbox it worked fine.
    But when I unchecked the "Autocommit" checkbox it gave me following error:
    ORA-01003: no statement parsed
    Please check post
    http://www.oraclebrains.com/2009/03/sql-command-problem-in-application-express-3200027/ for more details.
    Cheers

    I can't find the log file (a good indication that something went wrong)
    Here's the transcript of the session...
    SQL> startup upgrade
    ORACLE instance started.
    Total System Global Area 599785472 bytes
    Fixed Size 1288820 bytes
    Variable Size 264242572 bytes
    Database Buffers 331350016 bytes
    Redo Buffers 2904064 bytes
    Database mounted.
    Database opened.
    SQL> @apxpatch.sql
    PL/SQL procedure successfully completed.
    PL/SQL procedure successfully completed.
    Wrote file apxset.sql
    PL/SQL procedure successfully completed.
    PL/SQL procedure successfully completed.
    SQL>
    SQL> @apxldimg.sql
    PL/SQL procedure successfully completed.
    Enter value for 1: C:\Documents and Settings\jtench\Desktop\My Downloads\Oracle\apex_3.2.1
    old 1: create directory APEX_IMAGES as '&1/apex/images'
    new 1: create directory APEX_IMAGES as 'C:\Documents and Settings\jtench\Desktop\My Downloads\Oracle\apex_3.2.1/apex/images'
    Directory created.
    PL/SQL procedure successfully completed.
    PL/SQL procedure successfully completed.
    PL/SQL procedure successfully completed.
    Commit complete.
    timing for: Load Images
    Elapsed: 00:03:30.03
    Directory dropped.
    SQL>

  • Perform SQL search in QueryObject

    Hi,
    I've parsed a very complicated XML into several QueryObjects - more or less got now 3 "tables".
    Now i would like to use these three tables and perform a SQL search. something like
    Select * From tblMenu Where menu_dayId = 2
    I have searched and also tried to find a way in the Coldfusionreference, but was not lucky.
    Does anyone got a solution how i can achieve this goal?
    greets

    Found an answer: You just have to ask the correct question. QoQ = Query of Queries
    <cfset tblMenu = QueryNew("menuId, menu_dayId, menuDesc") />
    <cfquery dbtype="query" name="tblToday">
                select * from tblMenu
                where menu_dayId = #curWorkDay#
    </cfquery>

  • SQL Express problem client connection

    SQl Express problem, I can't connect another computer.
    I have sql express on win xp, and one client win 7 starter. The firewall is disable, I can ping the server computer (win xp pro). On Sql Configuration Manager I enable TCP/IP protocol and named pipes. ODBC local is fine, but remote don't connect.
    If anyone has an idea about this
    Felipe Script Center

    You hae to enable remote Connections as well, in Express Edition it's disabled by default, see
    Configure the remote access Server Configuration Option
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Pls help me(sql server problem)

    Im using sql server 2000
    i had 2 database servers
    'srv1', 'srv2'
    in srv1 had 'db1' database
    first create a user called 'db1usr1' with read and write previlages only(not dbowner)
    then take backup of 'db1' as 'db1bakup'
    then u hav to restore the 'db1bakup' in srv2 as 'db2'
    then u have 2 login in the 'srv2' machine as 'db1usr1'
    here is the problem : it is(db1usr1) not logged in srv2 machine through query analyser

    You're asking about a sql server problem on an Oracle forum?
    Don't you think a sql server forum would be a more appropriate place for your question?

  • Outlook 2010, Exchange 2010 - Searching Problems

    Anyone out there able to help with some searching problems some of our users have been seeing?
    Searching in OWA works fine but some people have problems when searching for older emails in Outlook. We've rebuilt Outlook profiles, rebuilt the windows index's (which seems to work but only temporarily). If there's a way to schedule the Windows index to
    rebuild every night or once  week, I'd be very happy to test that out but haven't been able to figure out how to do that.
    Anyone have any other ideas?

    Hi,
    It seems something keeps corrupting the index... Run Anti-virus program and Malicious Software Removal Tool to scan your system, check if there's any virus or malware that may cause the index issue.
    If this issue persists, please also go to File tab ->
    Options -> Search -> Indexing Options
    -> Advanced -> Click Troubleshoot search and indexing, to do some troubleshooting steps to find the possible cause.
    I hope this helps.
    Regards,
    Melon Chen
    TechNet Community Support

  • Form_check.php returns SQL Configuration Problem

    Hello, I am hosting the MUSE outside of BC and the form cannot send out email. http://<website>/scripts/form_check.php shows that there is a SQL Configuration Problem. How to fix?

    Repplying to myself Ok, after lots of frustration, tickets to web host admin, forum crawlign it looks like the problem was either on the PHP-versio or the name of the form. The forms were titled with Scandinavian characters and "/"-mark so after simplified the forename from muse the messages came trough! The thing is that also did change in control panel of my web host from PHP-version 4.3 to PHP 4.5 so not sure which one did the job, actually i did try with fresh-starndard forms out of Muse and also with the complexly-named ones and the later did not come trough with the PHP-version change. So i would expect that it was both - naming and php-version.
    Hopefully this will help others since painful form-issue it was. Used woo-forms for whole but in terms of easy updatebility i decided to go with MUSE one. Tool still missing crucial features like radio buttons but looks like Muse been little hobby of Adobe so features coming in one by one, slowly but surely.
    Not sure though if next time will be building site using DW since these small limitations - issues makes life so much harder. When the app works it works like charm but when issue arrises you better of building stuff from scratch.

  • SQL REPORT BUT SEARCH PROBLEM ON CREATED_ON Column

    Hi Friend,
    i have create SQL Report .
    My Code
    select      CRM_SALES_DEALs.id,
                        "CRM_SALES_CUSTOMERS"."CUSTOMER_NAME" as "CUSTOMER_NAME",
          "CRM_SALES_SALESREPS"."REP_LAST_NAME"||', '||
          "CRM_SALES_SALESREPS"."REP_FIRST_NAME" as "REP_NAME",
           "CRM_SALES_DEALS"."DEAL_CLOSE_DATE" as "DEAL_CLOSE_DATE",
           "CRM_SALES_DEALS"."DEAL_PROBABILITY" as "DEAL_PROBABILITY",
          "CRM_SALES_DEAL_STATUS_CODES"."STATUS_CODE" as "STATUS_CODE" ,
             "CRM_SALES_DEALS"."DEAL_AMOUNT" *
             "CRM_SALES_DEALS"."DEAL_PROBABILITY" / 100 weighted_forecast,
    (select count(*) from CRM_SALES_DEAL_notes where deal_id = "CRM_SALES_DEALS".id) notes,
    (select count(*) from CRM_SALES_DEAL_products where deal_id = "CRM_SALES_DEALS".id) products,
    nvl("CRM_SALES_DEALS".updated_on,"CRM_SALES_DEALS".created_on) last_changed,
    t.territory_name,
    CRM_SALES_DEALS.qtr, "CRM_SALES_DEALS"."CONTACT_NAME" as "CONTACT_NAME"
    from     
    "CRM_SALES_SALESREPS",
    "CRM_SALES_DEAL_STATUS_CODES" ,
    "CRM_SALES_CUSTOMERS",
    "CRM_SALES_DEALS",
    CRM_SALES_territories t
    where  
    CRM_SALES_customers.customer_territory_id = t.id(+) and
    "CRM_SALES_DEALS"."CUSTOMER_ID"="CRM_SALES_CUSTOMERS"."ID"(+)
    and      "CRM_SALES_DEALS"."DEAL_STATUS_CODE_ID"="CRM_SALES_DEAL_STATUS_CODES"."ID"(+)
    and      "CRM_SALES_DEALS"."SALESREP_ID_01"="CRM_SALES_SALESREPS"."ID"(+)
    and (:p1_find is null or instr(upper("CRM_SALES_CUSTOMERS"."CUSTOMER_NAME"),upper(:p1_find))>0 or instr(upper("CRM_SALES_DEALS"."DEAL_NAME"),upper(:p1_find))>0 or
    instr(upper("CRM_SALES_SALESREPS"."REP_FIRST_NAME"||' '||"CRM_SALES_SALESREPS"."REP_LAST_NAME"),upper(:p1_find))>0)
    and
    (nvl(:P1_TERRITORY,0) = 0 or t.id= :P1_TERRITORY)
    and
    (nvl(:P1_ACCOUNT,0) = 0 or "CRM_SALES_CUSTOMERS".id = :P1_ACCOUNT)
    and
    (nvl(:P1_QUARTER,'0') = '0' or CRM_SALES_deals.qtr = :P1_QUARTER)
    and
    nvl(DEAL_PROBABILITY,10) between nvl(:P1_MINIMUM_PROBABILITY,0) and nvl(:P1_MAXIMUM_PROBABILITY,100) or
    instr(upper("CREATED_ON"),upper(nvl(:P1_CREATE_DATE,"CREATED_ON")))My TAble
    CREATE TABLE  "CRM_SALES_DEALS"
       (     "ID" NUMBER,
         "CUSTOMER_ID" NUMBER NOT NULL ENABLE,
         "DEAL_NAME" VARCHAR2(255),
         "DEAL_CLOSE_DATE" DATE NOT NULL ENABLE,
         "DEAL_CLOSE_DATE_ALT" DATE,
         "DEAL_STATUS_CODE_ID" NUMBER,
         "DEAL_CUSTOMER_LOCATION" VARCHAR2(4000),
         "CREATED_BY" VARCHAR2(255),
         "CREATED_ON" DATE,
         "UPDATED_BY" VARCHAR2(255),
         "UPDATED_ON" DATE,
         "QTR" VARCHAR2(8),
         "DEPARTURE_DATE" DATE,
         "DEAL_SOURCE" VARCHAR2(15),
         "ADDRESS1" VARCHAR2(255),
          PRIMARY KEY ("ID") ENABLE
    /i want to search with CREATE_ON Column.
    How can i create code for search in my Quary Code.
    My Item is :P1_CREATE_DATE
    I have try it in last Line in code but it's show me Error.Invalid Relational Operator .
    How can i slove and serch with Created_on Column.
    Thanks
    Edited by: 805629 on Dec 27, 2010 9:13 PM
    Edited by: 805629 on Dec 27, 2010 9:13 PM

    Hi Friends,
    i have sortout this problem.
    Thanks

  • SQL Toolkit -- problem searching Date/Time field in Access

    I have got an application where I need to query a database (Access) between
    two dates (usually the same date, a couple of hours apart). I have set up
    the date field within Access as a 'General Date' but can't seem to get the
    right format on the SQL query. I am always getting some error. I enclose
    the date with {}, '', [], and () (and anything else I can think of) and I
    still get a problem. It is now to the point where I think it might be a
    problem with SQL Toolkit and Access working together.
    I tried making the Date field into a string field (instead of a Date field),
    but I can't search between time (I can search between dates, but not date
    and time i.e. MM/DD/YY 00:00:00).
    Any ideas?

    Sorry, the database type is Access.
    I just tried the following query SELECT * FROM ValveMeritData WHERE MeritTestDateTime >= '2006/05/01 13:24:28'
    and SELECT * FROM ValveMeritData WHERE MeritTestDateTime >= '2006/05/01'  (which gave a data mismatch error).
    I am going to try the query in access now.  I had pretty good success with other types of queries, just writing them in
    Labview and testing.
    Any other suggestions?

  • SQL statement - tricky search problem

    Hi,
    I am working in asp and use an Access db. I have a database
    with 500 shops around the world, the table contains among other
    things shop name, country and region (Europe, Asia etc). Then a
    search page with dropdown lists, one for Region and one for
    Country. Here is the problem, which seems easy first, but I really
    can´t get the sql statement to do what I want:
    The Region list has the following values:
    Any region
    Europe
    Asia
    etc
    The country list has te following values:
    Any country
    Sweden
    Germany
    USA
    etc
    Ok, so the problem is if the user choose "Any Region" and
    "Any Country" all shops should come up. "Europe" and "Any Country"
    should give all shops in Europe". "Any region" and "Sweden" should
    pull up ONLY shops in Sweden. "Europe" and "Sweden" should also
    pull up shops in Sweden only.
    Now you start see the problem. I have laborated with AND resp
    OR statments and also % resp xyz in the "Any Country" and "Any
    Region" values.
    Any help would be highly appreciated! Thanks!!

    Thank Manish,
    Could you tell me how to restrict in following codes?
    select
    e.EQUIPMENT_ID,
    e.HOST_NAME,
    e.SERIAL_NUMBER,
    e.CITY,
    e.ROOM,
    e.RACK,
    e.CR_DT,
    e.CR_USR,
    e.LM_USR,
    e.LM_DT,
    e.TASK_TASK_ID
    from SVR_EQUIPMENT e
    where
    instr(upper(e.SERIAL_NUMBER),upper(nvl(:P1_REPORT_SEARCH,e.SERIAL_NUMBER))) > 0 and
    instr(upper(e.CITY),upper(nvl(:P1_REPORT_SEARCH,e.CITY))) > 0 and
    instr(upper(e.CR_USR),upper(nvl(:P1_REPORT_SEARCH,e.CR_USR))) > 0 or
    instr(upper(e.LM_USR),upper(nvl(:P1_REPORT_SEARCH,e.LM_USR))) > 0
    Thanks for all again,
    Sam

  • PL/SQL reporting problem -  "The webpage cannot be found" error

    Dear All Expert,
    I'm here having a problem on generating apex report using PL/SQL. "The webpage cannot be found" error appear when "Search" button pressed.
    I'm appreciating if anyone can give their idea on this issue.
    PL/SQL will be fired when "Search" button pressed.
    My PL/SQL code as below;
    DECLARE
    lv_desc CLOB:='';
    lv_note_desc varchar2(4000);
    lv2      CLOB;
    lv_title varchar2(2000);
    lv_ti          varchar2(10);
    lv_tg          varchar2(10);
    lv_tr_cnt     integer:= 0;
    lv_ti_code     varchar2(6);
    lv_age          number(6):= 0;
    lv_note_flag     varchar(1);
    fv_note_flag varchar2(6);
    fv_ti_code varchar2(6);
    ti_code varchar2(20);
    ti_name varchar2(50);
    ti_tm_code varchar2(6);
    ti_test_grp varchar2(6);
    note_desc varchar2(4000);
    ti_unit varchar2(20);
    ti_insurance_code varchar2(20);
    ti_price number(14);
    ti_sex varchar(1);
    ti_age varchar(10);
    ti_tr_desc varchar(30);
    ti_lolimit number(10);
    ti_uplimit number(10);
    ti_plolimit number(10);
    ti_puplimit number(10);
    lv_hkey          number(10):= 0;
    lv_found     varchar2(1):= 'N';
    lv_itpv     varchar2(4000);          
    lv_lolimit     char(15);
    lv_uplimit     char(15);
    lv_tr          char(15);
    lv_tc          char(30);
    CURSOR READ_C1_REC IS
    select ti_code, ti_name, ti_tm_code, ti_test_grp,ti_unit, ti_itpv_flag,ti_attached_cmt
    from test_item
    where ti_code like NVL(:P11104_TI_CODE,'%')
    and ti_test_grp like NVL(:P11104_TG_CODE,'%')
    and ti_code not like '0MB%'
    order by ti_code;
    C1_REC READ_C1_REC%ROWTYPE;
    CURSOR READ_C2_REC IS
    select tr_sex_code,tr_ageto,tr_agecode,tr_range_desc,tr_mrr_desc,tr_normal_lolimit,tr_upper_uplimit,tr_panic_lolimit,tr_panic_uplimit
    from tr_range
    where tr_ti_code = lv_ti_code
    order by tr_ageto asc,tr_sex_code desc;
    C2_REC READ_C2_REC%ROWTYPE;
    cursor READ_C3_REC is
    select tivh_key
    from test_itpvh
    where tivh_ti_code = ti_code
    order by tivh_efd desc;
    C3_REC READ_C3_REC%ROWTYPE;
    cursor READ_C4_REC is
    select tivd_lolimit,tivd_uplimit,tivd_value,tivd_rr_desc
    from test_itpvd
    where tivd_hkey = lv_hkey
    order by tivd_seqno;
    C4_REC READ_C4_REC%ROWTYPE;
    BEGIN
    lv_title := '<div style="overflow: auto;height: 500px; width: 1000px;"><table style="width: 500px" cellpadding="0" cellspacing="0"><thead><tr><th>Code</th><th>Name</th></tr></thead>';
    htp.p(lv_title);
    OPEN READ_C1_REC;
    LOOP
    FETCH READ_C1_REC INTO C1_REC;
    EXIT WHEN READ_C1_REC%NOTFOUND;
         lv_note_flag := 'N';     
    fv_note_flag := 'N';
         fv_ti_code := c1_rec.ti_code;
    ti_code := c1_rec.ti_code;
    ti_name := ' '||c1_rec.ti_name;
    ti_tm_code := c1_rec.ti_tm_code;
         ti_test_grp := c1_rec.ti_test_grp;
    lv_desc := '<tbody><tr><td><input type="hidden" name="f01" value="'||fv_ti_code||'" /></td>'||
    '<td><input type="text" name="f02" size="20" maxlength="20" value="'||ti_code||'" /></td>'||
    '<td><input type="text" name="f03" size="50" maxlength="50" value="'||ti_name||'" /></td>'||
    '<td><input type="text" name="f04" size="6" maxlength="6" value="'||ti_tm_code||'" /></td>'||
    '<td><input type="text" name="f05" size="6" maxlength="6" value="'||ti_test_grp||'" /></td>';
    if c1_rec.ti_itpv_flag = 'Y' then
         lv_note_flag := 'Y';
         open read_c3_rec;
         loop
              fetch read_c3_rec into c3_rec;
              exit when read_c3_rec%notfound;
              lv_hkey := c3_rec.tivh_key;
              lv_found := 'Y'; exit;
         end loop;
         close read_c3_rec;
    if lv_found = 'Y' then
              lv_lolimit := 'Lower limit'; lv_uplimit := 'Upper limmit';
              lv_tr := 'Result'; lv_tc := 'Comment';
              lv_itpv := 'INTERPRETED TEST RESULT'||chr(10)||'-----------------------'||chr(10)||lv_lolimit||lv_uplimit||lv_tr||lv_tc||chr(10);
              open read_c4_rec;
              loop
              fetch read_c4_rec into c4_rec;
              exit when read_c4_rec%notfound;
              lv_lolimit := to_char(c4_rec.tivd_lolimit,'999990.999');
              lv_uplimit := to_char(c4_rec.tivd_uplimit,'999990.999');
    lv_tr := c4_rec.tivd_value;          
              lv_tc := c4_rec.tivd_rr_desc;
              lv_itpv := lv_itpv||chr(10)||lv_lolimit||lv_uplimit||lv_tr||lv_tc;
              end loop;
              close read_c4_rec;
         end if;
    note_desc := lv_itpv||chr(10)||chr(10);
         end if;
         if ltrim(rtrim(c1_rec.ti_attached_cmt)) is not null then
         lv_note_flag := 'Y';
         note_desc := note_desc||'ATTACHED COMMENTS'||chr(10)||'-----------------'||chr(10)||ltrim(rtrim(c1_rec.ti_attached_cmt))||chr(10);
         end if;
    begin
         select unit_name into ti_unit
    from unit_tbl
    where unit_code = c1_rec.ti_unit;
         exception when no_data_found then
    ti_unit := null;
         end;
    lv_desc := lv_desc ||'<td><input type="text" name="f06" size="20" maxlength="20" value="'||ti_unit||'" /></td>';
    begin
         select imh_insurance_code, imh_curr_p1 into ti_insurance_code, ti_price
         from item_masterh
    where imh_code = c1_rec.ti_code;
         exception when no_data_found then
         ti_insurance_code := null; ti_price := null;
         end;
    lv_desc := lv_desc ||'<td><input type="text" name="f07" size="20" maxlength="20" value="'||ti_insurance_code||'" /></td>'||'<td><input type="text" name="f08" size="14" maxlength="14" value="'||to_char(ti_price)||'" /></td>';
    lv_ti_code := c1_rec.ti_code;     
    lv_tr_cnt := 0;
    lv2 := '<table width="100%" border="0" bgcolor="#009900" cellspacing="0">';
    OPEN READ_C2_REC;
         LOOP
         FETCH READ_C2_REC INTO C2_REC;
         EXIT WHEN READ_C2_REC%NOTFOUND;
         lv_tr_cnt := lv_tr_cnt + 1;
    if c2_rec.tr_agecode = 'Y' then                    
    lv_age := c2_rec.tr_ageto / 365;
         elsif c2_rec.tr_agecode = 'M' then
              lv_age := c2_rec.tr_ageto / 30;
         else
              lv_age := c2_rec.tr_ageto;
         end if;
         ti_sex := c2_rec.tr_sex_code;
    ti_age := lv_age||c2_rec.tr_agecode;     
    ti_tr_desc := ' '||c2_rec.tr_range_desc;
         ti_lolimit := c2_rec.tr_normal_lolimit;
         ti_uplimit := c2_rec.tr_upper_uplimit;
         ti_plolimit := c2_rec.tr_panic_lolimit;
         ti_puplimit := c2_rec.tr_panic_uplimit;
    if c2_rec.tr_range_desc = 'MRR' then
         lv_note_flag := 'Y';
         note_desc := 'MRR DESCRIPTION'||chr(10)||'---------------'||chr(10)||c2_rec.tr_mrr_desc||chr(10)||chr(10)||note_desc;
         end if;
    if lv_note_flag = 'Y' then
    fv_note_flag := 'Y';
    end if;
    lv2 := lv2 || '<tr><td><input type="text" name="f09" size="1" maxlength="1" value="'||ti_sex||'" /></td>'||'<td><input type="text" name="f10" size="10" maxlength="10" value="'||to_char(ti_age)||'" /></td>'||'<td><input type="text" name="f11" size="30" maxlength="30" value="'||ti_tr_desc||'" /></td>'||'<td><input type="text" name="f12" size="10" maxlength="10" value="'||to_char(ti_lolimit,'99990.999')||'" /></td>'||'<td><input type="text" name="f13" size="10" maxlength="10" value="'||to_char(ti_uplimit,'99990.999')||'" /></td>'||'<td><input type="text" name="f14" size="10" maxlength="10" value="'||to_char(ti_plolimit,'99990.999')||'" /></td>'||'<td><input type="text" name="f15" size="10" maxlength="10" value="'||to_char(ti_puplimit,'99990.999')||'" /></td></tr>';
         END LOOP; lv2 := lv2||'</table>';
         CLOSE READ_C2_REC;
    if lv_tr_cnt = 0 then
         if lv_note_flag = 'Y' then
    fv_note_flag := 'Y';
    end if;
         end if;
    lv_desc := lv_desc||'<td><input type="hidden" name="f16" value="'||fv_note_flag||'" /></td>'||'<td><input type="hidden" name="f17" value="'||note_desc||'" /></td>';
         lv_desc := lv_desc||'<td>'||lv2||'</td></tr></tbody>';
    htp.p(lv_desc);
    END LOOP;
    CLOSE READ_C1_REC;
    htp.p('</table>');
    END;
    Thanks you very much in advance!

    First thing I'd say is that you're code doesn't compile:
    lv_title := '   //  <----Secondly, does no-one use comments anymore? Isn't this drilled into people in programming classes at colleges? There's a whole bunch of code there but not much in the way of explanation as to what you are trying to achieve. It might make perfect sense to you now but try going back to it in a year and see if you can untangle it's purpose.
    Thirdly, is there a specific reason why you've chosen to manually generate a report in PL/SQL, rather than delegating it to a report region? I understand that for particular formatting requirements (denormalised data, cells-within-cells etc), it is occasionally necessary to go to these lengths but I can't help but feeling a well-written query could simplify a lot of this, particularly the references multiple cursors.

  • SQL*Loader problem - not efficient, parsing error for big xml files

    Hi Experts,
    First of all, I would like to store xml files in object relation way. Therefore I created a schema and a table for it (see above).
    I wants to propagate it (by using generated xml files), hence I created a control file for sql loader (see above).
    I have two problems for it.
    1, It takes a lot of time. It means I can upload a ~80MB file in 2 hours and a half.
    2, At bigger files, I got the following error messages (OCI-31011: XML parsing failed OCI-19202: Error occurred in XML processing LPX-00243: element attribute value must be enclosed in quotes). It is quite interesting because my xml file is generated and I could generated and uploaded the first and second half of the file.
    Can you help me to solve these problems?
    Thanks,
    Adam
    Control file
    UNRECOVERABLE
    LOAD DATA
    CHARACTERSET UTF8
    INFILE *
    APPEND
    INTO TABLE coll_xml_objrel
    XMLTYPE(xml)
    FIELDS
    ident constant 2
    ,file_name filler char(100)
    ,xml LOBFILE (file_name) TERMINATED BY EOF
    BEGINDATA
    generated1000x10000.xml
    Sql Loader command
    sqlldr.exe username/password@//localhost:1521/SID control='loader.ctl' log='loadr.log' direct=true
    Schema
    <?xml version="1.0" encoding="UTF-8"?>
    <schema targetNamespace="http://www.something.com/shema/simple_searches" elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.something.com/shema/simple_searches">
        <element name="searches" type="tns:searches_type"></element>
        <element name="search" type="tns:search_type"></element>
        <element name="results" type="tns:results_type"></element>
        <element name="result" type="tns:result_type"></element>
        <complexType name="searches_type">
            <sequence>
                <element ref="tns:search" maxOccurs="unbounded"></element>
            </sequence>
        </complexType>
        <complexType name="search_type">
            <sequence>
                <element ref="tns:results"></element>
            </sequence>
            <attribute ref="tns:id" use="required"></attribute>
            <attribute ref="tns:type" use="required"></attribute>
        </complexType>
        <complexType name="results_type">
            <sequence maxOccurs="unbounded">
                <element ref="tns:result"></element>
            </sequence>
        </complexType>
        <complexType name="result_type">
            <attribute ref="tns:id" use="required"></attribute>
        </complexType>
        <simpleType name="type_type">
            <restriction base="string">
                <enumeration value="value1"></enumeration>
                <enumeration value="value2"></enumeration>
            </restriction>
        </simpleType>
        <attribute name="type" type="tns:type_type"></attribute>
        <attribute name="id" type="string"></attribute>
    </schema>
    Create table
    create table coll_xml_objrel
    ident Number(20) primary key,
    xml xmltype)
    Xmltype column xml
    store as object relational
    xmlschema "http://www.something.com/schema/simple_searches.xsd"
    Element "searches";

    Hi Odie_63,
    Thanks for your answer.
    I will post this question in the XML DB forum too (edit: I realized that you have done it. Thanks for it).
    1, Version: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    2, see above
    3, I have registered my schema with using dbms_xmlschema.registerSchema function.
    Cheers,
    Adam
    XML generator:
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import javax.xml.stream.XMLOutputFactory;
    import javax.xml.stream.XMLStreamException;
    import javax.xml.stream.XMLStreamWriter;
    public class mainGenerator {
        public static void main(String[] args) throws FileNotFoundException, XMLStreamException {
            // TODO Auto-generated method stub
            final long numberOfSearches = 500;
            final long numberOfResults = 10000;
            XMLOutputFactory xof = XMLOutputFactory.newFactory();
            XMLStreamWriter writer = xof.createXMLStreamWriter(new FileOutputStream("C:\\Working\\generated500x10000.xml"));
            writer.writeStartDocument();
            writer.writeStartElement("tns","searches", "http://www.something.com/schema/simple_searches");
            writer.writeNamespace("tns", "http://www.something.com/schema/simple_searches");
            for (long i = 0; i < numberOfSearches; i++){
                Long help = new Long(i);
                writer.writeStartElement("tns","search", "http://www.something.com/schema/simple_searches);
                writer.writeAttribute("tns", "http://www.something.com/schema/simple_searches", "type", "value1");
                writer.writeAttribute("tns", "http://www.something.com/schema/simple_searches", "id", help.toString());
                writer.writeStartElement("tns","results", "http://www.something.com/schema/simple_searches");
                for (long j = 0; j < numberOfResults; j++){
                    writer.writeStartElement("tns","result", "http://www.something.com/schema/simple_searches");
                    Long helper = new Long(i*numberOfResults+j);
                    writer.writeAttribute("tns", "http://www.something.com/schema/simple_searches", "id", helper.toString());
                    writer.writeEndElement();
                writer.writeEndElement();
                writer.writeEndElement();
            writer.writeEndElement();
            writer.writeEndDocument();
            writer.close();
    registerSchema:
    begin
    dbms_xmlschema.registerSchema(
    'http://www.something.com/schema/simple_searches',
    '<?xml version="1.0" encoding="UTF-8"?>
    <schema targetNamespace="http://www.something.com/schema/simple_searches" elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.something.com/schema/simple_searches">
        <element name="searches" type="tns:searches_type"></element>
        <element name="search" type="tns:search_type"></element>
        <element name="results" type="tns:results_type"></element>
        <element name="result" type="tns:result_type"></element>
        <complexType name="searches_type">
            <sequence>
                <element ref="tns:search" maxOccurs="unbounded"></element>
            </sequence>
        </complexType>
        <complexType name="search_type">
            <sequence>
                <element ref="tns:results"></element>
            </sequence>
            <attribute ref="tns:id" use="required"></attribute>
            <attribute ref="tns:type" use="required"></attribute>
        </complexType>
        <complexType name="results_type">
            <sequence maxOccurs="unbounded">
                <element ref="tns:result"></element>
            </sequence>
        </complexType>
        <complexType name="result_type">
            <attribute ref="tns:id" use="required"></attribute>
        </complexType>
        <simpleType name="type_type">
            <restriction base="string">
                <enumeration value="value1"></enumeration>
                <enumeration value="value2"></enumeration>
            </restriction>
        </simpleType>
        <attribute name="type" type="tns:type_type"></attribute>
        <attribute name="id" type="string"></attribute>
    </schema>',
    TRUE, TRUE, FALSE, FALSE);
    end

Maybe you are looking for