Create Or Replace Function Error

Hello,
I'm doing text mining using Oracle SQL Developer: ODMiner.. I imported the data "WEBLOG" into a table.. This weblog data consist of users activity, date, time, url, etc. The first step I took was to use a function to transform date and time that I have in the data table, into a number representing the 40 mins since 01-01-1990. I did this by dividing it by 2400 (seconds in 40 mins). The main purpose is to have a time frame for the sessions.
I used the following code,
CREATE OR REPLACE FUNCTION ssnDate(
DATE IN VARCHAR2 DEFAULT 03-01-18,
TIME IN VARCHAR2
) RETURN NUMBER
AS
BEGIN
RETURN TRUNC((to_date(DATE||' '||TIME, 'DD-MM-YY HH:MM:SS')- to_date('01-JAN-1990','DD-MON-YYYY')) * (86400/2400);
END ssnDate;
This was what appeared in the log after running the statement,
FUNCTION ssnDate compiled
Warning: execution completed with warning
After this, I tried to create a VIEW to transform the DATE and TIME with the ssnDate that was created earlier on, and concatenate the CS_URI_STEM (which is the resource accessed), and CS_URI_QUERY (which is the the query, if any, the client was trying to perform)into a new field called WEB_LINK.
This is the code used,
CREATE OR REPLACE VIEW WEBLOG_VIEWS("C_IP", "WEB_LINK", "CS_USER_AGENT", "SESSION")
AS
SELECT ssnDate(LOG_DATE, LOG_TIME) AS 'SESSION',
C_IP,
CS_USER_AGENT,
(CS_URI_STEM||'?'||CS_URI_QUERY) AS WEB_LINK
FROM WEBLOG;
Now from this I got the following error..
Error starting at line 1 in command:
CREATE OR REPLACE VIEW WEBLOG_VIEWS("C_IP", "WEB_LINK", "CS_USER_AGENT", "SESSION")
AS
SELECT ssnDate(LOG_DATE, LOG_TIME) AS 'SESSION',
C_IP,
CS_USER_AGENT,
(CS_URI_STEM||'?'||CS_URI_QUERY) AS WEB_LINK
FROM WEBLOG
Error at Command Line:3 Column:38
Error report:
SQL Error: ORA-00923: FROM keyword not found where expected
00923. 00000 - "FROM keyword not found where expected"
*Cause:
*Action:
I don't get where I'm going wrong with this.. This is the data preparation stage which requires me to prep the data before applying modeling techniques or algorithms.. The next step would be grouping the data, based on the session time, ip and the user agent of each session along with the web_links fields visited by the user in that session.
I would really be grateful for any inputs on where I'm going wrong and any solutions for that!

Ok, not sure I really understand, but I posted the query and this is the output I got..
ORA-31603: object "WEBLOG" of type TABLE not found in schema "WEBLOG_TABLE_OWNER_NAME"
ORA-06512: at "SYS.DBMS_METADATA", line 2625
ORA-06512: at "SYS.DBMS_METADATA", line 2668
ORA-06512: at "SYS.DBMS_METADATA", line 2983
ORA-06512: at "SYS.DBMS_METADATA", line 3897
ORA-06512: at "SYS.DBMS_METADATA", line 5678
ORA-06512: at line 1
31603. 00000 - "object \"%s\" of type %s not found in schema \"%s\""
*Cause:    The specified object was not found in the database.
*Action:   Correct the object specification and try the call again.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • SQL Replace function: errors if replacement text is 8191 characters

    Oracle 10.2.0.3.0 Enterprise Edition
    I'm working on an application which has a function to generate emails.
    We have a template, which gets filled with data from the database depending on the email being sent.
    To do this I'm using the Replace function to replace certain parts of the template with the right data.
    It seems that if the replacement text (the third argument to the function) is longer than 8191 bytes the function throws a PL/SQL: numeric or value error.
    This limitation doesn't appear to be documented anywhere, certainly nowhere that I can find.
    Anyone know of a way around this short of building my own replace function?

    I've figured out what was going on.
    The database column for the replacement text is defined as a clob, but there is a front end limit of 10,000 characters for the field being used.
    When using the replace function I was assigning the value to a varchar2(32767) field in the PL/SQL.
    So in terms of datatypes the function call is:
    varchar2 := replace(varchar2, varchar2, clob)
    If the length of the clob is over 8191 characters it errors.
    (Presumably because of the bug mentioned in this thread DBMS_LOB.SUBSTR() returning 8191 characters instead of 32767
    I've fixed it by simply changing the datatype of the variable to which the value is being assigned to a clob.

  • SQL Replace function - error

    I am little bit struggling to get the my sql function below, to execute the correct output:
    ALTER FUNCTION [dbo].[ReplaceTags](@XML VARCHAR(MAX))
    RETURNS VARCHAR(MAX)
    AS
    BEGIN
    SELECT @XML = REPLACE(@XML,[Name],'<a href="<a href="pagename.aspx?tag='+[name]+'">'+[name]+'</a>')
    FROM [dbo].[database_tags]
    where UploadDate >= '2014-09-01'
    RETURN @XML
    END
    When I call the function (select title, [dbo].[ReplaceTags](XML) from article ), it outputs the following result below, whereas the original data is this - (One is a 1m block of AIREM 2006-1X 2A3,).
    Query output:
    One is a &amp;#163;1m block of <a href="<a href="pagename.aspx?tag=<a href="<a href="pagename.aspx?tag=<a href="<a href="pagename.aspx?tag=<a href="<a href="pagename.aspx?tag=<a href="<a
    href="pagename.aspx?tag=AIREM 2006-1X 2A3">AIREM 2006-1X 2A3</a>"><a href="<a href="pagename.aspx?tag=AIREM 2006-1X 2A3">AIREM 2006-1X 2A3</a></a>"><a href="<a href="pagename.aspx?tag=<a
    href="<a href="pagename.aspx?tag=AIREM 2006-1X 2A3">AIREM 2006-1X 2A3</a>"><a href="<a href="pagename.aspx?tag=AIREM 2006-1X 2A3">AIREM 2006-1X 2A3</a></a></a>"><a href="<a
    href="pagename.aspx?tag=<a href="<a
    I am not sure, why it keep duplicating the name.  Please advice, where I may be going wrong. 
    Thank you for your help and time.

    Hi,
    There is no problem do this using CLR in the database side, as well. You can use SQLCLR regular expression function.
    In any case your HTML is wrong in the original question. You asked for 
    SELECT @XML = REPLACE(@XML,[Name],'<a href="<a href="pagename.aspx?tag='+[name]+'">'+[name]+'</a>')
    but you need 
    SELECT @XML = REPLACE(@XML,[Name],'<a href="pagename.aspx?tag='+[name]+'">'+[name]+'</a>')
    Please post DDL+DML for the [database_tags] table.
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]

  • Over-riding the "create or replace" function in WriteToSpreadsheetFile.vi

    I would like to modify the WriteToSpreadsheetFile.vi so that it automatically replaces a file, without asking me if it is okay to replace it. i.e. I want my file to be just one line, and not have to append it.

    The Write to Spreadsheet File.vi uses Open/Create/Replace File.vi as a subVI. The subVI has a an "advisory dialog" boolean.
    Save a copy of the Write to Spreadsheet File.vi with a different name and wire a True constant to the advisory dialog boolean.
    If you do not save the VI with a new name and into your directory, the modified VI would be used in any other NI VIs or examples. They might not work properly with the modification. Also your changes would be overwritten at the next LV upgrade.
    Lynn

  • Error while creating a simple function, procedure or triger in Oracle8i Lite

    Hi,
    I have Oracle8i Lite release 4.0.
    While creating a simple proceudre/function/trigger on the database, it's throwing the following error:
    create or replace function test return number is
    ERROR at line 1:
    OCA-30021: error preparing/executing SQL statement
    [POL-5228] syntax error
    Here is my sample code.
    create or replace function test return number is
    begin
    return 0;
    end;
    Tried to create the same function in the user SYSTEM too but got the same error message.
    Thanks in advance for the soluton.
    null

    I just started with 8i Lite, but as far as I know 8i Lite does not support PL/SQL code.
    So you have to write your triggers and stored procedures in Java.
    Ciao

  • Error while creating Custom Defined Functions in Essbase

    <p>Hi All,<br>I am trying to create CDF(Custom Defined Functions) in Essbase. Iwant to create a function which take list of child member andreturn the first child. For this, i have created a java file called"ChildAccess.java" which contains the following code:<br>public class ChildAccess<br>{<br>public static char GetFirstMember(char [] members)<br>{<br>return members[0];<br>}<br>}<br>I have compiled and made jar file called"ChildAccess.jar" and pasted it at"ARBORPATH/java/udf". Then i restarted the Essbase Serverand run the following MaxL command to register the function<br>create or replace function '@ChildAccess' as<br>'ChildAccess.GetFirstMember'<br>spec '@ChildAccess(memberRange)'<br>comment 'adds list of input members'.<br>Till here i am not getting any error but when i am using thisfunction in my calc script as given below<br><br>FIX(@ChildAccess(@CHILDREN("Abc")))<br><br>it gives the following error<br>"Error:1200414 Error parsing formula for [FIX STATEMENT]<br>(line 2)"argument[1] may not have size[6] in function[@CHILDREN]"<br>NOTE: The SIZE[6] is giving the no. of child in member"ABC".<br><br>Thanks in Advance<br>Arpit</p>

    If you want to use the CDF in a FIX statement you need to make sure that it returns a member name rather than a number:<BR><i><BR>public class ChildAccess<BR>{<BR>    public static String GetFirstMember(String[] members)<BR>    {<BR>        return members[0];<BR>    }<BR>}<BR></i><BR>I prefer to define the function against a specific application rather than globally because you only need to restart the application in order to pick-up any modifications to the .jar file. So the MaxL function definition would be:<BR><i><BR>    create or replace function appname.'@_GETFIRSTMEMBER' as<BR>        'ChildAccess.GetFirstMember(String[])';<BR></i><BR>and in the calculation script the FIX statement would become:<BR><i><BR>    fix ( @member( @_GetFirstMember( @name( @children( "Abc" ) ) ) ) )<BR></i><BR>This looks a little messy so you can use a macro to simplify it:<BR><i><BR>    create or replace macro appname.'@GETFIRSTMEMBER'(single) <BR>        as '@member( @_GETFIRSTMEMBER( @name( @@1 ) ) )' <BR>        SPEC "@GETFIRSTMEMBER(memberRange)";<BR></i><BR>and then the FIX statement could be written:<BR><i><BR>    fix( @getfirstmember( @children( "PRODUCT" ) ) )<BR></i>

  • Local function calling remote function - error

    Dear All
    i have following remote function wich return some value from both methods ie.
    1) select func1(variable, varialbe) from dual@remoteDB; working
    2) select func1(variable, varialbe) from dual; -- by making a synonym at local
    Now i create a local function funclocal calling remote functino i.e. func1 in this example as:
    CREATE OR REPLACE FUNCTION funclocal(locc varchar2, artnoo number)
    RETURN NUMBER IS
    query_str VARCHAR2(1000);
    STKQTYY NUMBER;
    artno number(10);
    loc varchar2(80);
    BEGIN
    artno := artnoo;
    loc := locc;
    query_str := 'select func1(loc, artno) from dual ';
    EXECUTE IMMEDIATE query_str
    INTO STKQTYY;
    RETURN STKQTYY;
    END;
    compiled successfully.
    But when i run as:
    SQL> select funclocal('abc', 469183) from dual;
    select funclocal('@st3', 469183) from dual
    ERROR at line 1:
    ORA-00904: "ARTNO": invalid identifier
    ORA-06512: at "funclocal", line 11
    Please guide me.
    Regards
    Saeed

    EXECUTE IMMEDIATE query_strAs Andreas states: Why are you using dynamic sql?
    From what I see all you need is sth like
    create or replace function funclocal (locc varchar2, artnoo number)
       return number
    is
    begin
       return func1 (locc, artnoo);
    end funclocal ;
    /even the whole concept of a »local« function seems suspicious. Why do you need that one?

  • Function error! pls help.

    Here is the code:
    CREATE OR REPLACE FUNCTION id_is_good
    (i_student_id IN NUMBER)
    RETURN BOOLEAN
    AS
    v_id_cnt NUMBER;
    BEGIN
    SELECT COUNT(*)
    INTO v_id_cnt
    FROM student
    WHERE student_id = i_student_id;
    RETURN 1 = v_id_cnt;
    EXCEPTION
    WHEN OTHERS
    THEN
    RETURN FALSE;
    END id_is_good;
    Error report:
    ORA-06550: line 5, column 20:
    PL/SQL: ORA-00904: "I_STUDENT_ID": invalid identifier
    ORA-06550: line 2, column 1:
    PL/SQL: SQL Statement ignored
    ORA-06550: line 6, column 1:
    PLS-00372: In a procedure, RETURN statement cannot contain an expression
    ORA-06550: line 6, column 1:
    PL/SQL: Statement ignored
    ORA-06550: line 10, column 1:
    PLS-00372: In a procedure, RETURN statement cannot contain an expression
    ORA-06550: line 10, column 1:
    PL/SQL: Statement ignored
    06550. 00000 - "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:
    This function run troubleless however it can not run troubleless in my computer, I have database though, I mean my database is ok, and i use sql developer but i dont understand why this code cant run good?? pls help me.
    thanks

    RETURN BOOLEANPerhaps you should read Oracle Doc about returning boolean value in SQL.
    Check the following link ->
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::NO::P11_QUESTION_ID:6263249199595
    Your solution might be something like this if you want to return boolean ->
    CREATE OR REPLACE FUNCTION id_is_good(i_student_id IN NUMBER)
    RETURN BOOLEAN
    IS
      v_id_cnt NUMBER;
    BEGIN
      SELECT COUNT(*)
      INTO v_id_cnt
      FROM student
      WHERE student_id = i_student_id;
      IF v_id_cnt > 0 THEN
         RETURN TRUE;
      ELSE
        RETURN FALSE;
      END IF;
    EXCEPTION
    WHEN OTHERS THEN
      RETURN FALSE;
    END id_is_good;Or, if you want to return the value then ->
    CREATE OR REPLACE FUNCTION id_is_good(i_student_id IN NUMBER)
    RETURN NUMBER
    IS
      v_id_cnt NUMBER;
    BEGIN
      SELECT COUNT(*)
      INTO v_id_cnt
      FROM student
      WHERE student_id = i_student_id;
      RETURN v_id_cnt;
    EXCEPTION
    WHEN OTHERS THEN
      RETURN 0;
    END id_is_good;Hope this will help.
    Regards.
    Satyaki De.

  • Function error:  Too many records

    I have writing a function that needs to return the total count of a sql statement. It will divide two calculated columns to get an average. I have two versions. Version 1 compiled successfully and I am trying to either run it in Reports or in the database and call it. I get an error stating that the function returns too many records. I understand that is a rule for stored functions but how can I modify the code to get it return one value for each time it is called?
    Here is the main calculation. SUM(date1-date2) / (date1-date2) = Avg of Days
    version1:
    create or replace FUNCTION CALC_OVER_AGE
    RETURN NUMBER IS
    days_between NUMBER;
    days_over NUMBER;
    begin
    select (determination_dt - Filed_dt), SUM(determination_dt - Filed_dt) into days_between, days_over
    from w_all_cases_mv
    where (determination_dt - Filed_dt) > 60
    and ;
    return (days_between/days_over);
    END CALC_OVER_AGE;
    version2:
    CREATE OR REPLACE FUNCTION CALC_OVER_AGE (pCaseType VARCHAR2)
    RETURN PLS_INTEGER IS
    v_days_between W_ALL_CASES_MV.DAYS_BETWEEN%TYPE;
    v_total NUMBER;
    days_over NUMBER;
    i PLS_INTEGER;
    BEGIN
    SELECT COUNT(*)
    INTO i
    FROM tab
    WHERE case_type_cd = pCaseType
    AND determination_dt - Filed_dt > 60;
    IF i <> 0 THEN
    select SUM(determination_dt-Filed_dt), days_between
    into v_total, v_days_between
    from tab
    where determination_dt - Filed_dt > 60;
    RETURN v_total/v_days_between;
    ELSE
    RETURN 0;
    END IF;
    EXCEPTION
    WHEN OTHERS THEN
    RETURN 0;
    END CALC_OVER_AGE;

    Table Structure:
    WB_CASE_NR NUMBER(10)
    RESPONDENT_TYPE_CD VARCHAR2(10)
    INV_LOCAL_CASE_NR VARCHAR2(14)
    CASE_TYPE_CD VARCHAR2(10)
    FILED_DT DATE
    FINAL_DTRMNTN_DT DATE
    REPORTING_NR VARCHAR2(7)
    INVESTIGATOR_NAME VARCHAR2(22)
    OSHA_CD VARCHAR2(5)
    FEDERAL_STATE VARCHAR2(1)
    RESPONDENT_NM VARCHAR2(100)
    DAYS_BETWEEN NUMBER
    LAST_NM VARCHAR2(20)
    FIRST_NM VARCHAR2(20)
    DETERMINATION_DT DATE
    DETERMINATION_TYPE_CD VARCHAR2(2)
    FINAL_IND_CD VARCHAR2(1)
    DESCRIPTION VARCHAR2(400)
    DETERMINATION_ID NUMBER(10)
    ALLEGATION_CD VARCHAR2(1)
    ALGDESCRIPTION VARCHAR2(50)
    Output is for Reports, I am trying to get the last calculation, which is the Average Days. The reports is grouped on Case Types and has several bucket counts for each like this.
    Case Type Count All Completed Pending Over Age Avg Days
    A 5 3 4 2 15
    Z 10 7 6 3 30
    4 8 3 5 4 22
    To get the Avg Days, the Over Age calculation is used as well as the Days Between (Determination_Dt - Filed_Dt). That is the (date1-date2) example that I gave in my first post. So the calcuation would be the SUM(Days_Between) / Days_Between.

  • PL/SQL Function error

    Hi Guys,
    I've been getting driven a little crazy with this piece of code...
    create or replace function "GetHeirachy" (current VARCHAR2) return VARCHAR2 is
         name VARCHAR2(4000);
         hold VARCHAR2(4000);
         parent VARCHAR2(4000);
    BEGIN
         LOOP
         SELECT PARENT_ITEM_ID, ITEM_NAME INTO parent, name
         FROM HTMLDB_OARS.ITEM_REGISTER
         WHERE ITEM_ID = current;
         IF hold IS NULL THEN
              hold := name;
         ELSE
              hold := name || '/' || hold;
         END IF;
         current := parent;
              EXIT WHEN current IS NULL;
         END LOOP;
         RETURN hold;
    END "GetHeirachy";
    basically the table structure is a self referencing table that creates a heirachy effect, and i need to be able to return a string of "parent/child/grandchild" for display purposes, the function begins with the grandchild and then uses the references to collect each parent and add it to the return.
    When i put the function into sql workshop it is fine but if i try soemthing as simple as
    begin
    htp.prn(GetHeirachy('34'));
    end;
    i get these errors;
    ORA-06550: line 2, column 9:
    PLS-00905: object HTMLDB_OARS.GETHEIRACHY is invalid
    ORA-06550: line 2, column 1:
    PL/SQL: Statement ignored1. begin
    2. htp.prn(GETHEIRACHY('34'));
    3. end;
    Is there something simple wrong with my function code? pl/sql isn't my native language... and i don't know how to debug properly!
    Cheers,
    Alex

    alright - code complete, i'll post it for the sake of others doing soemthing similar;
    create or replace function GetHeirachy (current varchar2) return VARCHAR2 is
    name VARCHAR2(4000);
    hold VARCHAR2(4000);
    parent VARCHAR2(4000);
    cur VARCHAR2(4000);
    BEGIN
    cur := current;
    for i in 1..10 LOOP
    SELECT PARENT_ITEM_ID, ITEM_NAME INTO parent, name
    FROM HTMLDB_OARS.ITEM_REGISTER
    WHERE ITEM_ID = cur;
    IF hold IS NULL THEN
    hold := name;
    ELSE
    hold := name || '/' || hold;
    END IF;
    cur := parent;
    EXIT WHEN cur IS NULL;
    END LOOP;
    RETURN hold;
    END GetHeirachy;
    :) - cheers for the help.

  • Please help : Pipline function, error passing parameter

    Hello,
    Please help a DBA who's trying to make it with PL/SQL (on Oracle 10.2.0.4).
    I'm just building a script to find the space used by all the segments (lob, index, partitions) related to a table.
    Here is my problem, when I call a table function (DBMS_SPACE.OBJECT_DEPENDENT_SEGMENTS) from within a pipeline function i get an error,
    if I turn that function into procedure it is running fine, if I hard code parameters it works...
    When running as a function I get the error :
    SQL> Select * from table(yke_size_info('SAPRD', 'REPOSRC'));
    Select * from table(yke_size_info('SAPRD', 'REPOSRC'))
    *+
    ERROR at line 1:
    ORA-20000: Object does not exist
    ORA-06512: at "SYS.DBMS_SPACE", line 2673
    ORA-06512: at "SYS.YKE_SIZE_INFO", line 40
    => line 40 is the call to DBMS_SPACE.OBJECT_DEPENDENT_SEGMENTS
    Thank for your help, I'm getting crazy with this, I've been browsing Google & docs for hoors but no answer yet !
    create or replace type r_size_info as object (
    nb_par_tbl   number ,
    nb_idx       number ,
    nb_par_idx   number ,
    nb_lob       number ,
    used_par_tbl number ,
    used_idx     number ,
    used_par_idx number ,
    used_lob     number ,
    free_par_tbl number ,
    free_idx     number ,
    free_par_idx number ,
    free_lob     number
    +)+
    +/+
    create or replace type t_size_info as table of r_size_info;
    +/+
    CREATE OR REPLACE FUNCTION yke_size_info(o_wner varchar2, o_bject varchar2 ) RETURN t_size_info PIPELINED AS
    r_size r_size_info := r_size_info(0,0,0,0,0,0,0,0,0,0,0,0);
    obj_segment_owner   VARCHAR2(100);
    obj_segment_name    VARCHAR2(100);
    obj_segment_type    VARCHAR2(100);
    obj_tablespace_name VARCHAR2(100);
    BEGIN
    FOR obj IN (SELECT segment_owner, segment_name, segment_type, tablespace_name FROM TABLE(dbms_space.object_dependent_segments(o_wner, o_bject, NULL, 1)))*
    LOOP
    If I change that line to hard code the parameter It's working :
    FOR obj IN (SELECT segment_owner, segment_name, segment_type, tablespace_name FROM TABLE(dbms_space.object_dependent_segments('SAPSR3', 'REPOSRC', NULL, 1)))
    If I turn the function into a procedure it is working :
    CREATE OR REPLACE PROCEDURE yke_size_inf(o_wner varchar2, o_bject varchar2 ) AS
    obj_segment_owner   VARCHAR2(100);
    obj_segment_name    VARCHAR2(100);
    obj_segment_type    VARCHAR2(100);
    obj_tablespace_name VARCHAR2(100);
    BEGIN
    FOR obj IN (SELECT segment_owner, segment_name, segment_type, tablespace_name  FROM (TABLE(dbms_space.object_dependent_segments (o_wner, o_bject, NULL, 1))))*
    LOOP

    Not really sure what you are trying to achieve... and putting a pipeline function on top of another pipeline function seems unnecessary to me.
    But using the basic code you've shown, the following works fine:
    SQL> create or replace type TStrings is table of varchar2(4000);
      2  /
    Type created.
    SQL>
    SQL> create or replace function FooPipe( objectName varchar2 ) return TStrings pipelined is
      2  begin
      3          for r in (
      4                  select
      5                          segment_owner, segment_name, segment_type, tablespace_name
      6                  from    table( dbms_space.object_dependent_segments(USER, objectName , NULL, 1))
      7          )
      8          loop
      9                  pipe row( r.segment_name||' is object('||r.segment_type||') in space('||r.tablespace_name||')' );
    10          end loop;
    11
    12          return;
    13  end;
    14  /
    Function created.
    SQL>
    SQL> select * from TABLE(FooPipe('TESTTAB'));
    COLUMN_VALUE
    TESTTAB is object(TABLE) in space(USERS)
    SQL>

  • Access Control - Function - error

    Hi guys,
    I was following "" Application Express Advanced Tutorials How to build an Access Control page ""
    But the function in the tutorial would not work:
    http://download.oracle.com/docs/cd/E14373_01/appdev.32/e13363/acl.htm#CHDDDFBD
    CREATE OR REPLACE FUNCTION acl_custom_auth (
    p_username IN VARCHAR2,
    p_password IN VARCHAR2)
    RETURN BOOLEAN IS
    BEGIN
    FOR c1 IN (SELECT 1
    FROM acl_employees
    WHERE upper(userid) = upper(p_username)
    AND upper(last_name) = upper(p_password))
    LOOP
    RETURN TRUE;
    END LOOP;
    RETURN FALSE;
    END;
    Could you please tell where is the mistake??
    What is " c1 " in the function??
    Thanks In Advance,
    Fateh

    Thanks Alex,
    Having done what you advised, I got the following error:
    1 error has occurred
    ORA-06550: line 2, column 1: PLS-00103: Encountered the symbol "CREATE" when expecting one of the following: ( begin case declare end exception exit
    for goto if loop mod null pragma raise return select update while with <an identifier> <a double-quoted delimited-identifier> <a bind variable> << continue
    close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe purgePerhaps you can take a look at the App,
    workspace: somefeto
    username: [email protected]
    password: QQWWEE!1
    App: 40807. ACL_EMPLOYEES
    App credentials :
    dev
    dev
    Best Regards,

  • Pipe lined function error

    Hi can someone tell me whats wrong in the below function code? Its compilation error
    table and Type structure are below for creating the same function.
    SQL> desc tt
    Name                                      Null?    Type
    NO                                                 NUMBER
    NAME                                               VARCHAR2(20)
    SQL> select * from tt;
            NO NAME
            30 WSS
            40 SYS
            10 WSS
            20 SYS
    create or replace type tt_typ as object
    (no number,
    name varchar2(20));
    create or replace type rec_tt_type as table of tt_typ;
    Type created.
    create or replace function fn1 return rec_tt_type  pipelined as
    table_tt  tt%rowtype;
    var_tt tt%rowtype;
    cursor c1 is select * from tt;
    begin
    open c1;
      loop
      fetch c1 into table_tt;
       execute immediate ' select no, name from tt where no = :1'  into var_tt using table_tt.no;
      pipe row(var_tt);
    end loop;
    return;
    end;
    sho err;
    Errors for FUNCTION FN1:
    LINE/COL ERROR
    23/3     PL/SQL: Statement ignored
    23/12    PLS-00382: expression is of wrong type
    SQL>

    SQL> create table tt
    as
       select 30 no, 'WSS' name from dual
       union all
       select 40 no, 'SYS' name from dual
       union all
       select 10 no, 'WSS' name from dual
       union all
       select 20 no, 'SYS' name from dual
    Table created.
    SQL> create or replace type tt_typ as object
       (no number, name varchar2 (20));
    Type created.
    SQL> create or replace type rec_tt_type as table of tt_typ;
    Type created.
    SQL> create or replace function fn1
       return rec_tt_type
       pipelined
    as
       cursor c1
       is
          select * from tt;
       table_tt   c1%rowtype;
       var_tt     c1%rowtype;
    begin
       open c1;
       loop
          fetch c1 into table_tt;
          exit when c1%notfound;
          execute immediate ' select no, name from tt where no = :1 '
             into var_tt
             using table_tt.no;
          pipe row (tt_typ (var_tt.no, var_tt.name));
       end loop;
       return;
    end fn1;
    Function created.
    SQL> select * from table (fn1)
            NO NAME               
            30 WSS                
            40 SYS                
            10 WSS                
            20 SYS                
    4 rows selected.

  • Passing record type into function [error: identifier must be declared]

    Hi,
    I have a record type defined in my procedure
    type chk_tab is record(
    effect date,
    count number(9)
    type chk_typ is table of chk_tab index by binary integer;
    chk_typ_rec chk_typ;
    I have to pass the effect and count into another function, i tried doin as below:
    function name: func_chk_typ
    func_chk_typ(effect, count);
    this returns an saying "identifier effect needs to be declared"
    I am required to pass these values from the record type into the function, How can i over come this??
    Any help is very much appreciated.

    Hi Hemz,
    Find below code.
    Function Code:
    CREATE OR REPLACE FUNCTION fetch_band(eff in date,ineff in date)
    return number
    is
      lu_cb_sysid  NUMBER;
    BEGIN
    select fk_cb_sysid
    into lu_cb_sysid
    from ia_for_icon
    where cr_ans_date >= eff
    and cr_ans_date < ineff;
    RETURN lu_cb_sysid;
    END fetch_band;Procedure code. Here I have embedded the function.
    CREATE OR REPLACE procedure abc(a varchar, b number) is
      type cns_tab_record is record(
        eff   date,
        ineff date);
      type cns_tab_typ is table of cns_tab_record index by binary_integer;
      cns_tab cns_tab_typ;
      v_lu_cb_sysid NUMBER;
    BEGIN 
      -- Here you have to assign the values to your table type record.
      -- For example I am passing two values SYSDATE and SYSDATE - 10
      cns_tab(1).eff := SYSDATE;
      cns_tab(1).ineff := SYSDATE - 10;
      v_lu_cb_sysid:= fetch_band(cns_tab(1).eff, cns_tab(1).ineff);
    END abc;But I am just wondering why you are using table type datatype here.
    Hope above code will help you.
    Thanks,
    Suri

  • Create hours worked functions

    I am trying to create a form for employee attendance, the attendance table is populated by employee login and log out.
    my table looks like this
    table attendance
    employee_id
    schedule_id
    start_time
    end_time
    total_time_worked (for this column i tried this formula in the property palette (:timeout-:timein) it did work but came out in .333333)
    any ideas please?
    thank you in advance.

    Here is a function that return something more comprehensive:
    CREATE OR REPLACE FUNCTION Diff_Time
         LD$Date_Deb IN DATE DEFAULT SYSDATE
         ,LD$Date_Fin IN DATE DEFAULT SYSDATE
         ,LN$JJ       OUT PLS_INTEGER
         ,LN$HH       OUT PLS_INTEGER
         ,LN$MI       OUT PLS_INTEGER
         ,LN$SS       OUT PLS_INTEGER
      ) Return NUMBER
    IS
      dif   NUMBER ;
    Begin
      If LD$Date_Fin < LD$Date_Deb Then
         Return ( -1 ) ;
      End if ;
      Select  LD$Date_Fin - LD$Date_Deb Into dif  From DUAL ;
      Select  trunc ( LD$Date_Fin - LD$Date_Deb)  Into LN$JJ  From DUAL ;
      Select  trunc ( (LD$Date_Fin - LD$Date_Deb) * 24) -  ( LN$JJ * 24 ) Into LN$HH From DUAL ;
      Select  trunc ( (LD$Date_Fin - LD$Date_Deb) * 1440) - ( (LN$HH * 60) + ( LN$JJ * 1440) ) Into LN$MI From DUAL ;
      Select  trunc ( (LD$Date_Fin - LD$Date_Deb) * 86400) - ( (LN$MI * 60) + (LN$HH * 3600) + ( LN$JJ * 3600 * 24 ) ) Into LN$SS From DUAL ;
      Return( dif ) ;
    End ;
    /That you can call as follow:
    SQL> set serveroutput on
    SQL> declare
      2   dd pls_integer;
      3   hh pls_integer;
      4   mi pls_integer;
      5   ss pls_integer;
      6   dif number ;
      7  Begin
      8   dif := diff_time ( sysdate, sysdate + 10.523, dd,hh,mi,ss ) ;
      9   dbms_output.put_line(
    10     '(' || ltrim(to_char(dif,'99999.99999')) || ')' || '  '
    11     || to_char(dd,'99999') || 'd '
    12     || to_char(hh,'00') ||':'
    13     || to_char(mi,'00') ||':'
    14     || to_char(ss,'00')
    15     ) ;
    16  End;
    17  /
    (10.52300)      10d  12: 33: 07Francois

Maybe you are looking for