REPLACE Function or plsql function

Hi,
I have the following tables:
persons p
id
name
surname
emails e
emid
subject
sender
html_body
text_body
cods c
id --> fk on persons(id)
emid --> fk on emails(emid)
cod1
cod2
cod3
In the fields html_body and text_body I have some parameters that should be replaced dinamically.
These fields are:
NAME
SURNAME
COD1
COD2
COD3
I should replace those fields dinamically with the fields of tables persons and cods.
I have a procedure and inside I have a cursor like:
FOR cur IN (SELECT e.sender, e.subject,
REPLACE
(REPLACE
(REPLACE
(REPLACE(e.html_body,'_NAME_',p.name)
,'_SURNAME_',p.surname)
,'_COD1_',c.cod1)
,'_COD2_',c.cod2) AS html_text,
REPLACE
(REPLACE
(REPLACE
(REPLACE(e.text_body,'_NAME_',p.name)
,'_SURNAME_',p.surname)
,'_COD1_',c.cod1)
,'_COD2_',c.cod2) AS
text_text
FROM
person p,
emails e,
cods c
WHERE p.id=c.id
AND e.emid=c.emid)
LOOP
send email here
do some inesrts....
What I want to do is replace all those "REPLACE" statements with some function.
Does this have sense or doing it like this, even if it's confusing, is more correct and performaning?
Thanks in advance
Tarek

Perhaps I'm missing something... Why not just
CREATE FUNCTION html_text_func( body IN VARCHAR2,
                                name IN VARCHAR2,
                                surname IN VARCHAR2,
                                cod1 IN VARCHAR2,
                                cod2 IN VARCHAR2 )
  RETURN VARCHAR2
AS
BEGIN
  <<nested REPLACE>>
END;
CREATE FUNCTION text_text_func( body IN VARCHAR2,
                                name IN VARCHAR2,
                                surname IN VARCHAR2,
                                cod1 IN VARCHAR2,
                                cod2 IN VARCHAR2 )
  RETURN VARCHAR2
AS
BEGIN
  <<nested replace>>
END;
FOR x IN (SELECT e.sender,
                 e.subject,
                 html_text_func( e.html_body,
                                 p.name,
                                 p.surname,
                                 c.cod1,
                                 c.cod2 ) html_text,
                 text_text_func( e.text_body,
                                 p.name,
                                 p.surname,
                                 c.cod1,
                                 c.cod2 ) text_text,
            FROM person p,
                 emails e,
                 cods c
           WHERE p.id=c.id
             AND e.emid=c.emid)
LOOP
...Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC

Similar Messages

  • How to replace/create the changes made in plsql function that is in package

    My problem here is that,
    There is a sql file , contains package,In that package there are more functions .I had made changes in one function body.I want it to be created with changes made in that package without effecting remaining functions.
    Here is my file
    CREATE OR REPLACE PACKAGE i2_pack_match IS
    -- Function to check whether date conditions are met or not
    FUNCTION fn_check_date(pd_sn_earliest_start_dt IN i2_sn_details.earliest_start_date%TYPE,
    pd_sn_latest_end_dt IN i2_sn_details.latest_end_date%TYPE,
    pn_sn_min_duration IN i2_sn_details.minimum_duration_weeks%TYPE,
    pd_tn_earliest_start_dt IN i2_tn_details.earliest_start_date%TYPE,
    pd_tn_latest_end_dt IN i2_tn_details.latest_end_date%TYPE,
    pn_tn_min_duration IN i2_tn_details.minimum_duration_weeks%TYPE,
    pn_date_margin IN NUMBER)
    RETURN BOOLEAN;
    FUNCTION fn_check_degree(ps_sn_degree IN i2_sn_details.degree%TYPE,
    ps_tn_degree IN i2_tn_details.degree%TYPE)
    RETURN BOOLEAN;/
    show errors
    PROMPT Creating Package Body PACK_MATCH ...
    CREATE OR REPLACE PACKAGE BODY i2_pack_match IS
    FUNCTION fn_check_date(pd_sn_earliest_start_dt IN i2_sn_details.earliest_start_date%TYPE,
    pd_sn_latest_end_dt IN i2_sn_details.latest_end_date%TYPE,
    pn_sn_min_duration IN i2_sn_details.minimum_duration_weeks%TYPE,
    pd_tn_earliest_start_dt IN i2_tn_details.earliest_start_date%TYPE,
    pd_tn_latest_end_dt IN i2_tn_details.latest_end_date%TYPE,
    pn_tn_min_duration IN i2_tn_details.minimum_duration_weeks%TYPE,
    pn_date_margin IN NUMBER)
    RETURN BOOLEAN IS
    lb_ok BOOLEAN := TRUE;
    ld_sn_latest_start_date DATE;
    ld_tn_latest_start_date DATE;
    BEGIN
    ld_sn_latest_start_date := pd_sn_latest_end_dt - (pn_sn_min_duration * 7) +
    pn_date_margin;
    ld_tn_latest_start_date := pd_tn_latest_end_dt - (pn_tn_min_duration * 7) +
    pn_date_margin;
    IF (pd_tn_earliest_start_dt > ld_sn_latest_start_date) OR
    (ld_tn_latest_start_date < pd_sn_earliest_start_dt) THEN
    --dbms_output.put_line('Date condition failed');
    lb_ok := FALSE;
    END IF;
    RETURN lb_ok;
    END;
    FUNCTION fn_check_degree(ps_sn_degree IN i2_sn_details.degree%TYPE,
    ps_tn_degree IN i2_tn_details.degree%TYPE)
    RETURN BOOLEAN IS
    lb_ok BOOLEAN := TRUE;
    BEGIN
    Vijaya-341-----Get the ALL count data equal to sum of Undergraduate,Bachelor and Masters count----------------------
    IF ps_tn_degree != -1 THEN
    IF ps_sn_degree = 75 THEN
    IF ps_tn_degree > 0 AND ps_sn_degree > 0 AND ps_tn_degree = ps_sn_degree THEN
    --dbms_output.put_line('Degree condition failed');
    lb_ok := TRUE;
    END IF;
    ELSIF ps_sn_degree = 50 THEN
    IF ps_tn_degree > 0 AND ps_sn_degree > 0 AND ps_tn_degree = ps_sn_degree THEN
    lb_ok := TRUE;
    END IF;
    ELSIF ps_sn_degree = 25 THEN
    IF ps_tn_degree > 0 AND ps_sn_degree > 0 AND ps_tn_degree = ps_sn_degree THEN
    lb_ok := TRUE;
    END IF;
    END IF;
    ELSIF (ps_tn_degree = -1) AND (ps_sn_degree = 50 OR ps_sn_degree = 25 OR ps_sn_degree = 75) THEN
    lb_ok := TRUE;
    END IF;
    Vijaya-341---------------------------------------END-------------------------
    RETURN lb_ok;
    END;
    END;
    show errors
    i made changes in function fn_check_degree.
    How can i create in oracle ?Plz any one help me.

    You need to get that revised code into the database - what you are doing with the 'alter package' command is simply recompiling what is already in the database (not your new code).
    In SQL*Plus:
    sql>@c:\myfile.sqlwhere c:\myfile.sql is the name of the file.
    Running this script will then replace the code stored in the database with the new code from your file.

  • Equivalent of JavaScript escape function in PLSQL

    Hi,
    Is there any equivalent of JavaScript's "escape()" function in PlSql for web development? cos I found that whenever I have links generated in stored procedure with text that has space, single quote and so on will become invalid url syntax when user clicks on the hyperlink.
    So I hope to convert the text to valid syntax while generating the link.
    Please advise.
    Thank you so much.

    Hi,
    CREATE OR REPLACE FUNCTION UNESCAPE_F
    (P_TEXT IN VARCHAR2 := null) RETURN VARCHAR2 IS
    V_HEX2 VARCHAR2(1);
    V_CHAR VARCHAR2(1);
    V_TEXT VARCHAR2(4000);
    V_RETURN VARCHAR2(4000) := NULL;
    V_HEX1 VARCHAR2(1);
    BEGIN
    IF p_text IS NULL THEN
    v_return := NULL;
    ELSE
    v_text := p_text;
    WHILE INSTR(v_text, '%') > 0 LOOP
    v_return := v_return &#0124; &#0124; SUBSTR(v_text, 1, INSTR(v_text, '%') - 1);
    v_text := SUBSTR(v_text, INSTR(v_text, '%') + 1);
    v_hex1 := SUBSTR(v_text, 1, 1);
    v_hex2 := SUBSTR(v_text, 2, 1);
    v_text := SUBSTR(v_text, 3);
    SELECT
    CHR(
    (DECODE(v_hex1,'0',0,'1',1,'2',2,'3',3,'4',4,'5',5,'6',6,'7',7,'8',8,'9',9,'A',10,'B',11,'C',12,'D',13,'E',14,'F',15,0) * 16) +
    DECODE(v_hex2,'0',0,'1',1,'2',2,'3',3,'4',4,'5',5,'6',6,'7',7,'8',8,'9',9,'A',10,'B',11,'C',12,'D',13,'E',14,'F',15,0) )
    INTO v_char
    FROM dual;
    v_return := v_return &#0124; &#0124; v_char;
    END LOOP;
    v_return := v_return &#0124; &#0124; v_text;
    END IF;
    RETURN(v_return);
    END UNESCAPE_F;
    Regards Michael

  • Is this plsql function considered ok?

    Is this plsql function considered ok?  The reason I am asking is because the results differ when called inside of a package vs calling inside of a procedure.  I am not sure if this is a bug or if it is illegal.
    CREATE OR REPLACE package body test as
    function test return varchar2 is
    begin
    htp.prn('ABCDEF');
    return 'xyz';
    end;
    end;
    When this function is called inside of a package, the string 'ABCDEF' is displayed out of sequence.   I think it is due to 11g inlining the function at compile time.
    Whereas, when the function is called inside of a procedure the string 'ABCDEF' appears in the browser's html correctly.
    Technically the function is doing procedural stuff by output htp.prn data, so Oracle may considered it illegal.  I have a very good reason for wanting this functionality, so before taking another approach I wanted to ask around.

    brian.mcginity wrote:
    'Out of sequence' is a bit vague...sorry.   I probably could create a calling package and procedure which shows the problem.  The place where this is happening in production code is in the middle of a bunch of unrelated business logic.
    Let me try to explain before going down the route of writing a test case.
    The function:
    CREATE OR REPLACE package body test as
    function test return varchar2 is
    begin
    htp.prn('!!!! inside of function !!!!');
    return null;
    end;
    end;
    This is how function is used in a different package:
    htp.p('This is line 1');
    if true then    
         open q for select * from dual;
    end if;
    htp.p('This is line 2.  '||  test.test() ' ||'<br>')
    htp.p('This is line 3');
    So the expected output when you view source in the browser should be:
    This is line 1
    This is line 2 !!! inside of function !!!! !!!! inside of function !!!!!!!! inside of function !!!!
    This is line 3
    However when this code is run inside of a package the output is out of sequence:
    This is line 1
    !!! inside of function !!!!
    This is line 2
    This is line 3
    No, what you're expecting as output is not what I would expect as output.  I would expect the output that you are considering to be 'out of sequence'.
    If you want the first output then your test function should simply be...
    function test return varchar2 is
    begin
      return '!!!! inside of function !!!!';
    end;
    so that it's not writing to the HTP buffer. (as Billy explained in his reply)
    Now take the exact same code block and run it inside of a stand alone procedure:
    htp.p('This is line 1');
    if true then    
         open q for select * from dual;
    end if;
    htp.p('This is line 2.  '||  test.test() ' ||'<br>')
    htp.p('This is line 3');
    and the output is correct:
    This is line 1
    This is line 2 !!! inside of function !!!! !!!! inside of function !!!!!!!! inside of function !!!!
    This is line 3
    When the function is placed inside of a package, the results are different than when inside of a stand alone procedure.  I have a handful of procedure which was calling test.test() and all was working fine.  Then one day when I called test.test() from a package, the output was jumbled.  I narrowed down the problem and quickly created a procedure which did the same thing as test.test() and it fixed the problem.  I still would have liked to use the function version if possible (long story why--don't really want to go into details).
    If that's a difference you're getting between executing the function through a procedure and a package, then there must be something you're not showing us.  There's no good reason for the function to act differently depending on it being in a procedure or packaged.
    You're going to have to provide a reproducable test for people to see exactly what the issue is, because what you've posted cannot be reproduced.

  • Error while trying to access a SSWA PLSQL function

    Hi,
    I am trying to access a report as a web page by defining the function as follows :
    Type : SSWA PLSQL FUNCTION
    HTML Call : OracleOASIS.RunReport
    Parameters : report=EMPDET
    This function is attached to the menu and when I try to access the page I get this error.
    "Error: The requested URL was not found, or cannot be served at this time.
    Incorrect usage."
    The URL that shows in the page is as follows(<server:port> I removed the server name and port) :
    http://<server:port>/dev60cgi/rwcgi60?GDEV_APPS+DESFORMAT=HTML+SERVER=GDEV_APPS+report=EMPDET+p_session_id=A9C71A70B9B1D9BD2DCC0FC3AF9BC324+p_user_id=1133+p_responsibility_id=50230+p_application_id=800+p_security_group_id=0+p_language_code=US+NLS_LANG=AMERICAN_AMERICA+NLS_DATE_FORMAT=DD-MON-RRRR+NLS_NUMERIC_CHARACTERS=.%2C+NLS_DATE_LANGUAGE=AMERICAN+NLS_SORT=BINARY+paramform=NO
    Surprisingly other functions which are defined in this manner work fine. Do I need to register my report anywhere or are there any other settings I need to do for the report to show up.
    Can someone let me know.
    Thanks

    Hi ;
    pelase check below which could be similar error like yours
    Troubleshooting of Runtime Errors of Customer Intelligence Reports [ID 284829.1]
    Regard
    Helios

  • A replacement for the Quicksort function in the C++ library

    Hi every one,
    I'd like to introduce and share a new Triple State Quicksort algorithm which was the result of my research in sorting algorithms during the last few years. The new algorithm reduces the number of swaps to about two thirds (2/3) of classical Quicksort. A multitude
    of other improvements are implemented. Test results against the std::sort() function shows an average of 43% improvement in speed throughout various input array types. It does this by trading space for performance at the price of n/2 temporary extra spaces.
    The extra space is allocated automatically and efficiently in a way that reduces memory fragmentation and optimizes performance.
    Triple State Algorithm
    The classical way of doing Quicksort is as follows:
    - Choose one element p. Called pivot. Try to make it close to the median.
    - Divide the array into two parts. A lower (left) part that is all less than p. And a higher (right) part that is all greater than p.
    - Recursively sort the left and right parts using the same method above.
    - Stop recursion when a part reaches a size that can be trivially sorted.
     The difference between the various implementations is in how they choose the pivot p, and where equal elements to the pivot are placed. There are several schemes as follows:
    [ <=p | ? | >=p ]
    [ <p | >=p | ? ]
    [ <=p | =p | ? | >p ]
    [ =p | <p | ? | >p ]  Then swap = part to middle at the end
    [ =p | <p | ? | >p | =p ]  Then swap = parts to middle at the end
    Where the goal (or the ideal goal) of the above schemes (at the end of a recursive stage) is to reach the following:
    [ <p | =p | >p ]
    The above would allow exclusion of the =p part from further recursive calls thus reducing the number of comparisons. However, there is a difficulty in reaching the above scheme with minimal swaps. All previous implementation of Quicksort could not immediately
    put =p elements in the middle using minimal swaps, first because p might not be in the perfect middle (i.e. median), second because we don’t know how many elements are in the =p part until we finish the current recursive stage.
    The new Triple State method first enters a monitoring state 1 while comparing and swapping. Elements equal to p are immediately copied to the middle if they are not already there, following this scheme:
    [ <p | ? | =p | ? | >p ]
    Then when either the left (<p) part or the right (>p) part meet the middle (=p) part, the algorithm will jump to one of two specialized states. One state handles the case for a relatively small =p part. And the other state handles the case for a relatively
    large =p part. This method adapts to the nature of the input array better than the ordinary classical Quicksort.
    Further reducing number of swaps
    A typical quicksort loop scans from left, then scans from right. Then swaps. As follows:
    while (l<=r)
    while (ar[l]<p)
    l++;
    while (ar[r]>p)
    r--;
    if (l<r)
    { Swap(ar[l],ar[r]);
    l++; r--;
    else if (l==r)
    { l++; r--; break;
    The Swap macro above does three copy operations:
    Temp=ar[l]; ar[l]=ar[r]; ar[r]=temp;
    There exists another method that will almost eliminate the need for that third temporary variable copy operation. By copying only the first ar[r] that is less than or equal to p, to the temp variable, we create an empty space in the array. Then we proceed scanning
    from left to find the first ar[l] that is greater than or equal to p. Then copy ar[r]=ar[l]. Now the empty space is at ar[l]. We scan from right again then copy ar[l]=ar[r] and continue as such. As long as the temp variable hasn’t been copied back to the array,
    the empty space will remain there juggling left and right. The following code snippet explains.
    // Pre-scan from the right
    while (ar[r]>p)
    r--;
    temp = ar[r];
    // Main loop
    while (l<r)
    while (l<r && ar[l]<p)
    l++;
    if (l<r) ar[r--] = ar[l];
    while (l<r && ar[r]>p)
    r--;
    if (l<r) ar[l++] = ar[r];
    // After loop finishes, copy temp to left side
    ar[r] = temp; l++;
    if (temp==p) r--;
    (For simplicity, the code above does not handle equal values efficiently. Refer to the complete code for the elaborate version).
    This method is not new, a similar method has been used before (read: http://www.azillionmonkeys.com/qed/sort.html)
    However it has a negative side effect on some common cases like nearly sorted or nearly reversed arrays causing undesirable shifting that renders it less efficient in those cases. However, when used with the Triple State algorithm combined with further common
    cases handling, it eventually proves more efficient than the classical swapping approach.
    Run time tests
    Here are some test results, done on an i5 2.9Ghz with 6Gb of RAM. Sorting a random array of integers. Each test is repeated 5000 times. Times shown in milliseconds.
    size std::sort() Triple State QuickSort
    5000 2039 1609
    6000 2412 1900
    7000 2733 2220
    8000 2993 2484
    9000 3361 2778
    10000 3591 3093
    It gets even faster when used with other types of input or when the size of each element is large. The following test is done for random large arrays of up to 1000000 elements where each element size is 56 bytes. Test is repeated 25 times.
    size std::sort() Triple State QuickSort
    100000 1607 424
    200000 3165 845
    300000 4534 1287
    400000 6461 1700
    500000 7668 2123
    600000 9794 2548
    700000 10745 3001
    800000 12343 3425
    900000 13790 3865
    1000000 15663 4348
    Further extensive tests has been done following Jon Bentley’s framework of tests for the following input array types:
    sawtooth: ar[i] = i % arange
    random: ar[i] = GenRand() % arange + 1
    stagger: ar[i] = (i* arange + i) % n
    plateau: ar[i] = min(i, arange)
    shuffle: ar[i] = rand()%arange? (j+=2): (k+=2)
    I also add the following two input types, just to add a little torture:
    Hill: ar[i] = min(i<(size>>1)? i:size-i,arange);
    Organ Pipes: (see full code for details)
    Where each case above is sorted then reordered in 6 deferent ways then sorted again after each reorder as follows:
    Sorted, reversed, front half reversed, back half reversed, dithered, fort.
    Note: GenRand() above is a certified random number generator based on Park-Miller method. This is to avoid any non-uniform behavior in C++ rand().
    The complete test results can be found here:
    http://solostuff.net/tsqsort/Tests_Percentage_Improvement_VC++.xls
    or:
    https://docs.google.com/spreadsheets/d/1wxNOAcuWT8CgFfaZzvjoX8x_WpusYQAlg0bXGWlLbzk/edit?usp=sharing
    Theoretical Analysis
    A Classical Quicksort algorithm performs less than 2n*ln(n) comparisons on the average (check JACEK CICHON’s paper) and less than 0.333n*ln(n) swaps on the average (check Wild and Nebel’s paper). Triple state will perform about the same number of comparisons
    but with less swaps of about 0.222n*ln(n) in theory. In practice however, Triple State Quicksort will perform even less comparisons in large arrays because of a new 5 stage pivot selection algorithm that is used. Here is the detailed theoretical analysis:
    http://solostuff.net/tsqsort/Asymptotic_analysis_of_Triple_State_Quicksort.pdf
    Using SSE2 instruction set
    SSE2 uses the 128bit sized XMM registers that can do memory copy operations in parallel since there are 8 registers of them. SSE2 is primarily used in speeding up copying large memory blocks in real-time graphics demanding applications.
    In order to use SSE2, copied memory blocks have to be 16byte aligned. Triple State Quicksort will automatically detect if element size and the array starting address are 16byte aligned and if so, will switch to using SSE2 instructions for extra speedup. This
    decision is made only once when the function is called so it has minor overhead.
    Few other notes
    - The standard C++ sorting function in almost all platforms religiously takes a “call back pointer” to a comparison function that the user/programmer provides. This is obviously for flexibility and to allow closed sourced libraries. Triple State
    defaults to using a call back function. However, call back functions have bad overhead when called millions of times. Using inline/operator or macro based comparisons will greatly improve performance. An improvement of about 30% to 40% can be expected. Thus,
    I seriously advise against using a call back function when ever possible. You can disable the call back function in my code by #undefining CALL_BACK precompiler directive.
    - Like most other efficient implementations, Triple State switches to insertion sort for tiny arrays, whenever the size of a sub-part of the array is less than TINY_THRESH directive. This threshold is empirically chosen. I set it to 15. Increasing this
    threshold will improve the speed when sorting nearly sorted and reversed arrays, or arrays that are concatenations of both cases (which are common). But will slow down sorting random or other types of arrays. To remedy this, I provide a dual threshold method
    that can be enabled by #defining DUAL_THRESH directive. Once enabled, another threshold TINY_THRESH2 will be used which should be set lower than TINY_THRESH. I set it to 9. The algorithm is able to “guess” if the array or sub part of the array is already sorted
    or reversed, and if so will use TINY_THRESH as it’s threshold, otherwise it will use the smaller threshold TINY_THRESH2. Notice that the “guessing” here is NOT fool proof, it can miss. So set both thresholds wisely.
    - You can #define the RANDOM_SAMPLES precompiler directive to add randomness to the pivoting system to lower the chances of the worst case happening at a minor performance hit.
    -When element size is very large (320 bytes or more). The function/algorithm uses a new “late swapping” method. This will auto create an internal array of pointers, sort the pointers array, then swap the original array elements to sorted order using minimal
    swaps for a maximum of n/2 swaps. You can change the 320 bytes threshold with the LATE_SWAP_THRESH directive.
    - The function provided here is optimized to the bone for performance. It is one monolithic piece of complex code that is ugly, and almost unreadable. Sorry about that, but inorder to achieve improved speed, I had to ignore common and good coding standards
    a little. I don’t advise anyone to code like this, and I my self don’t. This is really a special case for sorting only. So please don’t trip if you see weird code, most of it have a good reason.
    Finally, I would like to present the new function to Microsoft and the community for further investigation and possibly, inclusion in VC++ or any C++ library as a replacement for the sorting function.
    You can find the complete VC++ project/code along with a minimal test program here:
    http://solostuff.net/tsqsort/
    Important: To fairly compare two sorting functions, both should either use or NOT use a call back function. If one uses and another doesn’t, then you will get unfair results, the one that doesn’t use a call back function will most likely win no matter how bad
    it is!!
    Ammar Muqaddas

    Thanks for your interest.
    Excuse my ignorance as I'm not sure what you meant by "1 of 5" optimization. Did you mean median of 5 ?
    Regarding swapping pointers, yes it is common sense and rather common among programmers to swap pointers instead of swapping large data types, at the small price of indirect access to the actual data through the pointers.
    However, there is a rather unobvious and quite terrible side effect of using this trick. After the pointer array is sorted, sequential (sorted) access to the actual data throughout the remaining of the program will suffer heavily because of cache misses.
    Memory is being accessed randomly because the pointers still point to the unsorted data causing many many cache misses, which will render the program itself slow, although the sort was fast!!.
    Multi-threaded qsort is a good idea in principle and easy to implement obviously because qsort itself is recursive. The thing is Multi-threaded qsort is actually just stealing CPU time from other cores that might be busy running other apps, this might slow
    down other apps, which might not be ideal for servers. The thing researchers usually try to do is to do the improvement in the algorithm it self.
    I Will try to look at your sorting code, lets see if I can compile it.

  • How can I call a plsql function from an attribute?

    I have an attribute defined in an element. I want execute a PLSQL function from the attribute, and display the returne value with an HTML template.
    I've defined the attribute's type like PLSQL, and I've put the called of the function in the value of the attribute, but it doesn't work. The only value I obtain is an URL (I think that is the URL of the function or someting like this).
    How can I call to my function from the attribute and display the returnes value in the page?
    Thanks.

    Thanks, but it doesn't work. I have an attribute called ID_BOL and I want to associate a sequence to that attribute. I've created a function, with the sequence. This function return de value of the sequence. I want taht the attribute takes the value of the sequenece dinamically.
    I've tried it, creating the type attribute like PLSQL, and calling the function from the attribute, but it doesn't work.
    How can I return the sequence value to my attribute?
    Thanks.

  • Lack of flexibility in the format PLSQL functionality

    Hi,
    Is there any plans to increase the functionality of the format PLSQL function? Compared to TOAD, it is extremely limited. The TOAD formatter alone is enough to keep our organization from switching to SQL Developer.
    Darryl

    You got that in bold: it's announced on this forum and on sqldev's homepage... http://htmldb.oracle.com/pls/otn/f?p=42626:37:260789750723810::NO:::

  • How to create SSWA plsql function in Oracle Apps of HTML call .html

    Hello Team,
    I am working on Oracle Apps 11i (11.5.10.2)
    I want to know , what is the process to create a , "SSWA plsql function" in Oracle Apps of type "HTML" and html call tab.
    How to create that Function and how to attach the PL/SQL code to these functions.
    How it works.
    Please help me to understand this concept from basics.
    Kind Regards

    Hi;
    Please review:
    how to setup a forms function in R12 to launch an URL?
    http://www.trutek.com/serendipity/index.php?/archives/15-An-Example-of-How-to-Create-Custom-Functions,-Menus,-and-Responsibilities.html
    Regard
    Helios

  • How to register database plsql function in obiee

    Hi,
    I've a database plsql function which accepts two date arguments - StartDate and EndDate and return Integer.
    I discoverer like we've Plsql function registration tool, where we import function and pass parameter values as arguments in report- how same can be done in Oracle BI Administration tool and BI Answers?
    I tried to create logical column as
    EVALUATE('YOUR_FUNCTION(%1, %2, %3, %4)' as varchar(20),@{p_1},@{p_2},@{p_3},@{p_4})
    it is giving syntax error.
    url: How to store OBIEE presentation level variable values in DB
    Please help. It is really urgent.
    Kind Regards.

    Hi,
    I created 2 session variables p_startym and p_endym of char datatype and called in function(name: RepInitDates). It looks like:
    EVALUATE('INIT_DATES_MONID(%1, %2)' AS INTEGER , VALUEOF(NQ_SESSION."p_startym"), VALUEOF(NQ_SESSION."p_endym")).
    Now I've presentation variables StartMonth and EndMonth in bi answers report, whose value i want to pass to p_startym and p_endym. What should be the syntax of Bi answers column? Please reply.
    Thanks

  • Error in plsql function

    Hi Friends,
    I have the below plsql function which is throwing error.
    The below function is written in Apex, so kindly let me know ow to resolve this error
    The below query checks the existing value and if null assigns a value by select statement. else will assign it back to the variable.
    Function:
    BEGIN
    IF
    :P1_VARIABLE_NAME IS NULL THEN :P1_VARIABLE_NAME:=select .... from .... (which returns a string value)
    ELSE
    :P1_VARIABLE_NAME
    END
    END
    Error:
    Encountered the symbol "SELECT" when expecting one of the following: ( - + case mod new not null avg count current exists max min prior sql stddev sum variance execute forall merge time timestamp interval date pipe

    Pradeep wrote:
    No I am creating a PLSQL function body option to write the above query. Is there a way in apex to dynamically bind the valueApex function bodies support bind variables. For example, you can set the rendering condition of an Apex region to a function body and code it as follows:
    if :P1_SOMEVAR = MySchema.MyFunction( :P1_SOME_OTHERVAR ) then
      return( true );
    else
      return( false );
    end if;Where the bind variables used are standard Apex page item (variables).
    I also suggest that if your questions are Apex related and not specifically PL/SQL and SQL language related, you rather ask your questions in the OTN Apex forum and not here.

  • Problem in Importing PLSQL functions

    Dear Friends,
    I am facing a problem in Importing the PLSQL functions which i have created, Please refer to the following steps :
    1) I created the function and gave execute grants to EUL_US .
    2) I tried to import the function from Discoverer administrator, but i am unable to find the function in the list.
    Please advice wethere i missed any step..
    Thanks in advance
    Raj

    Hi
    Yes, i tried that. Please verify the following steps i did:
    1) created <mypack.myfunc> under apps user
    2) Grant all on <mypack.myfunc> to EUL_US with grant option;
    It contains two parameters :- id number, as_on_date date
    I tried to import in Discoverer admin, but i couldn't find it. Then i tried to register manually, i gave all options correctly, but it says invalid function.
    Did i miss any thing any where??
    Please help
    Thanks
    Raj

  • Unexpected problem with authorization scheme of type plsql function

    Hi,
    I have created one authorization scheme of type plsql function returning boolean. Authorization scheme is for pages only. p2_user_priviledge is a textbox on home page which extract privilege (list of pagenos) for login user from database. Home page has no authorization required. AUTHORIZATION SCHEME always returns false. I am not able to trace problem in my code. same code works fine for a textbox's default returning 'c'.
    ----- CODE FOR AUTHORIZATION SCHEME------------------------------------------------------------
    declare
    pageid varchar2(10);
    privilege varchar2(300);
    c number(3);
    begin
    pageid := ':P'||to_char(:app_page_id)||':' ; ---Pageno get stored in format  *:P2:*
    privilege := trim(:p2_user_priviledge); ++------Contain list of privilege like    :P2:P13:P67:P23:  etc+++ select instr(privilege,pageid) into c from dual;
    if c>0 then
    return true;
    else
    return false;
    end if;
    end;
    One more problem is again related to authorization scheme.
    I created one application and one authorization scheme (auth_aug) which worked finely. Then after some days i added 10 more pages to same application, But now autho_aug was always returning false for new pages. So i copied code from 'autho_aug' to new scheme 'autho_sept', & it worked for new pages. I don't understand if code is same for both scheme, why required to use two different schemes.
    Now i have added few more pages to application, and facing problem mentioned earlier.
    any solution for both the problems.....

    Hi,
    Let me clear my problem once again.
    -->Home page i.e. P2 does not use authorization, So it is displayed along with text item :p2_user_privilege.
    -->Then user click on one of the links , Now page :P70: should get displayed.
    P70 is using authorization scheme.
    -->But :p2_user_priviledge value is not accessible at authorization scheme, I dont know why.
    I could not find out where to create Application item , as suggested by you.
    & not able to find Developer menu , session at home page as suggested earlier.
    And one more question, my application at runtime display
    X en us
    at bottom
    How to make it
    USER: X Language: en us
    Like in development environment.
    Hope I have cleared my problem, waiting for reply.
    Edited by: TEJU on Nov 17, 2008 9:25 AM

  • Call plsql function from esb-xsl mapping

    Hi
    I want to call a plsql function that takes an inparameter from an xsl mapping file.
    I tried to use the orcl:query-database function for this, but i couldn't get it to work when I wanted to dynamically pass the value of the inparameter to the function taken from the XML file used as input in the xsl transformation:
    If I hardcode the parameter value like this, it works fine:
    orcl:query-database('select emx_parameters.get_parameter_value('DEADLINE') result from dual',false(),false(),'jdbc/DB')
    But if i dynamically want to assign the inparameter, it doesn't work for me:
    orcl:query-database('select emx_parameters.get_parameter_value('/Header/ParameterName') result from dual',false(),false(),'jdbc/DB')
    Maybe it has something to do with the ' signs, but I tried a lot of combinations it nothing worked for me.
    Has anyone any ideas how to do this?
    Thanks
    Kalle

    Hi
    If anyone is interested i managed to solve it this way:
    I build up the sql query string with xsl variables like this:
    <xsl:variable name="start">select emx_parameters.get_parameter_value('</xsl:variable>
    <xsl:variable name="param" select='/Header/ParameterName'/>
    <xsl:variable name="end">') result from dual</xsl:variable>
    <xsl:variable name="expr" select="concat($start,$param,$end)"/>
    And then I called the orcl:query-database method with the variable as in-parameter.
    orcl:query-database($expr,false(),false(),"jdbc/DB")
    Maybe there is another way, but this worked for me.
    //Kalle

  • Please suggest solutiion for calling a plsql function in report

    Hi,
    I did a small project using forms and reports 6i. Now i prepared a repor that will calucalate the sum(expenditure)per report level. Now the problem is i want to print the sum which is in number form , in words. That is if the sum is 50000 then i want to print "fifty thousand". For this conversion from number to figure i wrote a small programme , which successfully compiled and created a function.
    Now I want to create a field in the report and in which I want to call this plsql function and perform the number conversion of sum(expenditure)per report field. Please describe in detail how to make reference between these two fields i.e sum(expenditure)per report and field in which I want to run plsql code and thereby converting the sum into figures.
    the programme i used to convert currency from number to words is please see link.http:/orafaq.com/scripts/cheqprint.txt
    Thanks in advance
    Prasanth a.s.

    Hi,
    If the amount does not exceed more than 5,373,484 then you can use the following method to print the number in words.
    Test Db>Select to_char( to_date(5373484,'J'),'Jsp') from dual ;
    TO_CHAR(TO_DATE(5373484,'J'),'JSP')
    Five Million Three Hundred Seventy-Three Thousand Four Hundred Eighty-Four
    There's no need to write DB function unless you are sure that the value can exceed 5373484.
    You can do the following :
    1. Create a Summary column on the report column on which you want the data summed - Report level or at any level required
    2. Create a Formula Column - Report Level or any other level - Wherever required [ Same level as in Step 1]
    3. The trigger text of this formula column would use the column which is summation of the Expenditure field column (Summary Column) and this function should return Varchar2
    Declare
    lSumInWords Varchar2(1000) := Null;
    Begin
    Select TO_CHAR(TO_DATE(:CS_1,'J'),'JSP')
    Into lSumInWords
    From dual;
    Return (lSumInWords);
    End;
    3. In Your report layout, use this formula column for printing.
    Good Luck.
    -- Shailender Mehta --

Maybe you are looking for