Function return single record

create or replace function etest
(dep in number)
return varchar2
is
dept number:= 0;
cursor c1 is
select deptno
into dept
from emp
where deptno = dep;
begin
open c1;
loop
fetch c1 into dept;
exit when c1%notfound;
end loop;
close c1;
return dept;
end;
Dear all
the above function return only one return ,,,but i want to display all record that belong to department 10
it just i idea that what i want to do....!
and Secondly
how i fetch multiple column like i enter department 10 and it give output like
empno ename sal
7782 CLARK 2450
7739 KING 5000
7934 MILLER 13000
Thanks to all

You could use a REF CURSOR:
PL/SQL 101 : Understanding Ref Cursors
http://www.oracle-base.com/articles/misc/UsingRefCursorsToReturnRecordsets.php
or maybe a pipelined function....
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:19481671347143
http://www.oracle-base.com/articles/9i/PipelinedTableFunctions9i.php
depending on what client is fetching.

Similar Messages

  • Oracle 11g Table function returns no records on first call

    Hello,
    On a Oracle 11g R2 I've a table function ( PIPELINED ) returning rows selected from a table.
    The first time the function is selected, in a session ( I've tried to disconnect and log in again ), it returns no rows.
    I've tried to log the call using DBMS_OUTPUT and from what I see the select on the table function returns no rows and no output is printed. So I presume Oracle is not calling the function.
    The same function on a similar environment ( same db versions, patches and database structure ) works fine. The second environment is a production environment so it has more memory and some other settings enabled.
    Does anyone know of settings that can relate to this behaviour ?
    Thanks in advance for the help.
    Regards,
    Stefano Muret

    Thank you for answering so fast.
    Here's the function code:
    FUNCTION template_parameters (iTemplate IN TEMPLATE_RAW_DATA.TMPL_ID%TYPE := NULL)
    RETURN table_type_tmpl_parameters PIPELINED
    IS
    li_exception INTEGER DEFAULT -20025;
    POUT_PARM TABLE_TYPE_TMPL_PARAMETERS;
    lt_parms table_type_tmpl_parms_raw;
    sParmCheck VARCHAR2(4000);
    iOccurrence INTEGER;
    BEGIN
    pOut_Parm := table_type_tmpl_parameters();
    pOut_Parm.EXTEND;
    select
    tmpl_id
    *,tmpl_name*
    *,replace(upper(trim(sql_out)),'[SCHEMA].')*
    *,UPPER(TRIM(out_tmpl_parms))*
    bulk collect into lt_parms
    from ref_templates
    where tmpl_id = NVL(iTemplate,tmpl_id)
    order by tmpl_id;
    FOR k IN 1..lt_parms.COUNT
    LOOP
    pOut_Parm(1).tmpl_id := lt_parms(k).tmpl_id;
    pOut_Parm(1).tmpl_name := lt_parms(k).tmpl_name;
    FOR i IN 1..2
    LOOP
    IF i = 1 THEN
    sParmCheck := lt_parms(k).sql_out;
    ELSE
    sParmCheck := lt_parms(k).sql_parms;
    END IF;
    iOccurrence := 1;
    *pOut_Parm(1).parameter_name := regexp_substr(sParmCheck,'\[[^\[]+\]',1,iOccurrence);*
    WHILE pOut_Parm(1).parameter_name IS NOT NULL
    LOOP
    PIPE ROW (pOut_Parm(1));
    iOccurrence := iOccurrence + 1;
    *pOut_Parm(1).parameter_name := regexp_substr(sParmCheck,'\[[^\[]+\]',1,iOccurrence);*
    END LOOP;
    END LOOP;
    END LOOP;
    RETURN;
    EXCEPTION
    WHEN OTHERS THEN
    RAISE_APPLICATION_ERROR(li_exception,SUBSTR(SQLERRM,1,1000));
    RETURN;
    END template_parameters;
    This function is part of a package.
    The data on both environments is the same.

  • HELP needed to write a function returning 1 record from join tables

    Hi,
    I would like to have some help to write a function so It can return 1 result.
    I post my question in the APEX Express sextion but I think it's belong here.
    Mount Points and Home Directory
    Also, can I move a thread in another forum?
    thanks
    Roseline
    Edited by: user8772975 on 2009-09-19 21:43

    ok, I think I started to understand the functions. But I still can't figured out
    CONTEXT
    We are scanning pages and images from different newspaper. All the .tif, .jpg are on DVDs.
    I'm trying to build a search page who will allow for all DVDs and All images name related to the search result. Let say I search for:
    FIGARO
    I have this SQL query and I want to make a function that will return the same thing as:
    select     
          "DOSSIER"."ID" as "DOSSIERID",
          "DOSSIER"."TITLE" as "TITLE",
          "DVD"."ID" as "DVDID",
          "DVD"."NAME" as "DVDNAME",
          "DVD"."ID_DOSSIER" as "DVD_ID_DOSSIER",
          "ELEMENTS"."ID" as "ELEMENTSID",
          "ELEMENTS"."NAME" as "ELEMENTSNAME",
          "ELEMENTS"."ID_DVD" as "ELEMENTS_ID_DVD"
    from      "DOSSIER" "DOSSIER",
               "DVD" "DVD",
               "ELEMENTS" "ELEMENTS"
    where   "DVD"."ID_DOSSIER"="DOSSIER"."ID"
    and      "ELEMENTS"."ID_DVD"="DVD"."ID"
      and       "DOSSIER"."TITLE" = :P3_SEARCH
    ORDER BY "DVD".NAMEBasiccly, We are scanning pages and images from different newspaper. All the .tif, .jpg are on DVDs.
    So we have someting like that:
    TITLE: FIGARO
    DVD:        C2008-203
    Elements: 12l10201.tif, 12l10202.tif, 12l11101.tif, 12l11102.tif, 12l11201.tif
                    12l11202.tif, 12l12101.tif, 12l12102.tif
    DVD         C2008-204
    Elements: 12l12202.tif, 12l13101.tif, 12l13102.tif, 12l13201.tif, 12l13202.tif,
                   12l14101.tif, 12l14102.tif, 12l14201.tif, 12l14202.tif, 12l15101.tif,
                   12l15102.tif, 12l15201.tif
    DVD:       C2008-205
    Elements: 12l15202.tif, 12l16101.tif, 12l16102.tif, 12l16201.tif, 12l16202.tif,
                    12m01101.tif, 12m01102.tif, 12m01201.tifBased on what people on the forum told me, I now know that I have to use Pl/SQL so I have to write a function that will return the same thing as the prvious query.
    Is that exact?
    Based on this example,
    [http://plsql-tutorial.com/plsql-functions.htm|http://plsql-tutorial.com/plsql-functions.htm]
    I would write something like:
    CREATE FUNCTION my_super_function
    RETURN VARCHAR(2000);
    IS
    details VARCHAR(2000);
    BEGIN
    select     
          "DOSSIER"."ID" as "DOSSIERID",
          "DOSSIER"."TITLE" as "TITLE",
          "DVD"."ID" as "DVDID",
          "DVD"."NAME" as "DVDNAME",
          "DVD"."ID_DOSSIER" as "DVD_ID_DOSSIER",
          "ELEMENTS"."ID" as "ELEMENTSID",
          "ELEMENTS"."NAME" as "ELEMENTSNAME",
          "ELEMENTS"."ID_DVD" as "ELEMENTS_ID_DVD"
    from      "DOSSIER" "DOSSIER",
               "DVD" "DVD",
               "ELEMENTS" "ELEMENTS"
    where   "DVD"."ID_DOSSIER"="DOSSIER"."ID"
    and      "ELEMENTS"."ID_DVD"="DVD"."ID"
      and       "DOSSIER"."TITLE" = :P3_SEARCH
    RETURN details;
    END;
    / And then, use soemthing like:
    select my_super_function("DOSSIER"."ID") from "DOSSIER" "DOSSIER" where "DOSSIER"."TITLE" = :P3_SEARCHI'm kinda of lost. I spent the last 6 hours but I think that programming is a working progress.
    Any hint would be appreciated,
    thanks
    Roseline

  • Calling a function from SQL prompt that returns a record

    Hi,
    I've been trying to execute a function that is present on a different database. for eg. I am loged on to a database say 'A' and trying to execute a function present in database 'B'. this function is present in a package 'X' which has 2 functions and two procedures. From the packages i am able to execute the two procedures and one of the function.
    So i guess it is not a problem with the access permissions. The function that i am trying to call say function I has got 3 OUT
    parameters and 1 IN parameter. the Function returns a record. When i try to execute this function i get an error. Can you please let me know as to how exactly i need to call this function from the SQL prompt...
    thanx in advance
    null

    Hi Anand,
    As your function has 3 OUT parameters and it returns a record you can not just call it from SQL Plus. You need to write small PL/SQL program and use variables to hold the OUT values and the returned record.
    Good Luck,
    RajKiran
    null

  • How to return multiple record with Oracle Native Web Service?

    Dear all,
    I would like to know that the oracle native web service can be able to return multiple records to client or not?
    I successfully developed the oracle native web service for returning single record but the next challenge is to develop web service in order to return multiple record (like Employees data base on each department)
    Thank and Regards,
    Zenoni

    I successfully developed the oracle native web service for returning single record but the next challenge is to develop web service in order to return multiple record (like Employees data base on each department)You could return a list (multiple values/records) in XML format (using XMLType or CLOB), or CSV, or JSON, or whatever.
    function get_employees (p_department_id in number) return clob
    as
    begin
      return 'your_xml_string_here';
    end get_employees;It would be up to the client (the caller of the web service) to extract the values from whatever format you decide upon, of course.
    - Morten
    http://ora-00001.blogspot.com

  • Returning Mutiple Addresses as a Single Record + current addresses

    Hello All,
    I have to return students home and dorm addresses as a single record.
    Need to go from something like this:
    LAST_NAME     FIRST_NAME     ADDY_TYPE   ADDRESS             ZIP
    Smith                John             HOME         123 Awesome St     10003
    Smith               John               DORM         Oak Quad             10013To this desired format:
    LAST_NAME  FIRST_NAME     ADDY_TYPE  ADDRESS         ZIP        ADDY_TYPE     ADDRESS     ZIP
    Smith            John      HOME        123 Awesome St  10003   DORM            Oak Quad     10013Also need to get their latest addresses by date.
    The database keeps records of every place the students have move from dorm to dorm
    and some students permanent residences ("HOME") has changed as well.
    Would like to return only one DORM address and only one HOME address
    for every student.
    So I'm looking at possibly a CASE function to put it on one line/record and a RANK BY() or DENSE_RANK to determine the latest addresses.
    Hope I'm making some sense and as always much appreciation for any help. Thanks.

    Hi,
    user11137889 wrote:
    Also need to get their latest addresses by date. Then you must have a column (I'll call it addy_date) that can be used to tell you which is the latest.
    The database keeps records of every place the students have move from dorm to dorm
    and some students permanent residences ("HOME") has changed as well.
    Would like to return only one DORM address and only one HOME address
    for every student.
    So I'm looking at possibly a CASE function to put it on one line/record and a RANK BY() or DENSE_RANK to determine the latest addresses. I think that's the best way, though if you want only one of each type, then ROW_NUMBER is more appropriate than RANK or DENSE_RANK.
    WITH    got_rnum     AS
         SELECT     last_name
         ,     first_name
         ,     addy_type
         ,     address
         ,     zip
         ,     ROW_NUMBER () OVER ( PARTITION BY  last_name
                                   ,                    first_name
                             ,             addy_type
                             ORDER BY        addy_date     DESC     NULLS LAST
                           ) AS rnum
         FROM    table_x
    --     WHERE     ...          -- Any filtering goes here
    SELECT    last_name
    ,       first_name
    ,       MIN (CASE WHEN addy_type = 'HOME' THEN address END)     AS home_address
    ,       MIN (CASE WHEN addy_type = 'HOME' THEN zip     END)     AS home_zip
    ,       MIN (CASE WHEN addy_type = 'DORM' THEN address END)     AS dorm_address
    ,       MIN (CASE WHEN addy_type = 'DORM' THEN zip     END)     AS dorm_zip
    FROM       got_rnum
    WHERE       rnum     = 1
    GROUP BY  last_name
    ,            first_name
    ;This assumes the combination (last_name, first_name) uniquely identifies a student.
    If you'd post CREATE TABLE and INSERT statements for some sample data, then I could test this.

  • Function Module to convert multiple records into single record and vice-ver

    hi,
    i have a requirement to convert 10 records in an internal table to single record which should be passed
    to a single variable and store in the database.Kindly let me know is there any function module
    which meets my requirement. Also i need to do split one single record to 10 records each of
    say 65 length interval.
    kindly provide me if there is nay functinon module as such.
    I can do with ABAP-OOPS.Please suggest function module.

    I dont think such FM exists, but if you wanna code one it would be simple. Just loop through the internal table, keep concatenating the currently processing record into a long character variable to convert 10 records into one record.

  • PipeLine Function Taking time to return Table record

    Hi,
    I want to use a function in join clause. so i go for pipelined function(using for loop to get record & 1 more loop to fetch in table type variable). i achieved what i required. but problem is it takes much time to fetch data. is there any other approach which returns table records without pipelined function.
    please suggest me a better approach as soon as possible.

    Hi,
    Thanks all for the quick response.
    I am using oracle 10g
    this is the table details & the entire function.
    Create object & table type to use in the function
    CREATE OR REPLACE TYPE SYSADM.STR_TYPE AS OBJECT(COLUMNVALUE VARCHAR2(8),FromNo Int,ToNo Int)
    CREATE OR REPLACE TYPE SYSADM.STR_ARRAY AS TABLE OF STR_TYPE
    table involved
    View : VesselType
    column : Code varchar2(5)
    Table : T065_SHIP
    column : SKIPS_KODE varchar2(4)
    CODE_SHIPTYPE varchar2(5)
    Table : SelsKap
    column : SELSKAPSKODE varchar2(4)
    Table : t041_shiptypeusers
    column : Code_ShipType varchar2(5)
    USERID varchar2(8)
    View : PositionBook
    column : VesselCode varchar2(8)
    VoyageNo integer
    Company varchar2(4)
    Table : T62_BRUKER_SELSKAP
    column : SELSKAPSKODE varchar2(4)
    BRUKER varchar2(8)
    Pipelined function
    CREATE OR REPLACE FUNCTION SYSADM.TF_ShiporShipTypeByUser
    In_UserName IN VARCHAR2,
    In_Type IN VARCHAR2,
    In_VesselCode IN VARCHAR2,
    In_CompanyHistory IN NUMBER DEFAULT 0
    RETURN str_array PIPELINED AS
    l_ShipTypeUser NUMBER(10,0);
    l_CompanyUser NUMBER(10,0);
    l_UseCompanyHistory NUMBER(1,0);
    l_Snicsacct NUMBER(1,0);
    BEGIN
    BEGIN
    SELECT shiptype_user,
    company_user
    INTO l_ShipTypeUser,
    l_CompanyUser
    FROM User_Segregation;
    EXCEPTION
    WHEN OTHERS THEN
    l_ShipTypeUser := NULL;
    l_CompanyUser := NULL;
    END;
    BEGIN
    SELECT 1 INTO l_Snicsacct
    FROM DUAL
    WHERE NOT EXISTS ( SELECT 1 FROM sn_user_cfg WHERE UserID='SNICS' and CfgID='ACCTSYS');
    EXCEPTION
    WHEN OTHERS THEN
    NULL;
    END;
    IF In_CompanyHistory = 1
    THEN
    BEGIN
    SELECT CfgData
    INTO l_UseCompanyHistory
    FROM SN_User_Cfg
    WHERE CfgID = 'USE COMPANY HISTORY'
    AND UserID = 'SNICS';
    EXCEPTION
    WHEN OTHERS THEN
    l_UseCompanyHistory := 0;
    END;
    END IF;
    IF In_UserName = 'SYSADM' OR (l_CompanyUser = 0 AND l_ShipTypeUser = 0)
    OR (l_CompanyUser = 1 and l_Snicsacct =1 ) or (In_CompanyHistory = 0 and l_CompanyUser = 1 and In_Type ='ShipType')
    OR (l_ShipTypeUser = 1 and In_Type = 'Company')
    THEN
    BEGIN
    IF In_Type = 'ShipType'
    THEN
    BEGIN
    FOR cur IN (SELECT Code ShipCode
    , 1 VoyageFrom
    , 999999999 VoyageTo
    FROM VesselType )
    LOOP
    PIPE ROW(str_type(cur.ShipCode,cur.VoyageFrom,cur.VoyageTo));
    END LOOP;
    RETURN;
    END;
    ELSIF In_Type = 'Ship'
    THEN
    BEGIN
    FOR cur IN (SELECT SKIPS_KODE ShipCode
    , 1 VoyageFrom
    , 999999999 VoyageTo
    FROM T065_SHIP
    WHERE SKIPS_KODE = NVL(In_VesselCode,SKIPS_KODE ))
    LOOP
    PIPE ROW(str_type(cur.ShipCode,cur.VoyageFrom,cur.VoyageTo));
    END LOOP;
    RETURN;
    END;
    ELSIF In_Type = 'Company'
    THEN
    BEGIN
    FOR cur IN (SELECT SELSKAPSKODE ShipCode
    , NULL VoyageFrom
    , NULL VoyageTo
    FROM SelsKap)
    LOOP
    PIPE ROW(str_type(cur.ShipCode,cur.VoyageFrom,cur.VoyageTo));
    END LOOP;
    RETURN;
    END;
    END IF;
    END;
    ELSE
    IF In_Type = 'Ship'
    THEN
    BEGIN
    IF l_ShipTypeUser =1
    THEN
    BEGIN
    FOR cur IN (SELECT S.SKIPS_KODE ShipCode
    , 1 FromVoyage
    , 999999999 ToVoyage
    FROM T065_SHIP S
    JOIN t041_shiptypeusers U
    ON S.CODE_SHIPTYPE = U.Code_ShipType
    AND USERID = In_UserName
    WHERE S.SKIPS_KODE = NVL(In_VesselCode, S.SKIPS_KODE)
    GROUP BY S.SKIPS_KODE)
    LOOP
    PIPE ROW(str_type(cur.ShipCode,cur.FromVoyage,cur.ToVoyage));
    END LOOP;
    RETURN;
    END;
    ELSIF l_CompanyUser = 1
    THEN
    BEGIN
    IF l_UseCompanyHistory = 1 AND In_CompanyHistory = 1
    THEN
    FOR cur IN (SELECT a.VesselCode ShipCode
    , a.VoyageNo VoyageFrom
    , a.VoyageNo VoyageTo
    FROM PositionBook a
    JOIN T62_BRUKER_SELSKAP b
    ON a.Company = b.SELSKAPSKODE
    AND b.BRUKER = In_UserName
    WHERE a.VesselCode = NVL(In_VesselCode, a.VesselCode)
    UNION
    SELECT a.VesselCode ShipCode
    , a.VoyageNo VoyageFrom
    , a.VoyageNo VoyageTo
    FROM PositionBook a
    LEFT JOIN T62_BRUKER_SELSKAP b
    ON a.company = b.SELSKAPSKODE
    WHERE a.VesselCode = NVL(In_VesselCode, a.VesselCode)
    AND b.SELSKAPSKODE IS NULL
    GROUP BY a.VesselCode,
    a.VoyageNo,
    a.VoyageNo)
    LOOP
    PIPE ROW(str_type(cur.ShipCode,cur.VoyageFrom,cur.VoyageTo));
    END LOOP;
    RETURN;
    ELSE
    FOR cur IN (SELECT a.SKIPS_KODE ShipCode
    , 1 VoyageFrom
    , 999999999 VoyageTo
    FROM T065_SHIP a
    JOIN T62_BRUKER_SELSKAP b
    ON a.Company = b.SELSKAPSKODE
    AND b.BRUKER = In_UserName
    WHERE a.SKIPS_KODE = NVL(In_VesselCode, a.SKIPS_KODE)
    AND NVL(l_UseCompanyHistory,0) = 0
    UNION
    SELECT a.SKIPS_KODE ShipCode
    , 1 VoyageFrom
    , 999999999 VoyageTo
    FROM T065_SHIP a
    LEFT JOIN T62_BRUKER_SELSKAP b
    ON a.company = b.SELSKAPSKODE
    WHERE a.SKIPS_KODE = NVL(In_VesselCode, a.SKIPS_KODE)
    AND b.SELSKAPSKODE IS NULL
    GROUP BY a.SKIPS_KODE)
    LOOP
    PIPE ROW(str_type(cur.ShipCode,cur.VoyageFrom,cur.VoyageTo));
    END LOOP;
    RETURN;
    END IF;
    END;
    END IF;
    END;
    ELSIF In_Type = 'ShipType'
    THEN
    IF l_ShipTypeUser = 1
    THEN
    BEGIN
    FOR cur IN (SELECT S.CODE_SHIPTYPE ShipCode
    , 1 VoyageFrom
    , 999999999 VoyageTo
    FROM T065_SHIP S
    JOIN t041_shiptypeusers U
    ON S.CODE_SHIPTYPE = U.Code_ShipType
    AND USERID = In_UserName
    WHERE S.SKIPS_KODE = NVL(In_VesselCode, S.SKIPS_KODE)
    GROUP BY S.CODE_SHIPTYPE)
    LOOP
    PIPE ROW(str_type(cur.ShipCode,cur.VoyageFrom,cur.VoyageTo));
    END LOOP;
    RETURN;
    END;
    ELSIF l_CompanyUser = 1
    THEN
    IF l_UseCompanyHistory = 1 AND In_CompanyHistory = 1
    THEN
    BEGIN
    FOR cur IN (SELECT a.VesselType ShipCode
    , a.VoyageNo VoyageFrom
    , a.VoyageNo VoyageTo
    FROM PositionBook a
    JOIN T62_BRUKER_SELSKAP b
    ON a.COMPANY = b.SELSKAPSKODE
    AND b.BRUKER = In_UserName
    WHERE a.VesselCode = NVL(In_VesselCode,a.VesselCode)
    UNION
    SELECT a.VesselType ShipCode
    , a.VoyageNo VoyageFrom
    , a.VoyageNo VoyageTo
    FROM PositionBook a
    LEFT JOIN T62_BRUKER_SELSKAP b
    ON a.company = b.SELSKAPSKODE
    WHERE a.VesselCode = NVL(In_VesselCode, a.VesselCode)
    AND b.SELSKAPSKODE IS NULL
    GROUP BY a.VesselType,
    a.VoyageNo,
    a.VoyageNo)
    LOOP
    PIPE ROW(str_type(cur.ShipCode,cur.VoyageFrom,cur.VoyageTo));
    END LOOP;
    RETURN;
    END;
    ELSE
    BEGIN
    FOR cur IN (SELECT S.CODE_SHIPTYPE ShipCode
    , 1 VoyageFrom
    , 999999999 VoyageTo
    FROM T065_SHIP S
    JOIN T62_BRUKER_SELSKAP b
    ON S.company = b.SELSKAPSKODE
    AND B.BRUKER = In_UserName
    WHERE S.SKIPS_KODE = NVL(In_VesselCode, S.SKIPS_KODE)
    AND NVL(l_UseCompanyHistory,0) = 0
    UNION
    SELECT S.CODE_SHIPTYPE ShipCode
    , 1 VoyageFrom
    , 999999999 VoyageTo
    FROM T065_SHIP S
    LEFT JOIN T62_BRUKER_SELSKAP b
    ON S.company = b.SELSKAPSKODE
    WHERE S.SKIPS_KODE = NVL(In_VesselCode, S.SKIPS_KODE)
    AND b.SELSKAPSKODE IS NULL)
    LOOP
    PIPE ROW(str_type(cur.ShipCode,cur.VoyageFrom,cur.VoyageTo));
    END LOOP;
    RETURN;
    END;
    END IF;
    END IF;
    ELSIF In_Type = 'Company'
    THEN
    BEGIN
    FOR cur IN (SELECT a.SELSKAPSKODE ShipCode
    , NULL VoyageFrom
    , NULL VoyageTo
    FROM Selskap a
    JOIN T62_BRUKER_SELSKAP b
    ON a.SELSKAPSKODE = b.SELSKAPSKODE
    WHERE b.BRUKER = In_UserName
    Union All
    Select a.SELSKAPSKODE ShipCode
    , NULL VoyageFrom
    , NULL VoyageTo
    From Selskap a
    LEFT JOIN T62_BRUKER_SELSKAP b
    ON a.SELSKAPSKODE = b.SELSKAPSKODE
    Where b.SELSKAPSKODE IS NULL
    GROUP BY a.SELSKAPSKODE)
    LOOP
    PIPE ROW(str_type(cur.ShipCode,cur.VoyageFrom,cur.VoyageTo));
    END LOOP;
    RETURN;
    END;
    END IF;
    END IF;
    END;
    select statement which i call the function it takes minimum 6 seconds to execute. It gives 8339 records
    WITH deftbl AS ( SELECT /*+ CACHE(deftbl) */
    /*+ result_cache */
    a.VesselCode,
    a.VoyageNo,
    CASE a.BallastLeg When 0
    THEN MIN(a.ArrivalDate)
    ELSE NVL(( SELECT MAX(DepartureDate)
    FROM PositionBook b
    WHERE b.VesselCode = a.VesselCode
    AND b.VoyageNo = (Select MAX(VoyageNo) From PositionBook c Where c.VesselCode = a.VesselCode and c.VoyageNo<a.VoyageNo)
    ),MIN(a.ArrivalDate))
    END AS StartOfVoyage,
    MAX(DepartureDate) EndOfVoyage
    FROM PositionBook a
    JOIN TABLE(*TF_ShiporShipTypeByUser*('BKA', 'Ship', NULL, 1)) D        /*Calling the function*/
    ON D.ColumnValue = a.VesselCode
    AND a.VoyageNo BETWEEN D.FromVoyageNo AND D.ToVoyageNo
    GROUP BY VesselCode,VoyageNo,a.BallastLeg )
    SELECT /*+ result_cache */
    ROW_NUMBER() OVER(PARTITION BY a.VesselCode ORDER BY a.VoyageNo DESC) as "Row"
    ,a.VesselCode
    ,v.Name AS VesselName
    ,a.VoyageNo
    ,c.StartOfVoyage AS FromPort
    ,c.EndOfVoyage AS ToPort
    /*,a.FROMPORT
    ,a.TOPORT*/
    , CASE
    WHEN ( SELECT PortName
    FROM PositionBook b
    WHERE b.VesselCode = a.VesselCode
    AND b.VoyageNo = a.VoyageNo
    AND SYSDATE BETWEEN ArrivalDate AND DepartureDate ) IS NOT NULL
    THEN ( SELECT FIRST_VALUE(PortName) OVER(PARTITION BY b.vesselcode,b.VoyageNo ORDER BY b.vesselcode,b.VoyageNo,b.ArrivalDate,b.secondarytime)
    FROM PositionBook b
    WHERE b.VesselCode = a.VesselCode
    AND b.VoyageNo = a.VoyageNo
    AND SYSDATE BETWEEN ArrivalDate AND DepartureDate
    AND ROWNUM=1
    WHEN SYSDATE BETWEEN c.StartOfVoyage AND c.EndOfVoyage
    THEN ( SELECT 'Steam From '||FIRST_VALUE(UPPER(PortName)) OVER(PARTITION BY b.vesselcode,b.VoyageNo ORDER BY b.vesselcode,b.VoyageNo,b.ArrivalDate desc,b.secondarytime desc)
    FROM POSITIONBOOK b
    WHERE b.VesselCode = a.VesselCode AND b.VoyageNo = a.VoyageNo
    AND b.ArrivalDate<SYSDATE
    AND ROWNUM=1
    WHEN (c.StartOfVoyage-SYSDATE)>0
    THEN 'Voyage Not Started'
    WHEN (c.EndOfVoyage-SYSDATE)<0
    THEN 'Voyage Completed'
    ELSE Null
    END "Location"
    ,( SELECT MIN(b.PortName) KEEP(DENSE_RANK FIRST ORDER BY b.ArrivalDate,b.secondarytime) OVER(PARTITION BY b.VesselCode,b.VoyageNo)
    FROM POSITIONBOOK b
    WHERE b.VesselCode = a.VesselCode AND b.VoyageNo = a.VoyageNo
    AND b.ArrivalDate>SYSDATE
    AND ROWNUM=1
    ) AS NextPort
    , ( SELECT MIN(b.ArrivalDate) KEEP(DENSE_RANK FIRST ORDER BY b.ArrivalDate,b.secondarytime) OVER(PARTITION BY b.VesselCode,b.VoyageNo)
    FROM POSITIONBOOK b
    where b.VesselCode = a.VesselCode AND b.VoyageNo = a.VoyageNo
    AND b.ArrivalDate>SYSDATE
    AND ROWNUM=1
    ) AS NextETA
    ,a.STATUS VoyageStatus
    ,a.Trade
    ,UFN_MyVoyConcatinate_Values('FIXNOTE', a.VesselCode, a.VoyageNo) FixNote
    ,UFN_MyVoyConcatinate_Values('CHARTERER', a.VesselCode, a.VoyageNo) Charterer
    ,CASE WHEN st.CurrentStatus=0
    THEN 1
    WHEN st.CurrentStatus=1
    THEN 0
    ELSE st.CurrentStatus
    END AS CurrentStatus
    FROM Positionbook a
    JOIN deftbl c
    ON a.VesselCode = c.VesselCode
    AND a.VoyageNo = c.VoyageNo
    JOIN Vessel v
    ON v.Code = c.VesselCode
    LEFT JOIN GTT_VOYAGESTATUS st
    ON st.VesselCode = c.Vesselcode
    AND st.VoyageNo = c.VoyageNo
    GROUP BY a.VesselCode
    , v.Name
    , a.VoyageNo
    , c.StartOfVoyage
    , c.EndOfVoyage
    /*, a.FROMPORT
    , a.TOPORT*/
    , a.Status
    , a.Trade
    , st.CurrentStatus;
    Note:
    i changed the function without pipelined also. but it doesnt show much difference
    non pipelined function
    CREATE OR REPLACE FUNCTION TF_ShiporShipTypeByUser_nonp
    In_UserName IN VARCHAR2,
    In_Type IN VARCHAR2,
    In_VesselCode IN VARCHAR2,
    In_CompanyHistory IN NUMBER DEFAULT 0
    RETURN str_array AS
    l_ShipTypeUser NUMBER(10,0);
    l_CompanyUser NUMBER(10,0);
    l_UseCompanyHistory NUMBER(1,0);
    l_Snicsacct NUMBER(1,0);
    l_str_array str_array:=str_array();
    BEGIN
    BEGIN
    SELECT shiptype_user,
    company_user
    INTO l_ShipTypeUser,
    l_CompanyUser
    FROM User_Segregation;
    EXCEPTION
    WHEN OTHERS THEN
    l_ShipTypeUser := NULL;
    l_CompanyUser := NULL;
    END;
    BEGIN
    SELECT 1 INTO l_Snicsacct
    FROM DUAL
    WHERE NOT EXISTS ( SELECT 1 FROM sn_user_cfg WHERE UserID='SNICS' and CfgID='ACCTSYS');
    EXCEPTION
    WHEN OTHERS THEN
    NULL;
    END;
    IF In_CompanyHistory = 1
    THEN
    BEGIN
    SELECT CfgData
    INTO l_UseCompanyHistory
    FROM SN_User_Cfg
    WHERE CfgID = 'USE COMPANY HISTORY'
    AND UserID = 'SNICS';
    EXCEPTION
    WHEN OTHERS THEN
    l_UseCompanyHistory := 0;
    END;
    END IF;
    IF In_UserName = 'SYSADM' OR (l_CompanyUser = 0 AND l_ShipTypeUser = 0)
    OR (l_CompanyUser = 1 and l_Snicsacct =1 ) or (In_CompanyHistory = 0 and l_CompanyUser = 1 and In_Type ='ShipType')
    OR (l_ShipTypeUser = 1 and In_Type = 'Company')
    THEN
    BEGIN
    IF In_Type = 'ShipType'
    THEN
    BEGIN
    SELECT STR_TYPE(Code,1,999999999)
    BULK COLLECT INTO l_str_array
    FROM VesselType;
    RETURN l_str_array;
    END;
    ELSIF In_Type = 'Ship'
    THEN
    BEGIN
    SELECT STR_TYPE(SKIPS_KODE,1,999999999)
    BULK COLLECT INTO l_str_array
    FROM T065_SHIP
    WHERE SKIPS_KODE = NVL(In_VesselCode,SKIPS_KODE);
    RETURN l_str_array;
    END;
    ELSIF In_Type = 'Company'
    THEN
    BEGIN
    SELECT STR_TYPE(SELSKAPSKODE,NULL,NULL)
    BULK COLLECT INTO l_str_array
    FROM SelsKap;
    RETURN l_str_array;
    END;
    END IF;
    END;
    ELSE
    IF In_Type = 'Ship'
    THEN
    BEGIN
    IF l_ShipTypeUser =1
    THEN
    BEGIN
    SELECT STR_TYPE(S.SKIPS_KODE,1,999999999)
    BULK COLLECT INTO l_str_array
    FROM T065_SHIP S
    JOIN t041_shiptypeusers U
    ON S.CODE_SHIPTYPE = U.Code_ShipType
    AND USERID = In_UserName
    WHERE S.SKIPS_KODE = NVL(In_VesselCode, S.SKIPS_KODE)
    GROUP BY S.SKIPS_KODE;
    RETURN l_str_array;
    END;
    ELSIF l_CompanyUser = 1
    THEN
    BEGIN
    IF l_UseCompanyHistory = 1 AND In_CompanyHistory = 1
    THEN
    SELECT STR_TYPE(ShipCode,VoyageFrom,VoyageTo)
    BULK COLLECT INTO l_str_array
    FROM ( SELECT a.VesselCode ShipCode
    , a.VoyageNo VoyageFrom
    , a.VoyageNo VoyageTo
    FROM PositionBook a
    JOIN T62_BRUKER_SELSKAP b
    ON a.Company = b.SELSKAPSKODE
    AND b.BRUKER = In_UserName
    WHERE a.VesselCode = NVL(In_VesselCode, a.VesselCode)
    UNION
    SELECT a.VesselCode ShipCode
    , a.VoyageNo VoyageFrom
    , a.VoyageNo VoyageTo
    FROM PositionBook a
    LEFT JOIN T62_BRUKER_SELSKAP b
    ON a.company = b.SELSKAPSKODE
    WHERE a.VesselCode = NVL(In_VesselCode, a.VesselCode)
    AND b.SELSKAPSKODE IS NULL
    GROUP BY a.VesselCode,
    a.VoyageNo,
    a.VoyageNo);
    RETURN l_str_array;
    ELSE
    SELECT STR_TYPE(ShipCode,VoyageFrom,VoyageTo)
    BULK COLLECT INTO l_str_array
    FROM (SELECT a.SKIPS_KODE ShipCode
    , 1 VoyageFrom
    , 999999999 VoyageTo
    FROM T065_SHIP a
    JOIN T62_BRUKER_SELSKAP b
    ON a.Company = b.SELSKAPSKODE
    AND b.BRUKER = In_UserName
    WHERE a.SKIPS_KODE = NVL(In_VesselCode, a.SKIPS_KODE)
    AND NVL(l_UseCompanyHistory,0) = 0
    UNION
    SELECT a.SKIPS_KODE ShipCode
    , 1 VoyageFrom
    , 999999999 VoyageTo
    FROM T065_SHIP a
    LEFT JOIN T62_BRUKER_SELSKAP b
    ON a.company = b.SELSKAPSKODE
    WHERE a.SKIPS_KODE = NVL(In_VesselCode, a.SKIPS_KODE)
    AND b.SELSKAPSKODE IS NULL
    GROUP BY a.SKIPS_KODE);
    RETURN l_str_array;
    END IF;
    END;
    END IF;
    END;
    ELSIF In_Type = 'ShipType'
    THEN
    IF l_ShipTypeUser = 1
    THEN
    BEGIN
    SELECT STR_TYPE(ShipCode,VoyageFrom,VoyageTo)
    BULK COLLECT INTO l_str_array
    FROM (SELECT S.CODE_SHIPTYPE ShipCode
    , 1 VoyageFrom
    , 999999999 VoyageTo
    FROM T065_SHIP S
    JOIN t041_shiptypeusers U
    ON S.CODE_SHIPTYPE = U.Code_ShipType
    AND USERID = In_UserName
    WHERE S.SKIPS_KODE = NVL(In_VesselCode, S.SKIPS_KODE)
    GROUP BY S.CODE_SHIPTYPE);
    RETURN l_str_array;
    END;
    ELSIF l_CompanyUser = 1
    THEN
    IF l_UseCompanyHistory = 1 AND In_CompanyHistory = 1
    THEN
    BEGIN
    SELECT STR_TYPE(ShipCode,VoyageFrom,VoyageTo)
    BULK COLLECT INTO l_str_array
    FROM ( SELECT a.VesselType ShipCode
    , a.VoyageNo VoyageFrom
    , a.VoyageNo VoyageTo
    FROM PositionBook a
    JOIN T62_BRUKER_SELSKAP b
    ON a.COMPANY = b.SELSKAPSKODE
    AND b.BRUKER = In_UserName
    WHERE a.VesselCode = NVL(In_VesselCode,a.VesselCode)
    UNION
    SELECT a.VesselType ShipCode
    , a.VoyageNo VoyageFrom
    , a.VoyageNo VoyageTo
    FROM PositionBook a
    LEFT JOIN T62_BRUKER_SELSKAP b
    ON a.company = b.SELSKAPSKODE
    WHERE a.VesselCode = NVL(In_VesselCode, a.VesselCode)
    AND b.SELSKAPSKODE IS NULL
    GROUP BY a.VesselType,
    a.VoyageNo,
    a.VoyageNo);
    RETURN l_str_array;
    END;
    ELSE
    BEGIN
    SELECT STR_TYPE(ShipCode,VoyageFrom,VoyageTo)
    BULK COLLECT INTO l_str_array
    FROM ( SELECT S.CODE_SHIPTYPE ShipCode
    , 1 VoyageFrom
    , 999999999 VoyageTo
    FROM T065_SHIP S
    JOIN T62_BRUKER_SELSKAP b
    ON S.company = b.SELSKAPSKODE
    AND B.BRUKER = In_UserName
    WHERE S.SKIPS_KODE = NVL(In_VesselCode, S.SKIPS_KODE)
    AND NVL(l_UseCompanyHistory,0) = 0
    UNION
    SELECT S.CODE_SHIPTYPE ShipCode
    , 1 VoyageFrom
    , 999999999 VoyageTo
    FROM T065_SHIP S
    LEFT JOIN T62_BRUKER_SELSKAP b
    ON S.company = b.SELSKAPSKODE
    WHERE S.SKIPS_KODE = NVL(In_VesselCode, S.SKIPS_KODE)
    AND b.SELSKAPSKODE IS NULL);
    RETURN l_str_array;
    END;
    END IF;
    END IF;
    ELSIF In_Type = 'Company'
    THEN
    BEGIN
    SELECT STR_TYPE(ShipCode,VoyageFrom,VoyageTo)
    BULK COLLECT INTO l_str_array
    FROM ( SELECT a.SELSKAPSKODE ShipCode
    , NULL VoyageFrom
    , NULL VoyageTo
    FROM Selskap a
    JOIN T62_BRUKER_SELSKAP b
    ON a.SELSKAPSKODE = b.SELSKAPSKODE
    WHERE b.BRUKER = In_UserName
    Union All
    Select a.SELSKAPSKODE ShipCode
    , NULL VoyageFrom
    , NULL VoyageTo
    From Selskap a
    LEFT JOIN T62_BRUKER_SELSKAP b
    ON a.SELSKAPSKODE = b.SELSKAPSKODE
    Where b.SELSKAPSKODE IS NULL
    GROUP BY a.SELSKAPSKODE);
    RETURN l_str_array;
    END;
    END IF;
    END IF;
    END;please kindly provide me your valuable suggestions
    Edited by: ganex27lin on Mar 16, 2011 1:54 AM

  • Mac mail search function is not working. Any search term returns all records.

    Mac mail search function is not working. Any search term returns all records.

    hi eric. many thanks.
    i will have to read these links closer but what i meant to say is that the hard drive space that was being taken up seemed like it suddenly jumped way up because i had just gotten through a process in the last month where i am storing all my My Documents data on my Mac Pro. i am doing this in order to decide whether i should just keep it ALL on my Mac Pro and use ChronoSync to sync /some/ of it to my MBP.
    so if i look in the Documents folder on my Mac Pro i have a ton of folders that i have created with a ton of data. if i look in the Documents folder on my MBP there are NO folders that have data in them that i created. there are other folders such as folders that various software created but what i mean to point out is that there was a LOT of available space on my HD until recently.
    i am wondering if there is some way that running the Mail re-index (it then ran some kind of "Importing" routine) or by syncing my Photostream to the MBP caused a huge jump in data on this drive. if it is the photostream sync i can just take this off or see if it will sync more selectively. if it is something to do with mac mail jumping in size i am not sure why this would happen or what to do about it.
    does that question make sense?
    i mean, before i did these two operations my recollection is that i would have had 130 GB on the hard drive (really just guessing here) and now there is like 218 GB on the hard drive and i don't know where all this came from...

  • Functions returning records

    I have a function that returns a record, a row type from a table I selected
    In a procedure I now try to call values from this function by calling
    function.value1
    however I get the error
    subprogram or cursor 'function' reference is out of scope
    does anyone know what is wrong?
    thanks

    I can only provide some pattern
    -- your function:
    create or replace function your_function(p_param(s) in data_type) return your_table%rowtype is
      return_value your_table%rowtype;
    begin
      < your processing here (return_value gets a value assigned) >
      return return_value;
    end;
    -- your procedure:
    create or replace procedure your_procedure(p_param(s) in data_type) is
      function_value your_table%rowtype;
      some_variable data_type;
    begin
      < your processing here >
      function_value := your_function(p_param(s));
      some_variable := function_value.rowtype_column_name;
    end;Regards
    Etbin

  • Function returning string.  Data type question

    Hello all,
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    Our database has a parent record master_member_record_id & and children of those records member_record_id. I wrote a function which returns the master record for the child.
    eg. get_master(member_record_id). simple enough.
    I have wrote the opposite of this also, get_member_records(master_member_record_id). Obviously this function has multiple records to return so I have it set to return a listagg string with ',' separation. They want to be able to use this function as follows:
    select * from member_table where member_record_id in (get_member_records(master_member_record_id));
    or something similar, I realize this is a data type issue here, wondering if this is even possible. What do you think?
    Thanks in advance for your criticism/help,
    Chris

    My disagreement is with how pipeline table functionality is used.
    Instead of this (what it sounds like the OP is doing but returning CSV format)
    create or replace type TClientIdArray is table of number;
    create or replace function GetClientIDs( parentID number ) return TClientIdArray is
      array TClientIdArray;
    begin
      select
        client_id bulk collect into array
      from master_table
      where parent_id = parentID;
      return( array );
    end;A pipeline would look as follows:
    create or replace type TClientIdArray is table of number;
    create or replace function GetClientIDs( parentID number ) return TClientIdArray pipelined is
    begin
      for c in (select
                   client_id
                 from master_table
                 where parent_id = parentID ) loop
        pipe row( c.client_id );
      end loop;
      return;
    end;The first method is in fact more sensible in this case, especially when used from PL/SQL. A single SQL call/context switch to get a list of client identifiers. The issues with the first method are
    - cannot effectively deal with a large data set of client identifiers
    - would be suboptimal to use this function in subsequent SQL
    - if called by a client, a ref cursor (not collection) should be returned
    But assuming that the list of client identifiers are needed to be stepped through via complex PL/SQL app processing, using a (small) array is fine (assuming that concurrency/locking is not needed via a FOR UPDATE on the select that identifies the client identifiers to process).
    A pipeline in this case does not do anything better. It introduces more moving parts - as a native PL/SQL can no longer be used to get the collection and step through it. A TABLE() SQL function is needed, a SQL statement, and more context switching.
    The pipeline is simply an unnecessary layer between the code wanting to use the client identifiers and the SQL statement supplying the client identifiers. This approach of SQL -calls-> PIPELINE -calls-> MORE SQL is invariable wrong - unless the pipeline (PL/SQL code) does something very funky with the data from its SQL call, prior to piping it, that cannot be done using SQL.
    If the "user" of that client identifiers is SQL code, then both the above methods are flawed. As this code is already SQL, why use PL/SQL to call more SQL code? Simply use the SQL code/logic that supplies the client identifier list directly in the SQL code that needs the client identifiers. This means something like SQL JOIN, EXISTS, or IN clauses.

  • Error with function returning "multiple" values

    Hi
    i am trying to write a function to return "multiple" values
    however, it returned the following error during compilation
    Compilation errors for FUNCTION sch1.myfn
    Error: PLS-00382: expression is of wrong type
    Line: 19
    Text: RETURN V_res;
    Error: PL/SQL: Statement ignored
    Line: 19
    Text: RETURN V_res;
    ques :
    1 - is there a need to always declare a table ? as it'll only return a single record with multiple columns
    CREATE OR REPLACE TYPE result as table of result_t;
    CREATE OR REPLACE TYPE result_t as object
    (user varchar2(100), comments varchar2(4000));
    CREATE OR REPLACE FUNCTION myfn (IN_ID IN VARCHAR2, IN_BEGIN IN DATE) RETURN result IS
    type V_res_t is RECORD (user varchar2(100), comments varchar2(4000));
    V_res V_res_t;
    BEGIN
    select a.user, a.comment
    into V_res.user, V_res.comments
    from view1     A,
    (select distinct id,
    begin_time,
    max(time) over(order by time desc) max_time from view2 b
    where id = IN_LOTID
    and begin_time = IN_BEGIN) b
    where a.id = b.id
    and a.begin_time = b.begin_time
    and a.time = max_time
    and a.id = IN_ID
    and a.begin_time = IN_BEGIN;
    RETURN V_res; --> this is the line that the system keep complaining
    END;
    Note : pls ignore whether the return results is correct but i am expecting it to always return a single row
    pls advise
    tks & rgds

    And if you really want to return a type as a table of, work with PIPELINED function :
    SQL> CREATE OR REPLACE TYPE result_t as object
      2  (user# varchar2(100), comments varchar2(4000));
      3  /
    Type created.
    SQL> CREATE OR REPLACE TYPE result as table of result_t;
      2  /
    Type created.
    SQL>
    SQL> CREATE OR REPLACE FUNCTION myfn (IN_ID IN VARCHAR2, IN_BEGIN IN DATE) RETURN result
      2  pipelined is
      3  user# varchar2(100);
      4  comments varchar2(4000);
      5  BEGIN
      6  pipe row (result_t(user#,comments));
      7  return;
      8  END;
      9  /
    Function created.
    SQL>PS: there is non sense to use pipelined function in my example, it is just an example to return a type as table.
    Nicolas.

  • Report- Pl/sql function returning sql query parsing page items as text?

    Hi Team,
    I am facing a strange issue .
    I have four page items namely
    1)JOB_CODE
    2)MIN_EXP
    3) MAX_EXP
    4) SOURCES1
    I have a report of the type "Pl/sql function returning sql query"
    declare
    v_sql varchar2(4000);
    begin
    if (:JOB_CODE IS NOT NULL and :MIN_EXP IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
    v_sql:= 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
    elsif (:JOB_CODE IS NULL and :MIN_EXP IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
    v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
    elsif (:MIN_EXP IS NULL and :JOB_CODE IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
    v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where v_experience_years <= :MAX_EXP and V_REQUIREMENT = :JOB_CODE and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
    elsif (:MAX_EXP is null and :JOB_CODE IS NOT NULL and :MIN_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
    v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
    end if;
    insert into query_list values (v_sql);
    insert into debug values (:JOB_CODE , :MIN_EXP , :MAX_EXP , :SOURCES1);
    return v_sql;
    end;
    Please not that I am insertin the query into a table called Query_list and the page item values into the table called Debug thru the pl/sql function which returns teh query.
    Now I select the data from the debug tables.
    select unique(query) from query_list;
    select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like '%:SOURCES1%'
    select * from debug;
    JOBCODE     MINEX     MAXEX     SOURCE
    21     1     10     donkeyHire
    And if I run the query in sql I get some records returned
    select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = 21 and v_experience_years >= 1 and v_experience_years <= and source like 'donkeyHire'
    V_CANDIDATE_ID     V_FNAME     V_CURRENT_EMPLOYER     V_EXPERIENCE_YEARS
    2     Vengu     Andale Tech     4
    But the record does not show up in the report!
    does this type of report parse page items as text?
    Why is it so?
    Waiting for an early reply.
    Thanks,
    venkat

    Venkat - You don't want to put ':SOURCES1' in quotes like that.
    Scott

  • Function return value == -10. Native error code -2146824584 ADOBD.Recordset: Operation is not allowed when object is closed

    I want to call Stored Procedure that return records and output parameter, from CVI
    I can get output parrameter but when I want to get records stream I recieve following wrror:
    function return value == -10. Native error code -2146824584 ADOBD.Recordset: Operation is not allowed when object is closed

    in Stored procedure I create table variable and and insert into string values
    when I remove usage of table variable the error desappear

  • Returning only records that have no entry in a specific field

    Hello,
    I'm new to this forum and relatively new to Crystal Reports, so I apologize if this information is "plain as day" somewhere.  I've been hunting for this info for quite a while and can't find anything that makes sense!
    I am trying to put together a very simple report that will return only records where a certain field is blank.
    It is an Access database, in an information management program specific to our type of business.  CR 11 software was included with the LIMS (Laboratory Information Management System), as the reports generated from the LIMS software are in CR.  I've learned enough to be able to tweak reports and make some basic reports, but I can't find a simple answer to what I think is a simple question! 
    I have the report set up to access the following fields in the database:  Invoice number, Client name, Due date, Invoice amount, and Payment Received.  This will be used as a "cross check" - not as any major accounting tool - as the Payment Received field is simply the date that the payment was received.  If no payment has been received, the field is left blank.
    I want the report to return ONLY those records where that field is blank (i. e. a list of invoices/clients whose payment has not yet been received).
    Ideally, I would also like to be able to return only those records where that field is blank OR within a certain date range (i. e. less than 30 days from the date that the report is run).  However, we'll probably only use this report a couple of times a month, so that is not as critical.
    I know I need to filter the records according to the Payment Received field, but don't know how to construct a formula that says "just show the fields where there is nothing entered."
    Thank you!
    Brenda

    This is the hardest function to find:  IsNull
    If isNull(field) then  
        //  if the above fails on a numberic field or text field then see the following two-some databases are picky.
    If IsNull(field) or field=0 then  //this one maybe needed for a numeric field
    If IsNull(field) or field=""    //  this one maybe needed for a text field
    if IsNull(field) or field=<value>
    or
    if IsNull(field) or field like <value*>
    You always want the IsNull statement to be the first statement, and it is especially usefull when testing for not equal
    If IsNull(field) or field <>  <value>

Maybe you are looking for

  • Email marked as read on outlook without actually reading

    Hi, When I get an email in outlook it shows as unread. Once the email is sent to my blackberry the status on outlook changes to read (even without me ever opening the email on outlook or the blackberry). How can I stop this? I did a lot of research b

  • How to reference SQL column value for  page item text field

    greetings, I created a simple report based on sql query. the query is select employeeid,salary from emp_tbl. under the report column i see employeeid and salary. I created a page item text field with the source type pl/sql function body. inside this

  • Office 2008 Problems

    I purchased my MacBook about a month ago. Over the past couple of weeks I have been noticing that whenever I use Word or Powerpoint my computer will slow down, the fan will get loud, and the computer gets hot. The past day or two my computer has been

  • Selection Screen for Loading Z Prog

    Hi All, I am looking for help fr experienced ppl.... In Tcode : SLIN.. there is "Call Function Interface Error" .. I have a master list of all Z prog. how can i show only those Z prog fr the master file as output whcih are having this Error "Call Fun

  • Inserting mov. into powerpoint

    I am trying to insert a movie from Kodak Easyshare (uses quicktime) that is a mov. file. Windows will not recognize it and I cannot insert it into MS powerpoint. Any help is appreciated