Pl/sql region in apex

Hi All,
From sqlworkshop,
I have created a view like
CREATE OR REPLACE FORCE VIEW VW_SUB_CL_ADD1 AS
(select a.siteid siteid,a.bpaadd_0 bpaadd_0,a.bpanum_0 bpanum_0,
case when a.bpaaddlig_0 = '' then '-' else a.bpaaddlig_0 end address1,
case when a.bpaaddlig_1 = '' then '-' else a.bpaaddlig_1 end address2,
case when a.bpaaddlig_2 = '' then '-' else a.bpaaddlig_2 end address3,
case when a.bpades_0 = '' then '-' else a.bpades_0 end place,
case when a.cty_0 = '' then '-' else a.cty_0 end city,
case when a.poscod_0 = '' then '-' else a.poscod_0 end pincode,
case when b.cntnam_0 = '' then '-' else b.cntnam_0 end contactname,
case when b.fax_0 = '' then '-' else b.fax_0 end fax,
case when b.MOBTEL_0 = '' then '-' else b.MOBTEL_0 end mobile,
case when b.TEL_0 = '' then '-' else b.TEL_0 end phone,
case when b.web_0 = '' then '-' else b.web_0 end website,
c.zinvcty_0 zcity,c.bpainv_0 bpainv_0,c.bpcnum_0 bpcnum_0
from lbcreport.bpaddress@info a,lbcreport.contact@info b ,lbcreport.bpcustomer@info c
where (a.bpanum_0=b.bpanum_0) and (a.cty_0 = c.zinvcty_0) and (a.siteid = c.siteid))
but when i execute select * from vw_sub_cl_add1
the case is not working. '-' is not getting displayed for null values even i tried nvl function it is not working
when i use this view in apex for pl/sql region to display in the form of table .
The problem is, when there is no value in the columns the table is not showing row and column in a proper manner.
could any one help to overcome it.
Thanks in advance
bye
Srikavi

Hi Srikavi,
From your statement, it looks as though you are retrieving data from an external datasource? I have had a similar problem - it's due to the ODBC driver not recognizing nulls properly. In the end, I had to do something like:
case when xxx is null then '-' when xxx = ' ' then '-' when xxx = '' then '-' else xxx end xxxxx,
...This particularly happens with MS SQL databases and especially when their tables use char instead of varchar fields. The MSSQL table treats "empty" char fields as nulls but the ODBC driver doesn't - so the IS NULL value won't work on Oracle's side and the '' comparison won't always work on MS SQL side; hence having to check for all possibilities. The above may be overkill, but it did the job!
Andy

Similar Messages

  • Sorry-duplicate thread,since problem in forumby5.45pm pl/sql region in apex

    Hi All,
    From sqlworkshop,
    I have created a view like
    CREATE OR REPLACE FORCE VIEW VW_SUB_CL_ADD1 AS
    (select a.siteid siteid,a.bpaadd_0 bpaadd_0,a.bpanum_0 bpanum_0,
    case when a.bpaaddlig_0 = '' then '-' else a.bpaaddlig_0 end address1,
    case when a.bpaaddlig_1 = '' then '-' else a.bpaaddlig_1 end address2,
    case when a.bpaaddlig_2 = '' then '-' else a.bpaaddlig_2 end address3,
    case when a.bpades_0 = '' then '-' else a.bpades_0 end place,
    case when a.cty_0 = '' then '-' else a.cty_0 end city,
    case when a.poscod_0 = '' then '-' else a.poscod_0 end pincode,
    case when b.cntnam_0 = '' then '-' else b.cntnam_0 end contactname,
    case when b.fax_0 = '' then '-' else b.fax_0 end fax,
    case when b.MOBTEL_0 = '' then '-' else b.MOBTEL_0 end mobile,
    case when b.TEL_0 = '' then '-' else b.TEL_0 end phone,
    case when b.web_0 = '' then '-' else b.web_0 end website,
    c.zinvcty_0 zcity,c.bpainv_0 bpainv_0,c.bpcnum_0 bpcnum_0
    from lbcreport.bpaddress@info a,lbcreport.contact@info b ,lbcreport.bpcustomer@info c
    where (a.bpanum_0=b.bpanum_0) and (a.cty_0 = c.zinvcty_0) and (a.siteid = c.siteid))
    but when i execute select * from vw_sub_cl_add1
    the case is not working. '-' is not getting displayed for null values even i tried nvl function it is not working
    when i use this view in apex for pl/sql region to display in the form of table .
    The problem is, when there is no value in the columns the table is not showing row and column in a proper manner.
    could any one help to overcome it.
    Thanks in advance
    bye
    Srikavi
    Edited by: srikavi on Sep 10, 2008 10:42 AM

    Srikavi,
    1. The problem with null values is a template problem. Using Firefox and Web Developer Toolbar extension / CSS / View Style Information, you can find out which css class your report is referencing. Open the corresponding css file and add the following to the css class:
    empty-cells:show;border-collapse:collapse;
    It will show the borders for null values after that.
    2. b.fax_0 = '' is not correct. It should be b.fax_0 IS NULL.
    3. You can also try to use the built in property for showing NULL values as in the report attributes.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • Htp.p not rendering correctly in Apex PL/SQL region

    I'm using Apex 3.0.1 and have an application that merges data with an email template. I have a mailing list review function that allows you to preview any of the emails. This works by calling a packaged merge function in a PL/SQL region as in:
    htp.p (package.merge_function (p1 => 1, p2 => 2, p3 => 3));
    The "merge_function" returns a CLOB which contains the complete HTML message.
    The problem is this: when the email is sent and received it looks fine, but when previewed as above the font size changes in the HTML are not recognised. The other attributes, e.g. colour and font face are OK. I am more experienced with PL/SQL than with HTML so any help would be appreciated.

    Rick,
    The CSS files that APEX uses set some default font settings for all regions. Unless overridden, these default settings will be applied to most everything on the page.
    If you're going to use an htp.p() to put some text on the page, you may want to consider wrapping the entire output of htp.p with a DIV tag.
    For instance:
    htp.p('<div style="font-size:12px;">' || your_contents || '</div>');Hope that helps!
    - Scott -

  • [SOLVED] Shuttle in PL SQL region (Apex 3.2)

    Hi OTN,
    Is there an option of creating shuttle element in PL SQL region?
    I need to have a dynamic number of those elements on my page.
    I have copied HTML code of a static apex shuttle (with Never condition) on this page, but no double clicks or buttons [<<] [>>] are working.
    Could someone help me cope with the problem?
    Thanks.
    Solved. Should have copied <field> and <script> after right select list also.
    Edited by: ILya Cyclone on Feb 18, 2011 2:26 PM

    You won't get a no-data-found exception in a cursor loop like that. You can do something like this:declare
      l_found boolean := false;
    begin
      for c in (select 1 from dual where 1=2) loop
        htp.p('never print this');
        l_found := true;
      end loop;
      if not l_found then
        htp.p('no rows selected in cursor loop');
      end if;
    end;Scott

  • PL/SQL Region : Getting values from PL/SQL generated form?  (APEX 2.2.0)

    Hi, all,
    If I've got an PL/SQL region that dynamically generates a form using HTMLDB_ITEM.TEXTAREA, what is the best way to get the contents of those form data at submit time?
    Thanks,
    Don
    Message was edited by:
    Don_84
    Edited for clarity.

    Don,
    The apex_item (nee htmldb_item) functions take an index number as a parameter. So if you give the textarea function p_idx=>1, it creates item f01. If you give it p_idx=>2, it creates item f02, etc. In your after-submit code, access the package variable apex_application.g_fxx where xx is the index number you used.
    Scott

  • Report Using PL/SQL Region

    Hi,
    I have bit experiment create custom reports using PL/SQL region
    http://dbswh.webhop.net/apex/f?p=BLOG:READ:0::::ARTICLE:97800346956448
    I would like have from you tips and ideas how enhance this.
    Because I'm not so good with SQL,
    I really appreciate if you have tips enhance performance for query used for cursor.
        /* Report query */
        l_sql := '
          SELECT * FROM(
            SELECT a.*, row_number() OVER (ORDER BY '
            || l_sort_col
            || ' '
            || l_sort_ord
            || ') rn, COUNT(1) over() mrn
            FROM(' || l_sql || ') a
          ) WHERE rn BETWEEN ' || l_start_row || ' AND ' || l_last_row
        ; Regards,
    Jari

    Hi Jari
    I'm guessing you're trying to do paginated grid data or somewthing similar? You could try something like this...
        l_sql := 'SELECT * '||
               'FROM ('||
                      'SELECT /*+ FIRST_ROWS(n) */ '||
                              'a.*, ROWNUM rnum '||
                       'FROM ('||l_sql||' '||
                              'ORDER BY '||l_sort||' '||l_dir||') a '||
                       'WHERE ROWNUM <= '||l_max_row||') '||
               'WHERE rnum >= '||l_start;The variables would be initialized in the procedure as follows...
        l_max_row := p_start + p_limit;
        l_start   := p_start + 1;
        l_sort    := NVL(p_sort,'1');
        l_dir     := NVL(p_dir, 'ASC');My application process would be called something like follows, to spit out a JSON object...
    BEGIN
      htp.p(wwv_flow.g_widget_num_return||'(');
      munky_extjs.grid_json(p_app_id => wwv_flow.g_x01,
                        p_app_page_id => wwv_flow.g_x02,
                        p_region_id => TO_NUMBER(wwv_flow.g_x03),
                        p_start => NVL(wwv_flow.g_x04,0),
                        p_limit => NVL(wwv_flow.g_x05,10),
                        p_sort => wwv_flow.g_x06,
                        p_dir => wwv_flow.g_x07);
      htp.p(')');
    END;I think your use of analytics in the inner query may be slowing you down if you have a lot of data?
    Cheers
    Ben

  • Which is better - SQL Statement in APEX or as a function returning a type?

    Hi
    I have a general question about best practices for APEX development.
    If we have say a report region based on a SQL statement, is it better (from a performance perspective) to have the SQL statement defined in the region in APEX OR have the actual select statement executed in the backend and have the result set returned in a type to APEX?
    As an example:
    In APEX region
    SELECT col1, col2, col3 FROM table_aOR
    In APEX region
    select col1, col2, col3 from TABLE(CAST(<my package>.<my proceduere > AS <my type >)) ;<my package>.<my proceduere > would obviously execute the statement
    SELECT col1, col2, col3 FROM table_ausing dynamic SQL and return the results to APEX in thy type <my type>.
    Apologies if this sounds to be a really stupid thing to ask.
    Kind regards
    Paul

    Denes Kubicek wrote:
    You should use a pipelined function only then when you can't use SQL. Otherwise SQL is the way to go.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    ------------------------------------------------------------------------------thanks Denes... but does it matter if:
    1. The SQL statement is actually defined in the APEX region
    or
    2: The select statement is stored in a packageD function and returned to APEX?
    I seem to recall an article I read stating that it is best for all client applications to call stored procedures and functions rather than have SQL statement embedded in the actual application?
    Kind regards
    Paul

  • How to process a form created in a pl/sql region

    Hi:
    I have a form that is generated using pl/sql and this form is displayed on a page in a 'pl/sql' region. The form displays a 'Submit' button which upon being clicked should return the user to the same page but with the contents of the form updated etc etc. What should I set the form's 'Action' attribute to for this to happen ? Is it possible for 'post-submit' processes to be specified for such a form ?
    Thanks !

    Vikas:
    The form is the product of converting a VB based application to pl/sql. The VB app. is a sort of a dynamic form generator. The form elements (what elements a form is made up of) are stored in a database. For the purpose of illustration we can assume that the application is a survey application and the VB code generates the required survey form depending on the user requesting the form, the survey being requested etc. The questions/answers and the HTML element that will be used to render the question/answer are stored in the database as mentioned previously.
    I adopted what I thought was the easiest method to convert this application into an APEX app. This method ofcourse being converting the VB to PL/SQL and then using the pl/sql Web Tool kit to generate a PL/SQL region on an APEX page.
    Now, based on your comments it appears to me that I may have started off on the wrong track !

  • Using APEX_ITEM in pl/sql region

     

    this is the apex pl/sql region code and the page process, when the page is submitted the process fires but doe snot recognize any of the apex application global arrays???
    {DECLARE
    CURSOR get_bank IS
    select C.form, C.form_description, C.form_details
    from form C
    where C.form_type = 'P' and
    NOT EXISTS
    (select ''
    from sis_user_portlet D
    where D.fk_sis_user_roles = :P0_LOGIN_ROLE and
    D.portlet_id = C.form)
    order by 2;
    BEGIN
    htp.tableOpen(cattributes=>'width="100%" border="0" cellspacing="0" cellpadding="2"');
    htp.tableRowOpen;
    htp.p('<td align="center" width="100%">');
    htp.p('<div class="WidgetBank">');
    FOR x in get_bank LOOP
    htp.p('<td nowrap>');
    htp.p('<div id="' || x.form || '" class="bank" ondblclick="moveToDashboard(this.id,this.className);" onmouseup="setPosition(this.id,this.className);">');
    htp.p(x.form_description);
    htp.p('<span id="'||x.form||'_span" style="display:none;">');
    htp.tableOpen;
    htp.tableRowOpen;
    htp.p('<td>');
    htp.p(APEX_ITEM.HIDDEN(P_IDX =>1,
    p_value =>'test',
    p_attributes =>'id="'||x.form||'_form"'));
    htp.p(APEX_ITEM.HIDDEN(P_IDX =>2,
    p_value =>'',
    p_attributes =>'id="'||x.form||'_x"'));
    htp.p(APEX_ITEM.HIDDEN(P_IDX =>3,
    p_value =>'',
    p_attributes =>'id="'||x.form||'_y"'));
    htp.p('Height:');
    htp.p(APEX_ITEM.TEXT(P_IDX =>4,
    p_value =>'',
    p_size =>5,
    p_maxlength =>4,
    p_attributes =>'id="'||x.form||'_height"
    onChange="setHeight(this.value,'||''''||x.form||''''||');"'));
    htp.p('</td>');
    htp.tableRowClose;
    htp.tableRowOpen;
    htp.p('<td>');
    htp.p('Width:');
    htp.p(APEX_ITEM.TEXT(P_IDX =>5,
    p_value =>'',
    p_size =>5,
    p_maxlength =>4,
    p_attributes =>'id="'||x.form||'_width"
    onChange="setWidth(this.value,'||''''||x.form||''''||');"'));
    htp.p('</td>');
    htp.tableRowClose;
    htp.tableClose;
    htp.p('</span>');
    htp.p('</div>');
    htp.p('</td>');
    END LOOP;
    htp.p('</div>');
    htp.p('</td>');
    htp.tableRowClose;
    htp.tableClose;
    END;
    DECLARE
    l_portlet_id sis_user_portlet.portlet_name%TYPE;
    l_x_position sis_user_portlet.x_position%TYPE;
    l_y_position sis_user_portlet.y_position%TYPE;
    l_width sis_user_portlet.width%TYPE;
    l_height sis_user_portlet.height%TYPE;
    get_pk sis_user_portlet.pk_id%TYPE;
    BEGIN
    FOR i in 1 .. wwv_flow.g_f01.COUNT LOOP
    --if apex_application.g_f01(i) is not null then null;
    get_pk := sis_express.get_sys_guid();
    l_portlet_id := wwv_flow.g_f01(i);
    l_x_position := wwv_flow.g_f02(i);
    l_y_position := wwv_flow.g_f03(i);
    l_height := wwv_flow.g_f04(i);
    l_width := wwv_flow.g_f05(i);
    insert into sis_user_portlet (pk_id, fk_sis_user_roles, portlet_id,
    x_position, y_position, width, height)
    values (get_pk, :P0_LOGIN_ROLE, l_portlet_id,
    l_x_position, l_y_position, l_width, l_height);
    --end if;
    END LOOP;
    commit;
    END;}
    Edited by: [email protected] on Nov 11, 2009 3:22 PM
    Edited by: [email protected] on Nov 11, 2009 3:23 PM

  • Upload File using decode in SQL Region...Help

    I am trying to allow a user to see the file names of files attached to a row (ex., training certificates for training taken). If there is no training certificate attached, "None (Upload Certificate)" is shown in that column as html. I want the user to be able to upload the certificate, by clicking on that html. I'm getting "Error ERR-1002 Unable to find item ID for item "TRAINING_ID" in application "113". ", when clicking on the link.
    Here is my code:
    select
    A.TRAINING_ID,
    A.TRAINING_ID TRAINING_ID_DISPLAY,
    A.PERSONNEL_ID,
    A.COURSE_ID,
    A.DATE_COMPLETED,
    A.CERTIFICATE_ID,
    B.IMAGE_ID,
    decode(b.filename, null, htf.anchor('f?p=113:1090:'||:APP_SESSION||'::NO::PERSONNEL_ID,TRAINING_ID:'||A.PERSONNEL_ID||'%2C'||A.TRAINING_ID, 'None (Upload Certificate)'),
    ''||&B.FILENAME||'') as cert_file_name,
    B.IMAGE_ID DELETE_CERTIFICATE
    from TRAINING A, EASY_IMAGE B
    WHERE A.PERSONNEL_ID = :P2_PERSONNEL_ID
    AND (A.PERSONNEL_ID = B.PERSONNEL_ID (+)
    AND A.TRAINING_ID = B.TRAINING_ID (+))
    The only thing that doesn't seem to be working correctly, is when the filename is null, the parameter's being passed and calling of the upload form. I've tested this in another app, but not being passed in the SQL Region and in both cases the status line at the bottom match for the call, when passing the mouse over the link. One works fine , but the decoded one gives me the error above.
    Any Help/Direction would be GREATLY Appreciated.
    Thanks in Advance!
    Juanita Layne

    We Got it......
    We changed the decode to this..
    decode(b.filename, null, htf.anchor('https://rockhopper.hqcnsg.navy.mil/apex/f?p=102:1090:&SESSION.::NO::PERSONNEL_ID,TRAINING_ID:'||A.PERSONNEL_ID||','||A.TRAINING_ID||':','None (Upload Certificate)'), ''||&B.FILENAME||'') as cert_file_name,
    and our 2 items
    PERSONNEL_ID and TRAINING_ID were setup as Database Items. We changed them to Static Assignments and passed #PERSONNEL_ID# and #TRAINING_ID# to those items respectively. It worked perfectly after that.
    Maybe that will help someone else.
    Thanks,
    Juanita

  • Render Dynamic PL/SQL region as PDF?

    Hi!
    I would like to be able to render a Dynamic PL/SQL region as a PDF. Anybody have an idea how to do this or even if it can be done? This is not a report region.
    Also any idea's on how I might do pagination in a dynamic PL/SQL region?
    Any hope that a future version of APEX will accept lines from a PL/SQL function (including anonymous ones) as the source of a report region? It would need to preserve blank lines. Currently only select statements are valid for generating APEX reports.
    Thanks in advance for your help!
    Dave Venus

    Scott,
    This is what is what debug mode puts out just before it issues the data not found error:
    0.07: ...Process "create collection": PLSQL (ON_SUBMIT_BEFORE_COMPUTATION) -- -- Create Collections -- -- declare la_cks apex_application_global.vc_arr2; begin if apex_application.g_f19.count > 0 then -- wwv_flow.debug('count gt 0 for checksum'); la_cks := apex_application.g_f19; else
    0.09: Encountered unhandled exception in process type PLSQL
    0.09: Show ERROR page...
    0.09: Performing rollback...
    I was hoping that the wwv_flow.debug statements would help me figure out where the error was occurring, but they did not produce anything so I commented them out. One thing that might be useful is that when I am not in debug mode and I click the OK link after the Oracle error message, the repainted screen still has the checkboxes that have been marked so I am guessing the error handler can see the data that I put into the .g_fnn arrays within my pl/sql region code.
    In other tabular forms within the same application, the create collection code starts the same way and I do not have any problems.
    One of the tests I did this morning was to replace my reference to the fcs array with f19 just in case there was something special being done for checksums, but the change had no effect.
    thanks,
    Peter

  • Dynamic PL/SQL Region

    Hi,
    i'm having some trouble with PL/SQL regions (or rather with function htp.p)...
    The first problem is: i want to allocate a variable with the current user and call this variable in htp.p.
    So i wrote:
    DECLARE
    BEGIN
    v_user := :P1_USER;
    HTP.p (v_user);
    END;
    Where P1_User is allocated with &APP_USER.
    But while starting the application, v_user seems to be empty (even though it isnt empty).
    Second problem: is it possible, to call page items in htp.p (like htp.p(&P1_USER.))? i didn't manage it...
    So i tried to create this items in HTML (a textfield and a button). But if i'm having these HTML-items, how do i call them in apex?
    It won't be :P1_ITEMNAME, will it?
    I hope both is understandable (my english and my problems)

    Thanks for your answers. But I'm still having some problems.
    In case of the 'user-example', it works just fine.
    But my second problem isn't solved.
    I'm creating a HTML-table via htp.p.
    But in this table, I want to place a textfield and a button (for searching).
    How could I place this items as objects (not only their value) in this table?
    I tried it with htp.p(V('P1_BUTTON')), but this doesn't work.
    @Dimitri
    Why would you use the :ITEM notation wherever possible?
    (i'm new to apex, so, sorry for this question)
    Message was edited by:
    DFiles

  • Reading a value from PL/SQL region

    Hello,
    I hope to receive help from you!
    I have a PL/SQL dynamic region in which I create several items using htmldb_item.text function.
    e.g.
    htp.p(htmldb_item.text(1,'AAA',40,2000));
    Then I want to read the values of these items from another PL/SQL region. If I write
    htp.p(htmldb_application.g_f01(1));
    I get an error.
    If I try to read the value of an item from an After Submit Process, everything is OK.
    Is it possible to receive a value of an item in a PL/SQL region?
    Thanks,
    Nadja

    The other PL/SQL region should read the information from the source (table or view). If I understand your right, you are trying to "read" the information from your first PL/SQL block on load?
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • How to create dynamic HTML page using PL/SQL code in APEX.

    hello,
    I am woking on one APEX application in which i want to create one dynamic HTML page on button press using PL/SQL code.
    Thanks

    It is possible to create HTML page with dynamic content. One way would be creating hidden field (e.g. P1_HTML on page 1) with dynamic HTML and on button click you redirect to page 2 and pass P1_HTML item value to item P2_HTML on page 2. On page you must have PL/SQL region. You can then render your dynamic HTML with code:
    htp.p(:P2_HTML);
    Don use APEX URL for passing HTML value. Problem and solution is described here: http://blog.trent-schafer.com/2011/04/03/dont-pass-string-parameters-in-the-url-in-apex-its-a-bad-idea/
    Edited by: MiroMas on 3.2.2012 3:20

  • Is there a character limit on PL/SQL region code?

    Hi,
    We are moving a app from the Oracle apex site (10g) to our apex environment (9.2) and when I open a Dynamic PL/SQL region on a page, add a space to the declaration area just to cause it to be different, I try and save it and it goes to:
    "The webpage cannot be found"
    This happened at another job and I believe it was a environment setting to extend the character limit ability.???
    If so, what do I change and how do I change it?
    If not, any ideas?
    Thank you, Bill

    Hello Bill,
    >> … to our apex environment (9.2)
    The following might give you some more information on your possible situation -
    Re: Is there a maximum number of characters allowed in PL/SQL Anonymous Blo
    ORA-06550 recieved when trying to modify existing page after 3.1 Apex upg
    Regards,
    Arie.

Maybe you are looking for