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.

Similar Messages

  • Regarding sql function error  for Hijri date to Gregorian date

    Hi ,
    I want to convert Hijri date format into Gregorian date format . i write the script with  sql function  like this
    $Hijri_Date = '16/04/1428';
    $Gregorian_Date = sql('DS_REPO','SELECT CONVERT(DATE,[$Hijri_Date],131)');
    print($Gregorian_Date);
    here $Hijri_Date data type is varchar and $Gregorian_Date data type is date.
    but  I am getting error like
    7868     5812     DBS-070401     10/26/2010 10:37:18 PM     |Session Job_Hijradata_Conversion
    7868     5812     DBS-070401     10/26/2010 10:37:18 PM     ODBC data source <UIPL-LAP-0013\SQLEXPRESS> error message for operation <SQLExecute>: <[Microsoft][SQL Server Native Client
    7868     5812     DBS-070401     10/26/2010 10:37:18 PM     10.0][SQL Server]Explicit conversion from data type int to date is not allowed.>.
    7868     5812     RUN-050304     10/26/2010 10:37:18 PM     |Session Job_Hijradata_Conversion
    7868     5812     RUN-050304     10/26/2010 10:37:18 PM     Function call <sql ( DS_REPO, SELECT CONVERT(DATE,16/04/1428,131) ) > failed, due to error <70401>: <ODBC data source
    7868     5812     RUN-050304     10/26/2010 10:37:18 PM     <UIPL-LAP-0013\SQLEXPRESS> error message for operation <SQLExecute>: <[Microsoft][SQL Server Native Client 10.0][SQL
    7868     5812     RUN-050304     10/26/2010 10:37:18 PM     Server]Explicit conversion from data type int to date is not allowed.>.>.
    7868     5812     RUN-053008     10/26/2010 10:37:18 PM     |Session Job_Hijradata_Conversion
    please help me out to solve this problem .
    Please suggest any other solution to convert hijri date format to gregorian date format.
    Thanks&Regards,
    Ramana.

    Hi ,
    In Data quality there is no inbuild function for converting hijri date to gregorian date .  we have the function for converting julian date to gregorian date.
    Thanks&Regards,
    Ramana.

  • PL/SQL function body returning SQL - report error:ORA-01403: no data found

    Hi,
    I am working on Application Express 4.0.2.00.06, and 11G database.
    I have a problem with classic report area of type - PL/SQL function body returning SQL query. Query works if I define region area as - Use Generic Column Names (parse query at runtime only), and does not when I define it - Use Query-Specific Column Names and Validate Query.
    I am getting error:
    report error:ORA-01403: no data found
    This is my query that is returned from function, and displayed with htp.p, and it works ok and returns data in SQL Developer and SQL Workshop (in Apex).
    <code>
    /* select 1 from dual */ SELECT SIFPRO, NAZIV, VODITELJ, DATPZA,SUM(DECODE(TJEDAN,'2010/46',BRDJEL,null)) as "2010/46" ,SUM(DECODE(TJEDAN,'2010/49',BRDJEL,null)) as "2010/49" ,SUM(DECODE(TJEDAN,'2010/50',BRDJEL,null)) as "2010/50" ,SUM(DECODE(TJEDAN,'2010/51',BRDJEL,null)) as "2010/51" ,SUM(DECODE(TJEDAN,'2010/52',BRDJEL,null)) as "2010/52" ,SUM(DECODE(TJEDAN,'2011/01',BRDJEL,null)) as "2011/01" ,SUM(DECODE(TJEDAN,'2011/02',BRDJEL,null)) as "2011/02" ,SUM(DECODE(TJEDAN,'2011/03',BRDJEL,null)) as "2011/03" ,SUM(DECODE(TJEDAN,'2011/04',BRDJEL,null)) as "2011/04" ,SUM(DECODE(TJEDAN,'2011/05',BRDJEL,null)) as "2011/05" ,SUM(DECODE(TJEDAN,'2011/06',BRDJEL,null)) as "2011/06" ,SUM(DECODE(TJEDAN,'2011/07',BRDJEL,null)) as "2011/07" ,SUM(DECODE(TJEDAN,'2011/08',BRDJEL,null)) as "2011/08" ,SUM(DECODE(TJEDAN,'2011/09',BRDJEL,null)) as "2011/09" ,SUM(DECODE(TJEDAN,'2011/10',BRDJEL,null)) as "2011/10" FROM (SELECT * FROM PMV_PLAN_TVRTKA) GROUP BY SIFPRO, NAZIV, VODITELJ, DATPZA ORDER BY SIFPRO, NAZIV, VODITELJ, DATPZA
    </code>
    As you can see, I even tried with workaround that I found on the previous post on the forum, and that is to put /* select 1 from dual */ to start query.
    Any help would be appriciated.

    /* select 1 from dual */ SELECT SIFPRO, NAZIV, VODITELJ, DATPZA,SUM(DECODE(TJEDAN,'2010/46',BRDJEL,null)) as "2010/46" ,SUM(DECODE(TJEDAN,'2010/49',BRDJEL,null)) as "2010/49" ,SUM(DECODE(TJEDAN,'2010/50',BRDJEL,null)) as "2010/50" ,SUM(DECODE(TJEDAN,'2010/51',BRDJEL,null)) as "2010/51" ,SUM(DECODE(TJEDAN,'2010/52',BRDJEL,null)) as "2010/52" ,SUM(DECODE(TJEDAN,'2011/01',BRDJEL,null)) as "2011/01" ,SUM(DECODE(TJEDAN,'2011/02',BRDJEL,null)) as "2011/02" ,SUM(DECODE(TJEDAN,'2011/03',BRDJEL,null)) as "2011/03" ,SUM(DECODE(TJEDAN,'2011/04',BRDJEL,null)) as "2011/04" ,SUM(DECODE(TJEDAN,'2011/05',BRDJEL,null)) as "2011/05" ,SUM(DECODE(TJEDAN,'2011/06',BRDJEL,null)) as "2011/06" ,SUM(DECODE(TJEDAN,'2011/07',BRDJEL,null)) as "2011/07" ,SUM(DECODE(TJEDAN,'2011/08',BRDJEL,null)) as "2011/08" ,SUM(DECODE(TJEDAN,'2011/09',BRDJEL,null)) as "2011/09" ,SUM(DECODE(TJEDAN,'2011/10',BRDJEL,null)) as "2011/10" FROM (SELECT * FROM PMV_PLAN_TVRTKA) GROUP BY SIFPRO, NAZIV, VODITELJ, DATPZA ORDER BY SIFPRO, NAZIV, VODITELJ, DATPZA

  • PL/SQL function body returning SQL query - ORA-06502: PL/SQL: numeric or value error

    I'm attempting to dynamically generate a rather large SQL query via the "PL/SQL function body returning SQL query" report region option.  The SQL query generated will possibly be over 32K.  When I execute my page, I sometimes receive the "ORA-06502: PL/SQL: numeric or value error" which points to a larger than 32K query that was generated.  I've seen other posts in the forum related to this dynamic SQL size limitation issue, but they are older (pre-2010) and point to the 32K limit of the DNS (EXECUTE IMMEDIATE) and DBMS_SQL.  I found this post (dynamic sql enhancements in 11g) which discusses 11g no longer having the 32K size limitation for generating dynamic SQL.  Our environment is on 11gR2 and using ApEx 4.2.1.  I do not know which dynamic SQL method -- DNS or DBMS_SQL -- ApEx 4.2.1 is using.  Can someone clarify for me which dynamic SQL method ApEx uses to implement the "PL/SQL function body returning SQL query" option?
    As a test, I created a page on apex.oracle.com with a report region with the following source:
    declare
      l_stub varchar2(25) := 'select * from sys.dual ';
      l_sql  clob := l_stub || 'union all ';
      br     number(3) := 33;
    begin
      while length ( l_sql ) < 34000 loop
        l_sql := l_sql || l_stub || 'union all ';
      end loop;
      l_sql := l_sql || l_stub;
      for i in 1 .. ceil ( length ( l_sql ) / br ) loop
        dbms_output.put_line ( dbms_lob.substr ( l_sql, br, ( ( i - 1 ) * br ) + 1 ) );
      end loop;
      return l_sql;
    end;
    The dbms_output section is there to be able to run this code in SQL*Plus and confirm the size of the SQL is indeed larger than 32K.  When running this in SQL*Plus, the procedure is successful and produces a proper SQL statement which can be executed.  When I put this into the report region on apex.oracle.com, I get the ORA-06502 error.
    I can certainly implement a work-around for my issue by creating a 'Before Header' process on the page which populates an ApEx collection with the data I am returning and then the report can simply select from the collection, but according to documentation, the above 32K limitation should be resolved in 11g.  Thoughts?
    Shane.

    What setting do you use in your report properties - especially in Type and in Region Source?
    If you have Type="SQL Query", then you should have a SELECT statement in the Region Source. Something like: SELECT .... FROM ... WHERE
    According to the ERR-1101 error message, you have probably set Type to "SQL Query (PL/SQL function body returning SQL query)". In this situation APEX expects you to write a body of a PL/SQL function, that will generate the text of a SQL query that APEX should run. So it can be something like:
    declare
    mycond varchar2(4000);
    begin
    if :P1_REPORT_SEARCH is not null THEN
    mycond:='WHERE LAST_NAME like :P1_REPORT_SEARCH ||''%''';
    end if;
    return 'select EMPLOYEE_ID, FIRST_NAME, LAST_NAME from EMPLOYEES ' ||mycond;
    end;
    And for escaping - are you interested in escaping the LIKE wildcards, or the quotes?
    For escaping the wildcards in LIKE function so that when the user enters % you will find a record with % and not all functions, look into the SQL Reference:
    http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/conditions007.htm
    (You would than need to change the code of your function accordingly).
    If you are interested in escaping the quotes, try to avoid concatenating the values entered by the user into the SQL. If you can, use bind variables instead - as I have in my example above. If you start concatenating the values into the text of SQL, you are open to SQLInjection - user can enter anything, even things that will break your SQL. If you really need to allow users to choose the operator, I would probably give them a separate combo for operators and a textfield for values, than you could check if the operator is one of the allowed ones and create the condition accordingly - and than still use bind variable for inserting the filtering value into the query.

  • Error in report when executing pl/sql function body returning sql query.

    Hi,
    I have used the pl/sql function body returning sql query for creating a report. I have created a datepicker(
    P10_TASK_DATE) which can be submitted.The code is as below
    DECLARE
    v_sql varchar2(3000);
    BEGIN
    if :P10_TASK_DATE is not null THEN
    v_sql:='select
          * from tasks';
    return v_sql;
    else
    v_sql:='select * from discovery';
    return v_sql;
    END IF;
    END;if the date field is empty "select * from discovery" is executed and report is getting generated. But when we give a
    date using date picker the page is submitted and i get "report error: ORA-01403: no data found" even
    though the "tasks" table has data in it. Plz help
    Thanks,
    TJ

    hi
    Please try this
    1. Create 2 region
    1st region source=
    select * from tasks'
    go to the tab -> condition =
    item NOT NULL
    EXpression1 =:P10_TASK_DATE
    this will run whenever the item have any date
    2. open your 2 nd region source code= select * from discovery
    put the condition
    item is  NULL
    EXpression1 =:P10_TASK_DATE
    thanks
    Mark Wyatt

  • PL/SQL Function Returning Query Error / ORA-01858: a non-numeric char.....

    I'm trying to write a PL/SQL function to dynamically return a query with varying # of columns. I've done this type of thing before wiith much success, however this is the first time I'm using a cursor for loop within a function to accomplish my task.
    here is the error I get:
    ORA-01858: a non-numeric character was found where a numeric was expected
    Error ERR-1101 Unable to process function body returning query.
    Mind you I have tested the PL/SQL from a SQL editor and it works fine. I'm confused.
    Code is below.
    Thanks in advance!
    DECLARE
    my_query varchar2(4000);
    string1 varchar2(50) := 'select city, ';
    string2 varchar2(4000) := '' ;
    string3 varchar2(4000):= 'from
    ( select a.title, a.city, a.start_date, sum(a.total_stu) cnt
    from sj_class_summary3 a
    group by a.title, a.city, a.start_date
    having a.title = :P4_COURSE )
    group by title, city';
    TYPE date_tab_type IS TABLE OF date INDEX BY PLS_INTEGER;
    date_tbl date_tab_type;
    i number;
    BEGIN
    i:=1;
    for myrec in (select distinct start_date from sj_class_summary3
    where start_date between :P4_START_DATE and :P4_END_DATE order by 1) loop
    date_tbl(i) := myrec.start_date;
    string2 := string2 || ' max( decode( start_date, ''' || date_tbl(i) || ''', cnt,0) ) "' || date_tbl(i) || '", ';
    i := i+ 1;
    end loop;
    string2 := SUBSTR(string2,1,LENGTH(string2)-2);
    string2 := string2 || ' ';
    my_query := string1 || string2 || string3;
    return my_query;
    END;

    Hi Bob,
    you also have another date to character to date conversion in:
    decode( start_date, ''' || date_tbl(i) || ''', cnt,0)
    does this need to be:
    decode( start_date, to_date(''' || to_char(date_tbl(i), 'dd/mm/yyyy') || ''', ''dd/mm/yyyy''), cnt,0)
    Regards
    Michael

  • PL/SQL Function call error while reading or assigning returned value

    Hi,
    I am getting the following error while tryih to read the value of the PL/SQL Function. I am calling a function in one of my PL/SQL Packages passing mutliple IN parametes and the function returns some value back. Now on BPEL side when I try to read the return value I am getting an error:
    *<summary>*
    empty variable/expression result.
    xpath variable/expression expression "/ns3:OutputParameters/ns3:TEST_FUNCTION" is empty at line 124, when attempting reading/copying it.
    Please make sure the variable/expression result "/ns3:OutputParameters/ns3:TEST_FUNCTION" is not empty.
    *</summary>*
    Even though in the console when I check the Invoke Output Parameter it does shows me a valid value being retuned by a Function but when I am trying to Assgn this value to some variable using Assign Activity I get the above error.
    Even though all goes fine but looks like I am not able to read or assign the value returned from the Function.
    So just wondering if this even works as to me I have a very simple example and that seems not to work. Function is called successfully and is returning the value as I can see it in the BPEL console but when tryin to read or assign that value to some other variable I get the above error.
    Any ideas?
    Thanks

    This issue has come up a lot. The problem is with a mismatch between the version of JDeveloper and SOA. You'll encounter namespace issues if you use 10.1.3.1 in combination with 10.1.3.3 (or 10.1.3.4). You MUST synchronize both JDev and SOA to 10.1.3.3 or 10.1.3.4 (mixing 10.1.3.3 and 10.1.3.4 is OK). We changed when going to 10.1.3.3 by adding elementFormDefault="qualified" to the generated XSD. We used the default "unqualified" in 10.1.3.1. So you'll encounter namespace issues unless you're using 10.1.3.3 or higher JDev AND SOA. The fact that I see &lt;*db:*...&gt; tells me that you're using 10.1.3.1 JDeveloper. The correct solution is to upgrade your components.

  • Error Using LISTAGG SQL Function

    Hello,
    I'm trying to use the new LISTAGG SQL function with the following expression in a report:
    select listagg(email, ';') within group (order by email) as email_list from sba_registration_entries where team=241
    and I get the following SQL error in Apex SQL Workshop:
    ORA-00923: FROM keyword not found where expected
    Is this function enabled on the apex.oracle.com site? Am I using the correct syntax?

    Hi,
    The current database on apex.oracle.com is "Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production"
    The LISTAGG function seems to be from version 11.2: [http://download.oracle.com/docs/cd/E11882_01/server.112/e10592/functions087.htm] ?
    Andy

  • Error PLS-00306 during calling PL/SQL function from Java

    Hi all,
    I am facing a problem during call of oracle PL/SQL function from java using CallableStatement.
    I receive following error message.
    java.sql.SQLException: ORA-06550: line 1, column 13:
    PLS-00306: wrong number or types of arguments in call to 'EXPORT_HIST_ALARMS_FUNC'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    As per above error EXPORT_HIST_ALARMS_FUNC in oracle has this signature.
    CREATE OR REPLACE FUNCTION EXPORT_HIST_ALARMS_FUNC(startDateTime VARCHAR2, endDateTime VARCHAR2, meType VARCHAR2) RETURN VARCHAR2 IS
    END EXPORT_HIST_ALARMS_FUNC;
    Above function I have called following way in java.
    String sql = "begin ?:= EXPORT_HIST_ALARMS_FUNC(?, ?, ?); end;" ;
    CallableStatement cStatement = null;
    cStatement = connection.prepareCall(sql);
    cStatement.registerOutParameter(1,Types.VARCHAR);
    cStatement.setString(2,startDateTime);
    cStatement.setString(3,endDateTime);
    cStatement.setString(4,meType);
    cStatement.execute();
    msg = cStatement.getString(1);
    Actually above function requires three input parameters and one return parameter.
    During execution of above java code it throws SQLException and shows PLS-00306: wrong number or types of arguments in call to 'EXPORT_HIST_ALARMS_FUNC' error.
    I have run this function directly from oracle with three parameters and run successfully and finally it returns string.
    But I am unable to figure out why it doesn't run from above java code.
    Please help regarding this.
    Thanks.
    Regards,
    Shardul Banker

    Try this:
    String sql = "begin ?:= EXPORT_HIST_ALARMS_FUNC(?, ?, ?); end;" ;
    CallableStatement cStatement = null;
    cStatement = connection.prepareCall(sql);
    cStatement.registerOutParameter(1,Types.VARCHAR);
    cStatement.setString(1,startDateTime);
    cStatement.setString(2,endDateTime);
    cStatement.setString(3,meType);
    cStatement.execute();
    msg = cStatement.getString(1);Regards,
    Martijn Teigeler
    Edited by: mTeigeler on Oct 13, 2007 10:22 AM

  • Error on calling PL/SQL function

    Hi All,
    I have a code to call an existing PL/SQL function as following:
    PL/SQL function:
    FUNCTION pub_pkg.get_acc_rule_id (
    i_pub_id IN NUMBER,
    i_issue_id IN NUMBER,
    i_item_type IN VARCHAR,
    i_start_date IN DATE,
    i_end_date IN DATE
    RETURN NUMBER;
    Java Code:
    public Number getAccountingRuleId(Number pubId, Number issueId, String itemType,
    Date startDate, Date endDate)
    Number ruleId = new Number(-1);
    String sqlstatement =
    "BEGIN " + "\n"
    +" :1 := pub_pkg.get_acc_rule_id " + "\n"
    +" (p_param1 => :2" + "\n"
    +" ,p_param2 => :3" + "\n"
    +" ,p_param3 => :4" + "\n"
    +" ,p_param4 => :5" + "\n"
    +" ,p_param5 => :6" + "\n"
    +" );" + "\n"
    +"END; " + "\n";
    OADBTransaction trans = this.getOADBTransaction();
    OracleCallableStatement cStmt =
    (OracleCallableStatement) trans.createCallableStatement(sqlstatement,1);
    try
    cStmt.setNUMBER(2,pubId);
    cStmt.setNUMBER(3,issueId);
    cStmt.setString(4,itemType);
    cStmt.setDATE(5,startDate);
    cStmt.setDATE(6,endDate);
    cStmt.registerOutParameter(1, Types.INTEGER, 0, 10);
    cStmt.execute();
    ruleId = new Number(cStmt.getNUMBER(1));
    cStmt.close();
    catch (Exception ex)
    throw OAException.wrapperException(ex);
    finally
    try
    cStmt.close();;
    catch(Exception e)
    throw OAException.wrapperException(e);
    return ruleId;
    But I got error as following:
    java.sql.SQLException: ORA-06550: line 2, column 8:
    PLS-00306: wrong number or types of arguments in call to 'GET_ACC_RULE_ID'
    ORA-06550: line 2, column 2:
    PL/SQL: Statement ignored
    Can anyone help me to point out where is wrong with my code?
    Thanks & Regards,
    KJ

    That's a nice summary of this thread discussion, KJ. I hope other guys also start doing the same when their issue gets fixed.
    To add to above summary, if you want to call a procedure instead of a function, then you need to modify the line
    String sql = "begin :1 := package.function(:2,:3,:4); end;";
    to
    String sql = "begin package.procedure(:1,:2,:3); end;";
    In and out parameters can be as per the actual procedure.
    --Shiv                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to debug PL/SQL functions? Passing parameter and debugger error

    Hi,
    How to debug a PL/SQL function in JDeveloper? There are two problems with it:
    1) Don't see how it's possible to pass parameters required by function call (in the dialog opening after Debug -> Debug FUNCTION_NAME)
    2) In a function returning table_name%ROWTYPE (and having a record declaration for table_name%ROWTYPE), debug gives error:
    PLS-00103: Encountered symbol "/" when expecting one of ... in line
    v_Return PL/SQL RECORD;
    Debugging procedures works as expected.
    Found a similar question without answer here:
    Debugging PL/SQL with parameters

    Check
    http://www.oracle.com/technology/obe/obe9051jdev/plsqlobe/obeplsql.htm#t2
    Frank

  • ADO function error:SQL execute.vi is not executable​.

    Thanks for everyone who is willing to help me out of this problem that puzzled me several days,I can't find a similar one from Google or other forum..
    Problem:
    When I was using LabSQL,it come an error:
    Subvi "SQL execute":subvi isnot executable. and then I searched the source of the error,it was finally found to be the 
    "ADO Recordset GetString.vi":
    "invoke node:invalid method"
    "invoke node:invalid refnum class". 
    What I used is Windows 7 and LabVIEW7.1.
    Attached is the detail of this problem that includes the vi and some error pictures,and the ADO functions I used.
    ute.vi" is
    Attachments:
    Error.zip ‏1865 KB

    Duplicate - http://forums.ni.com/t5/LabVIEW/ADO-function-error​-SQL-execute-vi-is-not-executable/m-p/2397360#M742​...
    Try to take over the world!

  • Error while creating sql function

    I am getting the following error when i execute the below query for creatin sql function. Please let me know waht is the problem
    Major Error 0x80040E14, Minor Error 25501
    > create FUNCTION fantastic ( @deal_id , @as_of_date)
    returns @funtab table
    (issue_id int not null,
    par_amount money not null)
    as
    begin
    insert @funtab
    select a.issue_id,a.par_amount 
    from asserts as a, issue as i, issuer_rating_history h, deal d
    where h.as_of_date = @as_of_date and
     d.deal_id = @deal_id and 
    d.deal_id = a.deal_id
    a.issue_id=i.issue_id 
    return
    end
    There was an error parsing the query. [ Token line number = 1,Token line offset = 8,Token in error = FUNCTION ]
    create FUNCTION fantastic ( @deal_id , @as_of_date)
    returns @funtab table
    (issue_id int not null,
    par_amount money not null)
    as
    begin
    insert @funtab
    select a.issue_id,a.par_amount 
    from asserts as a, issue as i, issuer_rating_history h, deal d
    where h.as_of_date = @as_of_date and
     d.deal_id = @deal_id and 
    d.deal_id = a.deal_id
    a.issue_id=i.issue_id 
    return
    end

    Hello,
    See MSDN
    Differences Between SQL Server Compact and SQL Server => "User-defined functions and full text:
    Not supported" in SQL CE, so you can not create a function as in SQL Server.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Sql function sequence error

    i have a programm ... every time i try to add somthing to it ; wiil bring an error message telling me that there is an (sql function sequence error) ....
    for example i have somthing like
    if(i<beginYear){
    principal[i] = amount/installment;//somthing like that
    //other statments
    here i tried to change it like
    if(i<beginYear + 1)
    and the error came .....
    have you any idea..!!!

    actually iam using a microsoft access table but what is sstrange is that the error comes after the data base has been closed , so i didnt see any connection between the sql and what is going on..... i wander what usually ment by sql funftion sequence error...

  • 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]

Maybe you are looking for

  • GL balances are not matching with Fixed assets ledger

    Hi, Please suggest me regarding this... The issues is:when the legacy balances are uploaded in to sap there was the mistake.3 assets were entered twice(once in asset class 1250 & once in asset class 1300).It causes the GL balances are not matching wi

  • Error installing Azure SDK 2.2: An error occurred while parsing Entityname. Line 1031, position 71.

    I am setting up a new machine for windows azure development. I have VS 2013 Ultimate with Team Explorer on Windows 7 Enterprise.  When I launch the Web Installer for Azure SDK 2.2 I receive a dialog almost immediately with the message:  An error occu

  • ADFBC 10.1.3.3 Row Level Security

    Hello. Till now, we have implemented Row Level Security through a database function, and using this function in all our view objects where clause. We would like to remove this database function, and implement this kind of security with ADFBC. Is this

  • Closing balance

    hello experts,           i need to show closing balance for customer line open items in fbl5n header level.should i take dmbtr field from bsid table?or umsav field?is there any FM for closing balance?plz help me. thanks.

  • Performance Problem-Getting huge Dump

    Hi Guruz, I am facing performanece issue in my Production Server.From the last mont end I am getting a lot of TIME_OUT dump though the number of users and processing are quite same. The profile parameter "rdisp/max_wprun_time" is not set so it is tak