String scalar Function in ms sql2005

Can someone  help me with a function?
I have some sql:
  SELECT depositReceivedCurrency ,SUM(depositReceivedAmount) AS currencyAmount
    FROM    dbo.tbTrades
     WHERE clientID = 1 AND  depositReceivedCurrency IS  NOT NULL
      GROUP BY depositReceivedCurrency
That returns a table like so:
EUR    35459.00
GBP    1000.00
Note: there could be more than 2 currencies
I would like a function that would take this table and out put a string like this:
"EUR    35459.00 / GBP    1000.00"  [ + / ith currency amount]
Possible? here's a chance to show off

I've removed the stuff for simplicity and this gets me what I want:
    SELECT   ( (
SELECT  ' ' + depositReceivedCurrency + ' ',
        CAST(SUM(depositReceivedAmount) AS VARCHAR) + '   '
FROM    dbo.tbTrades
WHERE   clientID = 1
        AND depositReceivedCurrency IS  NOT NULL
GROUP BY depositReceivedCurrency
                                FOR
                                  XML PATH('')
the string
EUR 35459.00    GBP 1000.00    USD 324.00 
however if I do this:
  DECLARE @ResultVar VARCHAR
    SET @ResultVar = (
    SELECT   ( (
SELECT  ' ' + depositReceivedCurrency + ' ',
        CAST(SUM(depositReceivedAmount) AS VARCHAR) + '   '
FROM    dbo.tbTrades
WHERE   clientID = 1
        AND depositReceivedCurrency IS  NOT NULL
GROUP BY depositReceivedCurrency
                                FOR
                                  XML PATH('')
    select @ResultVar
I get nothing

Similar Messages

  • UDB scalar functions and parameter markers

    Hello,
    While using Prepared Statements in combination with UDB scalar functions (translate UDB function, for example), I get a Parameter marker error. The SQL statement works fine as an independent query.
    SQL Query example from UDB manual used as is:
    UPDATE EMPLOYEE
    SET LASTNAME = TRANSLATE(CAST(? AS VARCHAR(12)))
    WHERE EMPNO = ? When the above query is used as a Java prepared statement, an invalid parameter marker error occurs.
    Any ideas?
    Thanks.

    Personally, I'd try that SQL as:
    UPDATE EMPLOYEE
    SET LASTNAME =  CAST (UPPER(?) AS VARCHAR(12) )
    WHERE EMPNO = ? not least because it makes the action of the translation explicit, but mostly because other DBs that have a TRANSLATE function don't support the "1 parameter implicitly means upper case" form you're using (at first, I thought you were getting a bogus message for a mangled function call, but then I dug out the old DB2 docs and saw what the hell the TRANSLATE was intended to do here..)
    Also, my (old) reference doesn't list a CAST function, although it's certainly not up to date; instead it shows casting done in this style:
    UPDATE EMPLOYEE
    SET LASTNAME =  VARCHAR (UPPER(?) , 12)
    WHERE EMPNO = ? It doesn't show a VARCHAR2 function either, but I'd guess they're type-compatible in this application... hope this gives you something else to try...

  • How to know the no. of bytes in a String Control Function?

    Hi,
    I would like to know the no. of bytes for a certain String Control Data.
    For instance, if i have a String Length Function, on the left is a String Control and on the right is a Length Indicator.
    If i will type coordinates, i.e. 9.25,4.25 on the String Control it will show 9 on the Length Indicator. I think 9 do not mean 9 bytes but
    only a length. Is there any function in LV that will tell me the total bytes of the data on the string control?
    Appreciate for any advise.
    Thanks a lot.

    Thanks tst for your kind reply.
    Here is what i am trying to find/goal.
    I will be using wireless receiver for my system. The wireless receiver have some signal strength ranges; 95dbm @ 1Mbps (mega bit per sec), 90dbm @ 11Mbps, 82 dbm @ 24 Mbps and 75dbm @ 54 Mbps. Ofcourse i prefer to have lower data transfer rate so that my signal strength is best.
    I will be sending coordinate data/s via wireless communication using string controls. But i do not know how big/heavy is my coordinate data
    If i can know how many bytes or mega bytes the data i want to send then i will be able to transfer it to bits or mega bits(8 bits = 1 byte) thus i will know which setting i can use for the wireless receiver. And if the data is too big then i have a basis to redesign my data transfer to suite a better signal strength.
    Thanks for your help.

  • Pad leading zeros in a string.Format function

    How could use the string.Format function and in the format text pad a leading zero? 
    Pseudo code is:
    string parm = “5”;
    string format = “Some number formatted as 3 dig: Format({0}, 000)”;
    string output = string.Format(format, parm);
    Where the output would look like this:
    “Some number formatted as 3 dig: 005”
    Thanks.

    Thanks everyone. Unfortuantly there's a constraint where the padding operation needs to be embedded in the format string. This entire operatin is being put together dynamically where the format strings are being pulled from a library of format strings stored
    in a database. at runtime we don't know how which format will be used and how many parameters will be passed in. we have logic to handle the unknown number of paramters as there is metadata which helps us with that.
    the need for leading zeros needs to be part of the overall format defined in the format string.  for example, a real format string stored in the database looks like this:
    "LINE_NO = '{0}',  AND GEO_LOCATION = 'T{1}, {2},  R{3}, {4}, , Sec. {5}'"
    and its output from the string.Function is:
    "LINE_NO = 'TG-G2469',  AND GEO_LOCATION = 'T155, N,  R93, W, , Sec. 5'"
    the last parameter (param 5) had a value of 5.  In another case the output requirement might need to look like this:
    "LINE_NO = 'TG-G2469',  AND GEO_LOCATION = 'T155, N,  R93, W, , Sec. 05'"
    note the "05" at the end...
    the logic of using the leading zero needs to be embedded in the overall format string text.
    Thank you.

  • Implementing JDBC / scalar functions

    Hi,
    I am part of a team implementing a JDBC driver to allow third party software to query our data stores. We want to implement the full range of scalar functions listed in the JDBC spec. At the start of Appendix C there is a reference to the Open Group CLI specification for "more information on the semantics of the scalar functions". However, I cannot find any reference to scalar functions in the CLI spec found here:
    http://www.opengroup.org/bookstore/catalog/c451.htm
    Does anyone know where detailed specifications of the scalar functions may be found? I am particularly interested in behaviour when encountering null arguments.
    Thanks for any help,
    Rob

    Thanks for the link. However, I've already found definitions of a similar detail. I'm really interested in tracking down the original specification that the authors of JDBC were looking at, which will hopefully offer detailed desciptions of the required behaviour when dealing with null and invalid arguments.
    Rob

  • SQL 2012 not recognizing modification of scalar function

    I have two scalar functions which are both very similar. Both required three variables. Then I realized that I needed another variable in both functions so I added it to both.  I then modified the call to each function (e.g. select dbo.function(var1,
    var2, var3, var4)), but within Management Studio editor, only the change in the first function is recognized. Below is the function that is not recognized and the call to it.  The error is 'insufficient number of arguments'.  Its as if Management
    Studio doesn't realize I made the change.
    ALTER FUNCTION [dbo].[InvoicePaidLateInFull](@Invoice bigint, @DueDate datetime, @Total decimal(14, 4), @EndDate datetime)
    RETURNS bit
    AS
    BEGIN
    DECLARE @PaidLate bit, @Paydate datetime, @Amount decimal(14, 4)
    declare @Check int, @CurrentStatus bigint
    declare @AmtTol decimal(14,4), @CID bigint
    Set @PaidLate = 0
    Set @CurrentStatus = (Select top 1 StatusID from RebateData Where InvoiceNo = @Invoice order by ID)
    if @CurrentStatus <> 1
    Begin
    Goto NotDueYet
    End
    Set @CID = (Select top 1 CID from RebateData Where InvoiceNo = @Invoice order by ID)
    Set @AmtTol = (Select AmountTolerance from MasterCustomerProgramContracts where ID = @CID)
    If datediff(dd, @DueDate, @EndDate) < 0
    Begin
    GoTo NotDueYet
    End
    Set @Check = (Select count(*) from Payments Where InvoiceNo = @Invoice)
    if @Check = 0
    Begin
    --No payments have been received at all. Consider as 'Unpaid'
    GoTo NotDueYet
    End
    Set @Amount = isnull((Select round(sum(Amount) , 2)
    from Payments
    where invoiceno = @Invoice
    and PayDate <= @DueDate
    Group by InvoiceNo), 0)
    Set @Amount = -(@Amount)
    If @Amount between (@Total - (@Total * @AmtTol)) and (@Total + (@Total * @AmtTol))
    Begin
    Set @PaidLate = 0
    End
    If @Amount < (@Total - (@Total * @AmtTol))
    Begin
    Set @PaidLate = 1
    End
    NotDueYet:
    RETURN @PaidLate
    END
    The Call:
    Set @PL = (Select dbo.InvoicePaidLateInFull(@Inv, @DueDate, @Total, @EndDate))
    Seems like I read the other day of a script that can be run to 'update' SQL, but I can't remember it now.
    Thanks.
    Ross

    Leaving the Intellisense issue, permit me to point out that incorrectly used, this function can be a performance killer. An occasional call - no problem. But if you do something like:
    SELECT ..., dbo.InvoicePaidLateInFull(invoice_id, due_date) AS PaidLade
    FROM   MillionRowTable
    This is a performance disaster. SQL Server cannot optimize the function, so you will have a cursor in disguise.
    Overall, you should be very restrictive with scalar functions that perfoms data access.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Determine length of string without function module

    hai experts,
    i need to know how to determine length of string without function module strlen'
    regards,
    karthik

    Please SEARCH in SCN before posting.

  • Scalar function For Identity Or Row Number

    Hi
    I need to create a scalar Function that works in the same way as Row Number or a Identity column
    I've not really used functions before so what would be the best way to do this?
    Regards

    Well I'm taking over a ETL process for a OLAP cube which is using SQL scripts and views and Not SSIS, any other logic other than what is available in the design mode of the view are done in functions. If i use the built in one I lose the
    design view.
    If you are making your database design from what you see in some "design mode" you are putting the cart before the horse.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Simple String Compression Functions

    Hi all !
    I need two simple String compression functions, like
    String compress(String what)
    and
    String decompress(String what)
    myString.equals(decompress(compress(myString)))
    should result in true.
    Primarily I want to encode some plain text Strings so they are not too easy to read, and compression would be a nice feature here.
    I already tried the util.zip package, but that one seems to need streams, I simply need Strings.
    Any ideas ??
    thx
    Skippy

    It does not do any compression, in fact it does
    expansion to better encrypt the string (about 50%).How does that work? You want encryption to
    decrease entropy.Why in the world do you say that, pjt33? What a very odd statement indeed. I sure hope you don't work in security, or I do hope you work in security if I'm a bad guy, or a competitor.
    Let's say you had a 6-character string you wanted to encrypt.
    Well, if you didn't increase the entropy, any 6-character plaintext string would have a 6-character encoded equivalent. And if you decreased entropy (e.g. coding the most commonly used words to shorter strings,) it gets even easier to decrypt.
    Presumably there would be no hash collisions, after all, you want this to be reversible.
    Hash collisions decrease entropy too, and, by doing so, make it easier to find a plaintext string that happens to hash to a certain value. This is a Bad Thing.
    Now, to decode this, the Bad Guy only has to consider the set of 6-character strings and their hash values. You could even precalculate all of the common dictionary words, and everything with common letters and punctuation, making decryption virtually instantaneous. Especially if you had decreased the entropy in the signal, making fewer things I had to try.
    But somebody who increased the entropy of their signal by adding random bits and increasing the encrypted size of the message to, say, 64 characters, would make it a lot harder to decrypt.
    The ideal encryption system is pure noise; pure randomized entropy. An indecipherable wall of 0 and 1 seemingly generated at random. Statistical methods can't be used against it; nothing can be deciphered from it; it's as decipherable and meaningless as radio hiss. Now that's encryption!

  • Typecasting String to Function in AS3

    Hi,
    I would like to typecast a String to Function. The following is the code snippet,
    var  
    var funcionVar:Function = functionName as Function;
    bt.addEventListener(MouseEvent.CLICK,funcionVar);
    public function onSearch(event:MouseEvent) {
    // Code here
    While converting String to Function, it is returning null value. Is there any possible ways to achieve this?
    Thanks,
    Srinivasan S
      functionName:String = "onSearch" ; 

    This is the code snippet,
    var functionName:String = "onSearch";
    var funcionVar:Function = functionName as Function;
    bt.addEventListener(MouseEvent.CLICK,funcionVar);
    public function onSearch(event:MouseEvent) {
    // Code here
    Could you please help to resolve this?
    Thanks,
    Srinivasan S

  • String CDF functions not working in business rules

    Working with EPM 11.1.2. I created a calc script on the planning cube and it works perfectly. I then put the same code in a business rule and it will not validate. Please see the code below.
    1) created udf folder in following directory
    essbase/Oracle/Middleware/EPMSystem11R1/products/Essbase/EssbaseServer/java
    2) modified udf policy to grant access to all
    3) saved CDF_String.jar file to new udf folder on server
    4) registered functions via maxl
    5) stop/start application
    6) stopped/started EAS services
    I get the following error in the message window (line 9 is the JGetStringFromDouble statement):
    "Encountered " "-> " "-> "" at line 9, column 35.
    Was expected one of:
    What do I need to do to get this code working as a business rule since I want to use RTPs in this routine?
    FIX("No_Profit_Center", FY07:&CapAppEndYr, "Working Plan", "Current", "Manual_Input", "LOC", @Relative("Period",0), @Relative("Project",0), @Relative("Entity",0))
    "AC_Unappr_Fcst_Depr"
      IF ( "AC_Unappr_Fcst_Depr"  == #Missing)
         IF ("FY07"->"No_Period"->"AC_Depr_CC" != #Missing)
              "AC_Unappr_Fcst_Depr"->(@MEMBER(@CONCATENATE("EN_",@JgetStringFromDouble("FY07"->"No_Period"->"AC_Depr_CC",@_False,@_False))))  = "AC_Unappr_Fcst_Depr_Temp";
        ELSE
              "AC_Unappr_Fcst_Depr" = "AC_Unappr_Fcst_Depr_Temp";
        ENDIF
      ENDIF
    ENDFIXEdited by: jjdubb on Jun 11, 2012 9:10 AM

    I've had this issue with a different string function. Business Rules does not like the boolean parameters (@_FALSE) used in these CDF's. I had a similar issue and had to rewrite my CDF without the parameters. You basically need to hardcode the "with quotes" and "with decimals" parameters in the java code.
    Hope this helps,
    - Jake

  • Problem in getting last value of a string in Function Module

    Hi,
    I am working on FM in which i have to put highfen mark which is working ok,but the problem if there is when the value of string finds a space it should not insert highfen in it and i am not able to put the condition in it as it showing the higfen even when the word is full in the first line.i want to show highfen where the word is not able to display complete. here is d code which i am using right now. plzz provide me guidlines to solve this problem.
    here's d code:-
    FUNCTION Z_STRING_LENGTH1.
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(I_STRING) TYPE  STRING
    *"     VALUE(LENGTH) TYPE  I
    *"  EXPORTING
    *"     VALUE(E_STRING) TYPE  STRING
    data: STRING_F type string, "Stores the value in string format
          STRING_LENGTH type i, "Length of the string
          DIFF type i,          "Difference among the value
          DIFF1 TYPE C,
          STRING1 type string,  "Stores the 1st String
          STRING2 type string,  "Stores the 2nd String
          STRING3 type string,  "Stores the 3rd String
          STRING4 type string,  "Stores the 3rd String
          STRING5 type string,  "Stores the 3rd String
          LENGTH2 type I.
    STRING_F = I_STRING.
    STRING_LENGTH = STRLEN( I_STRING ).
    DIFF = STRING_LENGTH - LENGTH.
    IF DIFF LE 0.
      DIFF = 0.
    ENDIF.
    IF LENGTH LE STRING_LENGTH.
      STRING1 = STRING_F(LENGTH).
    ELSE.
      STRING1 = STRING_F(STRING_LENGTH).
    ENDIF.
    IF LENGTH LE STRING_LENGTH.
      STRING2 = STRING_F+LENGTH(DIFF).
    ELSE.
      STRING2 = STRING_F+STRING_LENGTH(DIFF).
    ENDIF.
    length2 = length - 1.
    STRING3 = STRING1+length2(1).
    STRING4 = STRING2+0(1).
    IF LENGTH LE STRING_LENGTH AND STRING3 NE SPACE AND STRING4 NE SPACE.
      concatenate STRING1 '-' STRING2  into STRING5.
      e_string = STRING5.
    ELSE.
      concatenate  STRING1 STRING2 into STRING5.
      e_string = STRING5.
    ENDIF.
    ENDFUNCTION.
    Edited by: ricx .s on May 12, 2009 5:20 AM

    Hi,
    I checked your code... its working fine except for some cases it is giving dumps for which I have added certain if conditions....
    Please check the modified code below... have optimized it as well by removing one extra if condition....
    you can copy and paste the code below...
    DATA: STRING_F TYPE STRING, "Stores the value in string format
          STRING_LENGTH TYPE I, "Length of the string
          DIFF TYPE I,          "Difference among the value
          DIFF1 TYPE C,
          STRING1 TYPE STRING,  "Stores the 1st String
          STRING2 TYPE STRING,  "Stores the 2nd String
          STRING3 TYPE STRING,  "Stores the 3rd String
          STRING4 TYPE STRING,  "Stores the 3rd String
          STRING5 TYPE STRING,  "Stores the 3rd String
          LENGTH2 TYPE I.
    STRING_F = I_STRING.
    STRING_LENGTH = STRLEN( I_STRING ).
    DIFF = STRING_LENGTH - LENGTH.
    IF DIFF LE 0.
      DIFF = 0.
    ENDIF.
    IF LENGTH LE STRING_LENGTH.
      STRING1 = STRING_F(LENGTH).
      STRING2 = STRING_F+LENGTH(DIFF). " added this statement in this if itself instead of one extra if
    " which is not required
    ELSE.
      STRING1 = STRING_F(STRING_LENGTH).
      STRING2 = STRING_F+STRING_LENGTH(DIFF).
    ENDIF.
    IF LENGTH IS NOT INITIAL.
      LENGTH2 = LENGTH - 1.
    ENDIF.
    " put this if condition as there is a dump occuring at this place.
    " Dump occurs when you give the length value as 0
    " Say for example the value of I_STRING, I passed it as SIDDARTH
    " and the length I passed as 0, then it gives me a dump
    STRING3 = STRING1+LENGTH2(1).
    IF STRING2 IS NOT INITIAL.
      STRING4 = STRING2+0(1).
    ENDIF.
    " put this if condition as there is a dump occuring at this place.
    " Dump occurs when you give the length value greater than or equal to
    " the string length
    " Say for example the value of I_STRING, I passed it as SIDDARTH
    " and the length I passed as 8, then it gives me a dump
    IF LENGTH LE STRING_LENGTH AND STRING3 NE SPACE AND STRING4 NE SPACE.
      CONCATENATE STRING1 '-' STRING2  INTO STRING5.
      E_STRING = STRING5.
    ELSE.
      CONCATENATE  STRING1 STRING2 INTO STRING5.
      E_STRING = STRING5.
    ENDIF.

  • Maximum length of query string for functions return a SELECT

    Hi all,
    I have a report that gets it's SELECT statement from a function, instead of being coded into the region. All was well but I suspect now I'm blowing some kind of limit as I'm getting an error :
         ORA-06502: PL/SQL: numeric or value error
         Error      ERR-1101 Unable to process function body returning query.
    However if I run the procedure out of ApEx and grab the SELECT statement then it works fine. The length of the query is 8636 bytes (yup, it's a beauty!).
    Does anyone know if there is a hard limit to the size of the string that can be returned?
    I'm using ApEx 3.1.
    Thanks,
    Steve H

    I do have a similar painfull scenario - Although my query length is very less i.e 618 bytes only.
    I have defined a stored function, which returns an SQL query string, this return SQL string executes fantastic but when I tried to to call this function from a APEX report it gives error. the details are as follows. Please help.......
    The function code:
    CREATE OR REPLACE function PROD."TEST_C_QRY"
    return VARCHAR2
    is
    msql VARCHAR2(32767);
    Begin
    msql:='Select null,statusname,AgeInd, ';
    For m_stat in (select statusname from a02_status)
    loop
    msql:= msql || q'[decode(statusname,']';
    msql:= msql || m_stat.statusname;
    msql:= msql || q'[',count(id),0) ]';
    msql:= msql || m_stat.statusname|| ',';
    end loop;
    msql:=rtrim(msql,',');
    msql:= msql||' from ';
    msql:= msql||'( ';
    msql:= msql||'select a.id, round(sysdate-a.registeredon) TimeSpan,';
    msql:= msql||'case ';
    msql:= msql||q'[when round(sysdate-a.registeredon)<=7 then 'Week' ]';
    msql:= msql||q'[when round(sysdate-a.registeredon)>7 and round(sysdate-a.registeredon)<14 then 'Fortnight' ]';
    msql:= msql||q'[when round(sysdate-a.registeredon)>14 and round(sysdate-a.registeredon)<30 then 'Month' ]';
    msql:= msql||q'[else 'More...'  end ageind,]';
    msql:= msql||'a.status_id,b.statusname ';
    msql:= msql||'from a02_task a,a02_status b ';
    msql:= msql||'where b.id=a.status_id) ';
    msql:= msql||'group by statusname,AgeInd;';
    return msql;
    end TEST_C_QRY;
    The Output SQL comes from this is
    SQL> Select null,statusname,AgeInd, decode(statusname,'Scheduled',count(id),0) Scheduled,decode(statusname,'Executing',count(id),0) Executing,decode(statusname,
    'Completed',count(id),0) Completed from ( select a.id, round(sysdate-a.registeredon) TimeSpan, case when round(sysdate-a.registeredon)<=7 then 'Week' when round
    (sysdate-a.registeredon)>7 and round(sysdate-a.registeredon)<14 then 'Fortnight' when round(sysdate-a.registeredon)>14 and round(sysdate-a.registeredon)<30 then
    'Month' else 'More...' end ageind, a.status_id,b.statusname from a02_task a,a02_status b where b.id=a.status_id) group by statusname,AgeInd;
    The result that comes when I execute the above resultant SQL is as follows.
    N STATUSNAME AGEIND SCHEDULED EXECUTING COMPLETED
    Completed More... 0 0 4
    Completed Week 0 0 1
    Scheduled Week 1 0 0
    Completed Month 0 0 3
    Executing More... 0 1 0
    Executing Month 0 6 0
    Scheduled More... 1 0 0
    7 rows selected.
    But the surprising error that comes from Oracle XE when I use the following code for stacked bar chart
    Code:
    begin
    return TEST_D_QRY;
    end;
    Error thrown by XE report builder is as follows:
    1 error has occurred
    Failed to parse SQL query!
    Select null,statusname,AgeInd, decode(statusname,'Scheduled',count(id),0) Scheduled,decode(statusname,'Executing',count(id),0) Executing,decode(statusname,'Completed',count(id),0) Completed from ( select a.id, round(sysdate-a.registeredon) TimeSpan, case when round(sysdate-a.registeredon)<=7 then 'Week' when round(sysdate-a.registeredon)>7 and round(sysdate-a.registeredon)<14 then 'Fortnight' when round(sysdate-a.registeredon)>14 and round(sysdate-a.registeredon)<30 then 'Month' else 'More...' end ageind, a.status_id,b.statusname from a02_task a,a02_status b where b.id=a.status_id) group by statusname,AgeInd;
    Certain queries can only be executed when running your application, if your query appears syntactically correct, you can save your query without validation (see options below query source).
    Regards,
    Soumen

  • Finder/sql - scalar functions

    Hi , I am running WLS7sp1, oracle 8.1.7 with the classes12.zip drivers
    I have a finder method as follows:
    <query>
              <query-method>
                   <method-name>findDistinctDrivenFields1</method-name>
                   <method-params>
                   <method-param>java.lang.String</method-param>
                   <method-param>java.lang.String</method-param>
                   <method-param>java.lang.String</method-param>
                   <method-param>java.lang.String</method-param>
              </method-params>
              </query-method>
         <ejb-ql>
         <![CDATA[
    SELECT o FROM DrivingDrivenMatrix AS o
    WHERE
    o.paramId = ?1 and
    ((o.drivingField = ?2 and
    (o.drivingCondition = 'BETWEEN' and
    (?4 BETWEEN {fn substring(o.drivingValue,1,{fn
    locate(o.drivingValue, 'and') } - 1) } and
    {fn substring(o.drivingValue,{fn
    locate(o.drivingValue, 'and')} +3,{fn length(o.drivingValue)})}
    ]]>
    </ejb-ql>
    </query>
    When ejbc runs ,
    it throws the error:
    [java] ERROR: Error from ejbc: Error while reading 'META-INF/weblogic-cmp-rdbms-jar.xml'.
    The error was:
    [java]
    [java] weblogic.ejb20.cmp.rdbms.finders.IllegalExpressionException:
    [java] While trying to process Query
    [java] Method Name: findDistinctDrivenFields1
    [java] Parameter Types: (java.lang.String, java.lang.String, java.lang.String,
    java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
    [java] EJB Query: ......
    [java] Could not parse EJB QL expression: .....
    [java] weblogic.ejb20.ejbc.EJBCException: antlr.TokenStreamRecognitionException:
    unexpected char: {
    [java] Error in 'BETWEEN' expression.
    [java] Check the BETWEEN syntax: expr1 [NOT] BETWEEN expr2 AND expr3
    [java] Check that no EJB QL keywords are being used as arguments: expr1, expr2
    or expr3.
    [java] Error in WHERE clause.
    [java] Check that no EJB QL keywords are being used as:
    [java] variable names.
    I guess if I have use functions like substring, locate, length in my finder I
    have to use it as
    eg: {fn substring() }
    which is what I am doing above.
    If I do not put the fn keyword in the finder, at runtime I get the following error
    java.sql.SQLException: Non supported SQL92 token at position: 757: fn
    java.sql.SQLException: Non supported SQL92 token at position: 757: fn
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
    at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:829)
    at oracle.jdbc.driver.OracleSql.handleToken(OracleSql.java:152)
    at oracle.jdbc.driver.OracleSql.handleODBC(OracleSql.java:112)
    at oracle.jdbc.driver.OracleSql.parse(OracleSql.java:64)
    at oracle.jdbc.driver.OracleConnection.nativeSQL(OracleConnection.java:762)
    at oracle.jdbc.driver.OracleStatement.expandSqlEscapes(OracleStatement.java:4790)
    at oracle.jdbc.driver.OracleStatement.parseSqlKind(OracleStatement.java:4779)
    at oracle.jdbc.driver.OraclePreparedStatement.<init>(OraclePreparedStatement.java:209)
    at oracle.jdbc.driver.OraclePreparedStatement.<init>(OraclePreparedStatement.java:165)
    at oracle.jdbc.driver.OracleConnection.privatePrepareStatement(OracleConnection.java:604)
    at oracle.jdbc.driver.OracleConnection.prepareStatement(OracleConnection.java:485)
    at weblogic.jdbc.jts.Connection.prepareStatement(Connection.java:138)
    at weblogic.jdbc.rmi.internal.ConnectionImpl.prepareStatement(ConnectionImpl.java:139)
    at weblogic.jdbc.rmi.SerialConnection.prepareStatement(SerialConnection.java:92)
    at com.bofa.news.business.entity.drivingdrivenmatrix.DrivingDrivenMatrixBean_g8txe4__WebLogic_CMP_RDBMS.ejbFindDistinctDrivenFields1(DrivingDrivenMatrixBean_g8txe4__WebLogic_CMP_RDBMS.java:1105)
    at java.lang.reflect.Method.invoke(Native Method)
    at weblogic.ejb20.cmp.rdbms.RDBMSPersistenceManager.collectionFinder(RDBMSPersistenceManager.java:314)
    at weblogic.ejb20.manager.BaseEntityManager.collectionFinder(BaseEntityManager.java:739)
    at weblogic.ejb20.manager.BaseEntityManager.collectionFinder(BaseEntityManager.java:712)
    at weblogic.ejb20.internal.EntityEJBLocalHome.finder(EntityEJBLocalHome.java:476)
    at com.bofa.news.business.entity.drivingdrivenmatrix.DrivingDrivenMatrixBean_g8txe4_LocalHomeImpl.findDistinctDrivenFields1(DrivingDrivenMatrixBean_g8txe4_LocalHomeImpl.java:123)
    whatz am I missing ?
    Thanx,
    Krish

    If I do not put the fn's in the finder explicitly, then at runtime I see the following
    in the log-file
    DRVR DBG1 SQL: "SELECT WL0.DRIVEN_FIELD, WL0.DRIVEN_VALUE, WL0.DRIVING_FIELD,
    WL0.DRIVING_VALUE, WL0.PARAM_ID, WL0.DEPENDENCY, WL0.DRIVEN_SCREEN_ID, WL0.DRIVING_CONDITION,
    WL0.LAST_UPDATE_TIME, WL0.LAST_USER_ID, WL0.MATRIX_DESC, WL0.RULE_DEFN, WL0.VERSION
    FROM DRIVING_DRIVEN_MATRIX WL0 WHERE ( (((WL0.PARAM_ID = ?)) AND ( (((WL0.DRIVING_FIELD
    = ?)) AND ( ( ( (((WL0.DRIVING_CONDITION = 'EQUAL')) AND ( ((? = WL0.DRIVING_VALUE)
    ) OR ((? = WL0.DRIVING_VALUE) ) ) ) OR (((WL0.DRIVING_CONDITION = 'NOTEQUAL'))
    AND ( ((? <> WL0.DRIVING_VALUE) ) OR ((? <> WL0.DRIVING_VALUE) ) ) ) ) OR
    (((WL0.DRIVING_CONDITION = 'LIKE')) AND ( ((WL0.DRIVING_VALUE LIKE ? ) ) OR
    ((WL0.DRIVING_VALUE LIKE ? ) ) ) ) ) OR (((WL0.DRIVING_CONDITION = 'BETWEEN'))
    AND ( (((? >= { fn SUBSTRING( WL0.DRIVING_VALUE, 1, { fn LOCATE( WL0.DRIVING_VALUE,
    'and' ) } - 1 ) } )) AND ((? <= { fn SUBSTRING( WL0.DRIVING_VALUE, { fn LOCATE(
    WL0.DRIVING_VALUE, 'and' ) } + 3, { fn LENGTH( WL0.DRIVING_VALUE ) } ) } ))
    ) OR (((? >= { fn SUBSTRING( WL0.DRIVING_VALUE, 1, { fn LOCATE( WL0.DRIVING_VALUE,
    'and' ) } - 1 ) } )) AND ((? <= { fn SUBSTRING( WL0.DRIVING_VALUE, { fn LOCATE(
    WL0.DRIVING_VALUE, 'and' ) } + 3, { fn LENGTH( WL0.DRIVING_VALUE ) } ) } ))
    ) ) ) ) ) OR (((WL0.DRIVING_FIELD = ?)) AND ((WL0.DRIVING_VALUE = ?)) ) )) AND
    ( ((WL0.DRIVEN_SCREEN_ID = ?) ) OR ((WL0.DRIVEN_SCREEN_ID = ?) ) ) ) "
    DRVR FUNC OracleStatement.OracleStatement(conn, batchValue=1, rowPrefetchValue=10)
    DBAC FUNC DBDataSetImpl.DBDataSetImpl(conn, nrows=0 ,dataSetType= 0)
    DRVR FUNC OraclePreparedStatement.OraclePreparedStatement(conn, sql, batchValue,
    rowPrefetchValue)
    DBAC FUNC DBDataSetImpl.DBDataSetImpl(conn, nrows=1 ,dataSetType= 1)
    DRVR FUNC OracleConnection.nativeSQL(sql)
    DRVR DBG1 Input SQL: "SELECT WL0.DRIVEN_FIELD, WL0.DRIVEN_VALUE, WL0.DRIVING_FIELD,
    WL0.DRIVING_VALUE, WL0.PARAM_ID, WL0.DEPENDENCY, WL0.DRIVEN_SCREEN_ID, WL0.DRIVING_CONDITION,
    WL0.LAST_UPDATE_TIME, WL0.LAST_USER_ID, WL0.MATRIX_DESC, WL0.RULE_DEFN, WL0.VERSION
    FROM DRIVING_DRIVEN_MATRIX WL0 WHERE ( (((WL0.PARAM_ID = ?)) AND ( (((WL0.DRIVING_FIELD
    = ?)) AND ( ( ( (((WL0.DRIVING_CONDITION = 'EQUAL')) AND ( ((? = WL0.DRIVING_VALUE)
    ) OR ((? = WL0.DRIVING_VALUE) ) ) ) OR (((WL0.DRIVING_CONDITION = 'NOTEQUAL'))
    AND ( ((? <> WL0.DRIVING_VALUE) ) OR ((? <> WL0.DRIVING_VALUE) ) ) ) ) OR
    (((WL0.DRIVING_CONDITION = 'LIKE')) AND ( ((WL0.DRIVING_VALUE LIKE ? ) ) OR
    ((WL0.DRIVING_VALUE LIKE ? ) ) ) ) ) OR (((WL0.DRIVING_CONDITION = 'BETWEEN'))
    AND ( (((? >= { fn SUBSTRING( WL0.DRIVING_VALUE, 1, { fn LOCATE( WL0.DRIVING_VALUE,
    'and' ) } - 1 ) } )) AND ((? <= { fn SUBSTRING( WL0.DRIVING_VALUE, { fn LOCATE(
    WL0.DRIVING_VALUE, 'and' ) } + 3, { fn LENGTH( WL0.DRIVING_VALUE ) } ) } ))
    ) OR (((? >= { fn SUBSTRING( WL0.DRIVING_VALUE, 1, { fn LOCATE( WL0.DRIVING_VALUE,
    'and' ) } - 1 ) } )) AND ((? <= { fn SUBSTRING( WL0.DRIVING_VALUE, { fn LOCATE(
    WL0.DRIVING_VALUE, 'and' ) } + 3, { fn LENGTH( WL0.DRIVING_VALUE ) } ) } ))
    ) ) ) ) ) OR (((WL0.DRIVING_FIELD = ?)) AND ((WL0.DRIVING_VALUE = ?)) ) )) AND
    ( ((WL0.DRIVEN_SCREEN_ID = ?) ) OR ((WL0.DRIVEN_SCREEN_ID = ?) ) ) ) "
    DRVR FUNC DBError.check_error(errNum=34, obj=757: fn)
    DRVR FUNC DBError.throwSqlException(errNum=34, obj=757: fn)
    DRVR FUNC DBError.findMessage(errNum=34, obj=757: fn)
    DRVR FUNC DBError.throwSqlException(reason="Non supported SQL92 token at position:
    757: fn", SQLState=null, vendorCode=17034)
    SQLException: SQLState(null) vendor code(17034)
    java.sql.SQLException: Non supported SQL92 token at position: 757: fn
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
         at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:829)
         at oracle.jdbc.driver.OracleSql.handleToken(OracleSql.java:152)
         at oracle.jdbc.driver.OracleSql.handleODBC(OracleSql.java:112)
         at oracle.jdbc.driver.OracleSql.parse(OracleSql.java:64)
         at oracle.jdbc.driver.OracleConnection.nativeSQL(OracleConnection.java:762)
         at oracle.jdbc.driver.OracleStatement.expandSqlEscapes(OracleStatement.java:4790)
         at oracle.jdbc.driver.OracleStatement.parseSqlKind(OracleStatement.java:4779)
         at oracle.jdbc.driver.OraclePreparedStatement.<init>(OraclePreparedStatement.java:209)
         at oracle.jdbc.driver.OraclePreparedStatement.<init>(OraclePreparedStatement.java:165)
         at oracle.jdbc.driver.OracleConnection.privatePrepareStatement(OracleConnection.java:604)
         at oracle.jdbc.driver.OracleConnection.prepareStatement(OracleConnection.java:485)
         at weblogic.jdbc.jts.Connection.prepareStatement(Connection.java:138)
         at weblogic.jdbc.rmi.internal.ConnectionImpl.prepareStatement(ConnectionImpl.java:139)
         at weblogic.jdbc.rmi.SerialConnection.prepareStatement(SerialConnection.java:92)
         at com.bofa.news.business.entity.drivingdrivenmatrix.DrivingDrivenMatrixBean_g8txe4__WebLogic_CMP_RDBMS.ejbFindDistinctDrivenFields1(DrivingDrivenMatrixBean_g8txe4__WebLogic_CMP_RDBMS.java:1105)
         at java.lang.reflect.Method.invoke(Native Method)
         at weblogic.ejb20.cmp.rdbms.RDBMSPersistenceManager.collectionFinder(RDBMSPersistenceManager.java:314)
         at weblogic.ejb20.manager.BaseEntityManager.collectionFinder(BaseEntityManager.java:739)
    "thorick" <[email protected]> wrote:
    >
    Right, the JDBC escapes 'fn' are not supported in EJB QL or WebLogic
    QL.
    What does the EJB QL query look like that does not have the 'fn' escapes
    -thorick

  • Returning unicode string through function argument.

    Hi all,
    I have following function written in a C++ dll. I need to be able to call it from Java using JNI. This function expects to receive a buffer pointed by wchar_t * of "int len" length. It will copy write some text in to this buffer and i need to be able to get this updated Unicode string in Java code. please let me know how to write Java code to call this function.
    int getWString(wchar *ch, int len)
         wcsncpy( ch, L"Hello unicode world", len);
         return 1; // no error
    }Best Regards
    Noman Khan

    You can't.
    You have to write some C "wrapper" code that meets the java interface, and have it call the C function and handle the return.
    Java doesn't do output parameters, especially wchar_t* s.

Maybe you are looking for