Using UTL_HTTP.GET_RESPONSE function (PL/SQL)

Hello,
I have a problem using the UTL_HTTP.GET_RESPONSE (URL, 'POST') function while I try to call a function that returns an XML;
The function returning my XML is:
FUNCTION MyFunction return XMLTYPE is
begin
return XMLTYPE('<PROVA>test</PROVA>');
end MyFunction;
To perform the http call I use this function:
FUNCTION POST(URL VARCHAR2, DATA_IN CLOB) RETURN CLOB IS
BEGIN
DECLARE
DATA_OUT CLOB;
PIECE VARCHAR2(4000);
AMT PLS_INTEGER := 4000;
POS PLS_INTEGER := 1;
HTTP_REQ UTL_HTTP.REQ;
HTTP_RESP UTL_HTTP.RESP;
BEGIN
HTTP_REQ := UTL_HTTP.BEGIN_REQUEST (URL, 'POST');
UTL_HTTP.SET_HEADER(HTTP_REQ, 'content-length', LENGTH(DATA_IN));
LOOP
DBMS_LOB.READ(DATA_IN,AMT,POS,PIECE);
UTL_HTTP.WRITE_TEXT(HTTP_REQ, PIECE);
EXIT WHEN AMT < 4000;
POS := POS + AMT;
AMT := 4000;
END LOOP;
HTTP_RESP := UTL_HTTP.GET_RESPONSE (HTTP_REQ);
BEGIN
LOOP
UTL_HTTP.READ_TEXT(HTTP_RESP, PIECE);
DATA_OUT := DATA_OUT || PIECE;
END LOOP;
EXCEPTION WHEN UTL_HTTP.END_OF_BODY THEN NULL;
END;
UTL_HTTP.END_RESPONSE (HTTP_RESP);
RETURN DATA_OUT;
END;
END;
The script pl/sql that calls the preceding function is:
declare
v_resp CLOB;
v_url VARCHAR2(4000);
begin
v_url := 'http:// ... /meters.export_table.MyFunction'
v_resp := POST(v_url, '-');
end;
After this call to my url, the variabile v_resp contains the following error message:
"<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>400 Bad Request</TITLE>
</HEAD><BODY>
<H1>Bad Request</H1>
Your browser sent a request that this server could not understand.<P>
mod_plsql: /pls/prjsi/meters.export_table.MyFunction HTTP-400 Missing '=' in query string or post form<P>
<HR>
<ADDRESS>Oracle-Application-Server-10g/10.1.2.0.2 Oracle-HTTP-Server Server at websvil.aem.torino.it Port 80</ADDRESS>
</BODY></HTML>"
Do you know how I can get my XML? What is the problem in that call http for my function?
Thanks

Hello !
I have not understand exactly what have you try to achieve with your code , but i thing there are few things misunderstood in your code ,
so i'm posting this very basic but working example in hope that it will help you
SQL>
SQL>
SQL> conn scott/tiger
Connected.
SQL>
SQL>
SQL> create or replace procedure http_test is
  2  begin
  3    htp.p('<PROVA>test</PROVA>');
  4  end http_test;
  5  /
Procedure created.
SQL> CREATE OR REPLACE function HTTP_POST return varchar2 is
  2 
  3    req  utl_http.req;
  4    resp utl_http.resp;
  5   
  6    v_txt varchar2(1024);
  7   
  8  BEGIN
  9   
10    req  := UTL_HTTP.begin_request ('http://localhost:7777/pls/my_utf8/http_test'
11                                   ,'POST','HTTP/1.1');
12    Utl_Http.Set_Authentication ( r => req, username => 'scott', password => 'tiger'
13                                , scheme => 'Basic', for_proxy => false );
14    resp := UTL_HTTP.get_response  (req);
15    utl_http.read_text(resp,v_txt);
16    utl_http.end_response(resp);
17    return v_txt;
18  END;
19  /
Function created.
SQL> select http_post from dual;
HTTP_POST
<PROVA>test</PROVA>
SQL> T

Similar Messages

  • Using User Defined Function is SQL

    Hi
    I did the following test to see how expensive it is to use user defined functions in SQL queries, and found that it is really expensive.
    Calling SQRT in SQL costs less than calling a dummy function that just returns
    the parameter value; this has to do with context switchings, but how can we have
    a decent performance compared to Oracle provided functions?
    Any comments are welcome, specially regarding the performance of UDF in sql
    and for solutions.
    create or replace function f(i in number) return number is
    begin
      return i;
    end;
    declare
      l_start   number;
      l_elapsed number;
      n number;
    begin
      select to_char(sysdate, 'sssssss')
        into l_start
        from dual;
      for i in 1 .. 20 loop
        select max(rownum)
          into n
          from t_tdz12_a0090;
      end loop;
      select to_char(sysdate, 'sssssss') - l_start
        into l_elapsed
        from dual;
      dbms_output.put_line('first: '||l_elapsed);
      select to_char(sysdate, 'sssssss')
        into l_start
        from dual;
      for i in 1 .. 20 loop
        select max(sqrt(rownum))
          into n
          from t_tdz12_a0090;
      end loop;
      select to_char(sysdate, 'sssssss') - l_start
        into l_elapsed
        from dual;
      dbms_output.put_line('second: '||l_elapsed);
      select to_char(sysdate, 'sssssss')
        into l_start
        from dual;
      for i in 1 .. 20 loop
        select max(f(rownum))
          into n
          from t_tdz12_a0090;
      end loop;
      select to_char(sysdate, 'sssssss') - l_start
        into l_elapsed
        from dual;
      dbms_output.put_line('third: '||l_elapsed);
    end;
    Results:
       first: 303
       second: 1051
       third: 1515
    Kind regards
    Taoufik

    I find that inline SQL is bad for performance but
    good to simplify SQL. I keep thinking that it should
    be possible somehow to use a function to improve
    performance but have never seen that happen.inline SQL is only bad for performance if the database design (table structure, indexes etc.) is poor or the way the SQL is written is poor.
    Context switching between SQL and PL/SQL for a User defined function is definitely a way to slow down performance.
    Obviously built-in Oracle functions are going to be quicker than User-defined functions because they are written into the SQL and PL/SQL engines and are optimized for the internals of those engines.
    There are a few things you can do to improve function
    performance, shaving microseconds off execution time.
    Consider using the NOCOPY hints for your parameters
    to use pointers instead of copying values. NOCOPY
    is a hint rather than a directive so it may or may
    not work. Optimize any SQL in the called function.
    Don't do anything in loops that does not have to be
    done inside a loop.Well, yes, but it's even better to keep all processing in SQL where possible and only resort to PL/SQL when absolutely necessary.
    The on-line documentation has suggested that using a
    DETERMINISTIC function can improve performance but I
    have not been able to demonstrate this and there are
    notes in Metalink suggesting that this does not
    happen. My experience is that DETERMINISTIC
    functions always get executed. There's supposed to
    be a feature in 11g that acually caches function
    return values.Deterministic functions will work well if used in conjunction with a function based index. That can improve access times when querying data on the function results.
    You can use DBMS_PROFILER to get run-time statistics
    for each line of your function as it is executed to
    help tune it.Or code it as SQL. ;)

  • Using CLR Integration functionality in SQL Server 2005 in CR 2008

    I have several CLR SQLProcedures in my SQL Database for performing performing complex selects with regex etc. These work exceptionally well form with Visual Strudio for retrieving a dataset. However from within Crystal Reports I can not see these stored procedures, so cannot use the to report on, which was the whole idea of creating them.
    Considering CLR Intergration has been around since 2004/5, I would have expected CR 2008 to be able to make use of them, but I can find no way to make them work.
    I hope some one can assist me in this quest.

    Mark,
    Hate to say this but I'm baffled. Until you actually do something with it, CR shouldn't even know that there is a difference between a T-SQL SP and a CLR SP.
    If nothing else, that's probably a good indication that the problem is either in the Native Client settings or at the server level.
    I did some Google searching but didn't find anything relevant.
    Sorry,
    Jason

  • Using power shell function and SQL Table

    I have a table holding file path of over 1 million documents. so like column one is documentID and column two is full file path.
    Now, I want to get the file size of each of the documents. I have a function in power shell that gets the size of a file given file path.
    My problem, is I do not know how to use that function and the table to get the size of each of the files(documents).
    Help Much Appreciated!!
    ebro

    I am not clear with your questions sir. Do you mean the category this question belongs too? If so, may be some body could help redirect the question to the appropriate place.
    So what category does this belong too CM12 or Powershell?
    http://www.enhansoft.com/

  • Using type for function in sql

    CREATE OR REPLACE
    type InListType_number as table
    of number
    CREATE OR REPLACE function in_list( p_patseq in number ) return InListType_number
    as
    l_number number default p_patseq ;
    l_data InListType_number := InListType_number();
    begin
    loop
    exit when l_number is null;
    end loop;
    return l_data;
    end;
    SELECT p.pat_seq, p.diagnosis_type, ct.code_value || ' ' || p.alt_description as diagnosis_desc
    FROM patient_diagnosis p,
         (select * from code_set , code_set_type
         where code_set.code_set_type_seq =code_set_type.code_set_type_seq) ct
    WHERE p.enterprise_seq = (select enterprise_seq from org_lookup where organization_seq = 0 and rownum = 1)
    and p.diagnosis_code_seq = ct.code_set_seq(+)
    and (p.diagnosis_type LIKE 'A%' OR p.diagnosis_type LIKE 'W%')
    and p.PAT_SEQ IN (select /*+ CARDINALITY (t ) */* from table( cast( in_list (list of pat_seq here like 12345,12344,345666,etc over 1000 counts of pat_seqs)
    as InListType_number ) ) t)
    this gives me
    ORA-00939: too many arguments for function
    can someone advise? thanks

    Well IN_LIST takes a single parameter of type NUMBER and you are passing in
    12345,12344,345666which is patently multiple numbers. I think what you want to do is pass in a string ' 12345,12344,345666' and have a function TO_LIST() that parses the string and spits out numbers. Fortunately for you John Spencer has posted Re: Splitting the values in one column.
    Cheers, APC

  • How to perform authentication on proxy using utl_http package?

    Hi,
    I am using Oracle 8i database (ver:8.1.7). I want to use the utl_http package to perform http requests. Within my company, I am forced to use a proxy and I have to be authenticated on that proxy. How can I authenticate myself on the proxy using utl_http.request function on Oracle 8i?
    Thanks a lot.
    Paulo.

    UTL_HTTP
    The UTL_HTTP package makes Hypertext Transfer Protocol (HTTP) callouts from SQL and PL/SQL. You can use it to access data on the Internet over HTTP.
    With UTL_HTTP, you can write PL/SQL programs that communicate with Web (HTTP) servers. UTL_HTTP also contains a function that can be used in SQL queries. The package also supports HTTP over the Secured Socket Layer protocol (SSL), also known as HTTPS, directly or through an HTTP proxy. Other Internet-related data-access protocols (such as the File Transfer Protocol (FTP) or the Gopher protocol) are also supported using an HTTP proxy server that supports those protocols.
    When the package fetches data from a Web site using HTTPS, it requires Oracle Wallet Manager to set up an Oracle wallet. Non-HTTPS fetches do not require an Oracle wallet.
    See Also:
    Chapter 102, "UTL_URL"
    Chapter 100, "UTL_SMTP"
    Oracle Advanced Security Administrator's Guide for more information on Wallet Manager
    This chapter discusses the following topics:
    UTL_HTTP Constants, Types and Flow
    UTL_HTTP Exceptions
    UTL_HTTP Examples
    Summary of UTL_HTTP Subprograms
    http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96612/u_http.htm#ARPLS070
    Joel P�rez

  • How to use open Row set in sql server 2014

    Hello All,
    How to open the row set using sql server 2014 using link server connection.

    Hi  denyy,
    Are you referring to the OPENROWSET function in SQL Server 2014?
    The OPENROWSET method is an alternative to accessing tables in a linked server and is a one-time, ad hoc method of connecting and accessing remote data by using OLE DB. The examples below demonstrate how to use the OPENROWSET function:
    A. Using OPENROWSET with SELECT and the SQL Server Native Client OLE DB Provider
    SELECT a.*
    FROM OPENROWSET('SQLNCLI', 'Server=Seattle1;Trusted_Connection=yes;',
    'SELECT GroupName, Name, DepartmentID
    FROM AdventureWorks2012.HumanResources.Department
    ORDER BY GroupName, Name') AS a;
    B. Using the Microsoft OLE DB Provider for Jet
    SELECT CustomerID, CompanyName
    FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
    'C:\Program Files\Microsoft Office\OFFICE11\SAMPLES\Northwind.mdb';
    'admin';'',Customers);
    GO
    C. Using OPENROWSET to bulk insert file data into a varbinary(max) column
    USE AdventureWorks2012;
    GO
    CREATE TABLE myTable(FileName nvarchar(60),
    FileType nvarchar(60), Document varbinary(max));
    GO
    INSERT INTO myTable(FileName, FileType, Document)
    SELECT 'Text1.txt' AS FileName,
    '.txt' AS FileType,
    * FROM OPENROWSET(BULK N'C:\Text1.txt', SINGLE_BLOB) AS Document;
    GO
    D. Using the OPENROWSET BULK provider with a format file to retrieve rows from a text file
    SELECT a.* FROM OPENROWSET( BULK 'c:\test\values.txt',
    FORMATFILE = 'c:\test\values.fmt') AS a;
    Reference:
    OPENROWSET (Transact-SQL)
    Using the OPENROWSET function in SQL Server
    Thanks,
    Lydia Zhang
    If you have any feedback on our support, please click
    here.

  • Run a report in PL/SQL using utl_http.request

    Hi
    I need to run a report in PL/SQL using utl_http.request
    How that can be done ??
    Thank you!

    Okay, backtrack.
    A web server can deliver all kinds of content. From static HTML pages, to XML files and videos and dynamic content. Including reports.
    The communication language (protocol) used to talk to a web server is HTTP.
    UTL_HTTP is an Oracle PL/SQL library that implements the client side of this communication. It allows the developer to write code that acts like a web browser and communicates with a web server.
    Now what do you not understand and cannot use?
    HTTP is not simple and easy. You need to understand the basics of this communication language in order to communicate successfully with the web server. Like knowing the difference between GET and PUT and POST commands, how the URL query string works and so on.
    Once you know that, you can look at how the web server provides reports. How do you authenticate as a web browser with the web reporting system? What URLs do you use to access which reports? How do you pass name-values to the web server as report parameters? What HTTP response formats (MIME types) does the web report server provide? Which one do you plan to use and how do you parse that response into a meaning structured data format?
    If you're thinking it is "easy", think again. Sure, someone here can provide sample code that for example grabs a CSV report file from a web server and (using a pipeline table function), turn that into rows and columns. But that will not teach you the fundamentals you need to know and not equip you with dealing with the problem with your own brains, hands and keyboard.
    PS. In other words, learn to crawl and walk before trying to run. Get to grips with how HTTP works before diving into the deep end of web report integration.

  • How to add WebService authentication in pl/sql using UTL_HTTP

    Hi,
    I am passing SOAP request and getting output as a soap response from WebService using UTL_HTTP.
    Calling Web service client call from the PL/SQL procedure.
    Java web service is a service producer.
    Now we needs to add security to the application we are planing to add some of the userid/pwd credientials.
    So what needs to be add sql code in the sq/sql for making client call.
    i checked from the few of the articles. it shown like
    UTL_HTTP.set_authentication(http_req, 'username', 'password' );
    is it enough for making clent call or any other changes are required.
    Please let me know and any code to be implemented in the jave side aslo(if you knows) :-)
    Thanks,
    Pradeep.

    Okay, backtrack.
    A web server can deliver all kinds of content. From static HTML pages, to XML files and videos and dynamic content. Including reports.
    The communication language (protocol) used to talk to a web server is HTTP.
    UTL_HTTP is an Oracle PL/SQL library that implements the client side of this communication. It allows the developer to write code that acts like a web browser and communicates with a web server.
    Now what do you not understand and cannot use?
    HTTP is not simple and easy. You need to understand the basics of this communication language in order to communicate successfully with the web server. Like knowing the difference between GET and PUT and POST commands, how the URL query string works and so on.
    Once you know that, you can look at how the web server provides reports. How do you authenticate as a web browser with the web reporting system? What URLs do you use to access which reports? How do you pass name-values to the web server as report parameters? What HTTP response formats (MIME types) does the web report server provide? Which one do you plan to use and how do you parse that response into a meaning structured data format?
    If you're thinking it is "easy", think again. Sure, someone here can provide sample code that for example grabs a CSV report file from a web server and (using a pipeline table function), turn that into rows and columns. But that will not teach you the fundamentals you need to know and not equip you with dealing with the problem with your own brains, hands and keyboard.
    PS. In other words, learn to crawl and walk before trying to run. Get to grips with how HTTP works before diving into the deep end of web report integration.

  • Using DECODE Function in SQL

    I need to know if there is any way to use a range of values from
    database and decode to certain text. I am able to do with one
    value.
    for example:
    DECODE(column_name,'216767111','Unlimited',column_name)
    above argument works with one value only. How about a range,
    ex: 216767000 to 216767111. I need to use only SQL. No PL/SQL.
    Kinldly need some body's help
    Thanks
    Munis

    Which version of the database? If it's 8i+ then you can use
    the CASE function
    for example:
    (CASE WHEN column_name between 216767000 and 216767111
    THEN 'Unlimited' ELSE column_name END)
    This won't work in PL/SQL because they're introducing a CASE
    statement does soemthing different.
    rgds, APCHello Andrew
    Thank you for response. I am using 8i. 8.1.6. However using
    CASE, I get inconsistent data type, ORA-00932: inconsistent
    datatypes. I able to work it out with other response using
    DECODE(sign(. Do you have any idea why i am getting this error.
    If time permits, let me know

  • Error while invoking webservice using UTL_HTTP from PL/SQL Block

    Hi All,
    I am invoking a webservice (SOAP Request) from a PL/SQL block using UTL_HTTP package.
    I am able to send the complete request and am getting the required instance on the BPEL Console, but the process is erroring out while getting response back.
    and the PL/SQL Block is ending in error mentioned below:
    ERROR at line 1:
    ORA-29266: end-of-body reached
    ORA-06512: at "SYS.UTL_HTTP", line 1321
    ORA-06512: at "APPS.CSM_BPEL_TEST_PKG", line 34
    ORA-06512: at line 1
    Package is completing successfully if i test in local DB and local BPEL.
    But giving above error in client's.
    Can anyone let me know what is the cause of this.
    Thanks in advance

    I got it working by making process Synchronous.
    But with asynchronous process it is still same error.
    Thanks...

  • Use of ROW_NUMBER() function in PL/SQL

    I have a Table Emp with the following Structure
    SQL> desc emp
    Name Null? Type
    EMPNO NUMBER(2)
    ENAME VARCHAR2(50)
    HIREDATE DATE
    DEPTNO NUMBER(2)
    If I write a following query on this table
    SQL> SELECT deptno, hiredate, record_id
    2 FROM (SELECT deptno, ename, hiredate, ROW_NUMBER()
    3 OVER (ORDER BY hiredate) AS record_id
    4 FROM emp)
    5 WHERE record_id >= 2
    6 AND record_id <=5;
    The Result I get is
    DEPTNO HIREDATE RECORD_ID
    10 22-NOV-01 2
    10 22-NOV-01 3
    10 22-NOV-01 4
    10 22-NOV-01 5
    But if I put this query in a cursor in a PL/SQL block. The
    pl/sql does not compiles and gives me the following address
    SQL> DECLARE
    2 CURSOR c_my IS
    3 SELECT deptno, hiredate, record_id
    4 FROM (SELECT deptno, ename, hiredate, ROW_NUMBER()
    5 OVER (ORDER BY hiredate) AS record_id
    6 FROM emp)
    7 WHERE record_id >= 2
    8 AND record_id <=5;
    9 BEGIN
    10 FOR c_rec IN c_my LOOP
    11 dbms_output.put_line(c_rec.ename);
    12 END LOOP;
    13 END;
    14 /
    OVER (ORDER BY hiredate) AS record_id
    ERROR at line 5:
    ORA-06550: line 5, column 13:
    PLS-00103: Encountered the symbol "(" when expecting one of the
    following:
    , from
    Question: Can you please tell me how I can use the ROW_NUMBER()
    function in PL/SQL. I need to use this for selecting the correct
    range of records for Pagination on a website.
    Thanks in advance
    Prashant

    As Andrew said, PL/SQL hasn't caught up with the newer bits of
    SQL.  I have heard that in 9i, they will be the same, but in 8i
    there are still things that you can do in SQL that you cannot do
    directly in PL/SQL, such as the new functions like ROW_NUMBER. 
    However, you can use NDS as a work around.  The following does
    the same as what you posted:
    SET SERVEROUTPUT ON
    DECLARE
      TYPE c_my_type  IS REF CURSOR;
      c_my               c_my_type;
      TYPE c_rec_type IS RECORD
        (deptno          emp.deptno%TYPE,
         ename           emp.ename%TYPE,
         hiredate        emp.hiredate%TYPE,
         record_id       INTEGER);
      c_rec              c_rec_type;
      v_sql              VARCHAR2 (4000);
    BEGIN
      v_sql :=
      'SELECT deptno, ename, hiredate, record_id
       FROM   (SELECT deptno, ename, hiredate,
                      ROW_NUMBER() OVER
                        (ORDER BY hiredate)
                        AS record_id
              FROM    emp)
       WHERE  record_id >= 2
       AND    record_id <= 5';
      OPEN c_my FOR v_sql;
      LOOP
        FETCH c_my INTO c_rec;
        EXIT WHEN c_my%NOTFOUND;
        DBMS_OUTPUT.PUT_LINE (c_rec.ename);
      END LOOP;
    END;
    However, you stated that you need it for selecting the correct
    range of records for pagination on a website.  For that, you
    will want something more like this:
    CREATE OR REPLACE PACKAGE package_name
    AS
      TYPE c_my_type     IS     REF cursor;
      PROCEDURE procedure_name
        (c_my            IN OUT c_my_type,
         p_record_id1    IN     NUMBER DEFAULT 1,
         p_record_id2    IN     NUMBER DEFAULT 4);
    END package_name;
    CREATE OR REPLACE PACKAGE BODY package_name
    AS
      PROCEDURE procedure_name
        (c_my            IN OUT c_my_type,
         p_record_id1    IN     NUMBER DEFAULT 1,
         p_record_id2    IN     NUMBER DEFAULT 4)
      IS
        v_sql                   VARCHAR2 (4000);
      BEGIN
        v_sql :=
            'SELECT deptno, ename, hiredate, record_id'
        || ' FROM   (SELECT deptno, ename, hiredate,'
        ||                ' ROW_NUMBER() OVER'
        ||                  ' (ORDER BY hiredate)'
        ||                  ' AS record_id'
        || ' FROM    emp)'
        || ' WHERE  record_id >= :a'
        || ' AND    record_id <= :b';
        OPEN c_my FOR v_sql
        USING p_record_id1, p_record_id2;   
      END procedure_name;
    END package_name;

  • Function in SQL: PRAGMA used, but '..does not guarantee not to update database'- WHY?

    I use function in SQL statement. It is a dynamicaly build SQL, therefore I need overload functions. These funcs defined in package. The package has PRAGMA Restrict_References (.., WNDS). So all functions should be restricted to update database.
    But Oracle returns an error:
    Function NVL_ does not guarantee not to update database
    This is my build SQL:
    ----- the execution string is: ---------------
    Begin
    INSERT INTO TEST_TBL_BS (MILL_ORDER, CLM1, CLM2, CLM3, NOTES, INIT_DATE )
    VALUES (NV.NVL_(Arc_Utl.TEST_TBL_dltd.MILL_ORDER),
    NV.NVL_(Arc_Utl.TEST_TBL_dltd.CLM1),
    NV.NVL_(Arc_Utl.TEST_TBL_dltd.CLM2),
    NV.NVL_(Arc_Utl.TEST_TBL_dltd.CLM3),
    NV.NVL_(Arc_Utl.TEST_TBL_dltd.NOTES),
    Arch.Init_Time );
    End;
    This is NV package:
    PACKAGE NV IS
    PRAGMA Restrict_References ( NV, WNDS );
    NULL_date DATE := TO_DATE ('01/01/1001', 'mm/dd/yyyy');
    NULL_numb NUMBER := 0;
    NULL_str VARCHAR2 (10)
    := '?';
    -- overloaded NULL_Val function returns NULL_<type> value (defined early)
    -- depend on received variable type
    FUNCTION NULL_Val ( val_in IN DATE )
    RETURN DATE ;
    FUNCTION NULL_Val ( val_in IN NUMBER )
    RETURN NUMBER ;
    FUNCTION NULL_Val ( val_in IN VARCHAR2 )
    RETURN VARCHAR2 ;
    -- PRAGMA Restrict_References ( NULL_Val, WNDS ); -- can be used in SQLs
    -- these pretends to cover hole of the SYS.NVL that do not have posibility
    -- to return default NULL value for every given type
    FUNCTION NVL_ ( val_in IN DATE )
    RETURN DATE ;
    FUNCTION NVL_ ( val_in IN NUMBER )
    RETURN NUMBER ;
    FUNCTION NVL_ ( val_in IN VARCHAR2 )
    RETURN VARCHAR2 ;
    -- PRAGMA Restrict_References ( NVL_, WNDS ); -- can be used in SQLs
    END NV;
    CREATE OR REPLACE PACKAGE BODY NV AS
    -- NULL_Val set of overloaded functions - returns appropriate NULL value
    FUNCTION NULL_Val ( val_in IN DATE )
    RETURN DATE IS
    BEGIN RETURN NULL_date;
    END NULL_Val; -- for date
    FUNCTION NULL_Val ( val_in IN NUMBER )
    RETURN NUMBER IS
    BEGIN RETURN NULL_numb;
    END NULL_Val; -- for NUMBER
    FUNCTION NULL_Val ( val_in IN VARCHAR2 )
    RETURN VARCHAR2 IS
    BEGIN RETURN NULL_str;
    END NULL_Val; -- for VARCHAR2
    -- set NVL_ function to return default NULL value if received variable
    -- is NULL or the received variable if it is not NULL
    FUNCTION NVL_ ( val_in IN DATE )
    RETURN DATE IS
    BEGIN RETURN NVL( val_in, NULL_Val ( val_in )); END NVL_;
    FUNCTION NVL_ ( val_in IN NUMBER )
    RETURN NUMBER IS
    BEGIN RETURN NVL( val_in, NULL_Val ( val_in )); END NVL_;
    FUNCTION NVL_ ( val_in IN VARCHAR2 )
    RETURN VARCHAR2 IS
    BEGIN RETURN NVL( val_in, NULL_Val ( val_in )); END NVL_;
    END NV;
    Can anybody help : where is a problem and what I can do in my case?
    I work in Oracle 7.3
    Thank you,
    Alex

    Hi Alex,
    I've found that on the RDBS docs:
    If you specify DEFAULT instead of a function name, the pragma applies to all functions in the package spec or object type spec (including, in the latter case, the
    system-defined constructor). You can still declare the pragma for individual functions. Such pragmas override the default pragma.
    Try using that and let me know.
    The docs says also that the declaration of the pragma for an overloaded function applies to the nearest one. You may also try to insert several declaration, one after every function declaration.
    Bye Max

  • Using 'Function Returning SQL Query' with Flash charts

    I have created a pl/sql function that returns a SQL query as a varchar2 of this form:
    select null link
    <x value> value
    <Series1 y value> Series 1 Label
    <Series2 y value> Series 2 Label
    <Series3 y value> Series 3 Label
    from tablea a
    join tableb b
    on a.col = b.col
    order by <x value>
    If I now call the function from a Flash Chart Series SQL box with the Query Source Type set to 'Function Returning SQL Query' like this:
    return functionname(to_date('30-sep-2010', 'dd-mon-yyyy'))
    it parses correctly and the page is saved; however, when I run the page I don't get any output - nor any error messages or other indication of a problem.
    Now, if I call the function in a SQL client, capture the SQL query output using dbms_output and paste that into the Flash Chart Series SQL box - changing the Query Source Type to SQL Query - and save the page it works fine when I run it and returns a multi-series flash chart.
    Can anyone suggest either;
    1. What have I might have missed or done wrong?
    2. Any way to usefully diagnose the problem...
    I have tried using the Apex debugger - which is very nice, by the way - but it doesn't provide any info on what my problem might be. I even tried writing my own debug messages from my function using the apex_debug_message package - got nothing...
    Thanks,
    Eric

    Hi Eric,
    Try expressing the source as this:
    begin
       return functionname(to_date('30-sep-2010', 'dd-mon-yyyy'));
    end;That works fine for me, and if I take out the begin-end and the trailing semicolon from the return statement I get the same behavior as you.
    It does mention in the help for the source (only during the wizard though) that this source type has to be expressed that way, but I agree it would be helpful if the tool would validate for this format when 'Function Returning SQL Query' is used or give some sort of indication of the trouble. Anyway, this should get you going again.
    Hope this helps,
    John
    If you find this information useful, please remember to mark the post "helpful" or "correct" so that others may benefit as well.

  • Can window and aggregate SQL functions be used in Pro*C embedded SQL?

    It appears that window functions such as dense_rank() over(partition by ... order by ...) can not be used in Pro*C embedded SQL? Can somebody confirm that that is really the case?
    Thanks
    Rawender Guron

    Please refer to this thread: "Is this forum also used for Pro*'C Questions? "
    Is this forum also used for Pro*'C Questions?

Maybe you are looking for

  • WHAT A LOW QUALITY KEYBOARD!!​! Broken after using for ONE day, what should I do????

    Hi guys~ I've bought my first thinkpad x230 from lenovo offical online store and recived it on yesterday. I was very exciting when I receive this extreamely light and pretty notebook. -However, it not last long... After typing a series of numbers, th

  • Itunes download will not work. Itunes crashes and won't open

    Okay, seriously. I'm at my wits end. Please help. I have a Dell Inspiron 1420 running Vista and when I d/l itunes 8.1.1, this is the error message I get when I try to launch itunes. Problem signature: Problem Event Name: APPCRASH Application Name: iT

  • Freezing up while playing a game

    so i recently i got this problem and i i don't know how to fix it. My problem is that when I am playing a game such as call of duty, vindictus and heroes of newerth it'll work fine for a few minutes then the screen like flickers once and then the who

  • Adobe AIR 24 Error Android 4.2.2

    Exactly the same error as pierre.nirph Samsung Tab3 10.1 GT-P5200 running Android 4.2.2 Jellybean. Adobe AIR 15.0.0.252 does not install, get error 'Unknown error code during application install: "-24" ' We have two Identical Samsung units-.one of wh

  • Where is the date for my movie clips?

    In the previous version of iMovie when you clicked on a movie clip you could see the date near the preview window. Now in iMovie 6 you have to double click on the clip to get the date info. Anybody else notice this. I thought it was useful to have th