Add Parameter to hardcoded string in decode function

I have a query something like this :
Select ............
,decode((select bill_sequence_id
from bom_structures_b a
where a.assembly_item_id =POL.ITEM_ID
and a.organization_id=FSP.INVENTORY_ORGANIZATION_ID
and a.alternate_bom_designator is null
and msi.bom_enabled_flag='Y'
),null,null,'test_url'||a.bill_sequence_id) "Destination"
From........
where..........
i want to add the column value that I searched at the end of 'test_url'
If I did decode(...,null,null,'test_url'||222222222) it worked, but when i give bill_sequence_id or a.bill_sequence_id , it cries for invalid identifier.
please assist.
Thanks

Its good to flush out your tear glands sometimes.Sure is. I've tried to dechiffer your "query" and to me it looks like something like this:
select <some_columns_we_dont_know_of>
     , nvl2(a.bill_sequence_id, 'test_url'|| to_char(a.bill_sequence_id), null) "Destination"
  from (select assembly_item_id
             , organization_id
          from bom_structures_b
         where alternate_bom_designator is null) a
     , (select pol.item_id
             , fsp.inventory_organization_id
          from pol
             , fsp
             , msi
             , <other_tables_we_dont_know_of>
         where <your_join_conditions>
           and msi.bom_enabled_flag='Y'
           and <other_predicates>) b
where a.assembly_item_id(+) = b.item_id
   and a.organization_id(+) = b.inventory_organization_id;Or perhaps
select <some_columns_we_dont_know_of>
      , case
          when a.bill_sequence_id is not null and b.bom_enabled_flag = 'Y'
          then 'test_url'|| to_char(a.bill_sequence_id)
        end "Destination"
   from (select assembly_item_id
              , organization_id
           from bom_structures_b
          where alternate_bom_designator is null) a
      , (select pol.item_id
              , fsp.inventory_organization_id
              , msi.bom_enabled_flag
           from pol
              , fsp
              , msi
              , <other_tables_we_dont_know_of>
          where <your_join_conditions>
            and msi.bom_enabled_flag='Y'
            and <predicates>) b
  where a.assembly_item_id(+) = b.item_id
   and a.organization_id(+) = b.inventory_organization_id;Regards
Peter

Similar Messages

  • Problem with decode function.

    Hi,
    Can anyone of you help me out in solving this?
    It is like i wish to give different select statements according to the value of a parameter entered by user USING DECODE FUNCTION.The select statement contains some other select statements inside it.So when i execute it,it is giving error like 'ORA-00913-too many values(even when i enclose select statements within brackets).

    ORA-00913 too many values
    Cause: The SQL statement requires two sets of values equal in number. This error occurs when the second set contains more items than the first set. For example, the subquery in a WHERE or HAVING clause may return too many columns, or a VALUES or SELECT clause may return more columns than are listed in the INSERT.
    Action: Check the number of items in each set and change the SQL statement to make them equal.
    the above is from oracle documentation. the brackets is not the problem, u must be using multiple items in the integrated decode queries. If the problem still exists post ur DML for further analysis.
    zaibi.

  • Compare 2 string within DECODE

    Hi All,
    Is there anyone else able to guide me on how to compare 2 strings inside DECODE function? Currently I need to check whether string1 = string2.
    I need a DECODE function which has similar function like below,
    eg: IF(string1 = String2? 1, 2) => java code

    DECODE(string1,string2,1,2)If string1=string2 then 1 will be returned else 2 will be returned.

  • Suggestion on decode function

    DECODE(pc.prtyp_refno,4053,0,201979,0,201980,0,205495,0,201982,0,201981,0,1) = 0
    could some body explain me what this exactly it means ,does pc.prtyp_refno is in the numbers provided or it should not be in the numbers given
    Many thanks in advance

    Hi,
    Decode function compares column values to the specified list of possible values.
    I suggest SQL Reference book.
    This is what I found there:
    DECODE compares expr to each search value one by one. If expr is equal to a
    search, then Oracle returns the corresponding result. If no match is found, then
    Oracle returns default. If default is omitted, then Oracle returns null.
    If expr and search contain character data, then Oracle compares them using
    nonpadded comparison semantics. expr, search, and result can be any of the
    datatypes CHAR, VARCHAR2, NCHAR, or NVARCHAR2. The string returned is of
    VARCHAR2 datatype and is in the same character set as the first result parameter.
    Oracle automatically converts expr and each search value to the datatype of the
    first search value before comparing. Oracle automatically converts the return
    value to the same datatype as the first result. If the first result has the datatype
    CHAR or if the first result is null, then Oracle converts the return value to the
    datatype VARCHAR2.
    Of course there is much more information :)
    Peter D.

  • Error -3016 when trying to compare a column value via "decode" function

    The following statement:
      select * from turbine_user
      where login_name  = decode(1, 2,  'name1', 'name2')
    yields a "-3016 Invalid numeric constants" error.
    OTOH, the following variations work as expected:
      (a)
      select * from turbine_user
      where login_name  = 'name1'
      (b)
      select * from turbine_user
      where login_name  = 'name2'
      (c)
      select * from turbine_user
      where 'name1'  = decode(1, 2,  'name1', 'name2')
      (d)
      select decode(1, 2,  'name1', 'name2') from turbine_user
    Does MaxDB have problems with using the decode function to compare something to column values?
    My MaxDB-Version: 7.6.03.07
    Thanks in advance,
    Alex
    Edited by: Alexander Zimmer on Feb 6, 2008 3:53 PM

    Hi,
    unfortunately I assume that I should explain the doing of decode a little bit:
    As we see in the reference manual:
    DECODE(<check_expression>,<search_and_result_spec>,...[,<default_expression>])
    <check_expression> ::=
      <expression>
    <search_and_result_spec> ::=
      <search_expression>,<result_expression>
    <default_expression> ::=
      <expression>
    <search_expression> ::=
      <expression>
    <result_expression> ::=
      <expression>
    Ok, that will mean, that the first parameter of decode will be compared to parameter number 2, 4, 6, 8, 10,... up to number n-1.
    If the result of the comparison is true with parameter number x, the result of decode will be the value of parameter x+1.
    If no comparison results in 'equal', then NULL will be returned if there is an odd number of parameters respectively the value of the last parameter if there is an even number of parameters of the decode function.
    In your context, this means, that 1 is compared to 2 (always false), thus returning 'name2' always. Therefore I do not understand what you want to do with that decode.
    Ok, if we assume that the select sent is only a short form of what you really want to do, then I have to apologize, but there is a bug in the kernel coding. It will be fixed ASAP.
    To be able to work until then, put the function DIGITS around your 1 and around the 2 (or the corresponding real parameter values) and it should do.
    BTW: with column on the left hand side, the error occurs and with a string literal it does not? This is different to my check where both values on the left side cause this error to occur.
    Elke

  • Regarding decode function

    Hi all,
    i want to know abt decode function in oracle-sql
    i..e passing the parameters in decode using decode using ":" bind parameter
    select JOB, decode(:j,'CLERK','MANAGER','ANALYST','EXEC',JOB) FROM EMP;
    i declared the j variable in sql environment
    VARIABLE J VARCHAR2(20);
    i exec the query
    and passed as the clerk as input parameter
    but iam getting the o/p as
    JOB DECODE(:J
    MANAGER MANAGER
    MANAGER MANAGER
    MANAGER MANAGER
    SALESMAN SALESMAN
    SALESMAN SALESMAN
    SALESMAN SALESMAN
    CLERK CLERK
    SALESMAN SALESMAN
    ANALYST ANALYST
    CLERK CLERK
    ANALYST ANALYST
    JOB DECODE(:J
    CLERK CLERK
    12 rows selected.
    SQL> PRINT J;
    J
    im not getting o/p
    so please hlelp me only : should be used not &
    this is my first thread.
    execuse me if any mistakes
    tons of thanks in advance to all

    SORRY DAVE,ROD FOR NOT BEING CLEAR,
    IAM WORKING WITH EMP TABLE THE DATA IN IT IS LIKE THIS
    EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
    7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
    7782 CLARK MANAGER 7839 09-JUN-81 2450 10
    7566 JONES MANAGER 7839 02-APR-81 2975 20
    7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
    7499 chaitu SALESMAN 7698 20-FEB-81 1600 300 10
    7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
    7900 JAMES CLERK 7698 03-DEC-81 950 30
    7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
    7902 FORD ANALYST 7566 03-DEC-81 3000 20
    7369 SMITH CLERK 7902 17-DEC-80 800 20
    7788 SCOTT ANALYST 7566 09-DEC-82 3000 20
    EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
    7876 ADAMS CLERK 7788 12-JAN-83 1100 20
    AND I USED DECODE FUNCTION
    select JOB BEFOREPROMOTION, decode(job,'CLERK','MANAGER','ANALYST','EXEC') PROMOTION FROM EMP
    BEFOREPRO PROMOTI
    MANAGER
    MANAGER
    MANAGER
    SALESMAN
    SALESMAN
    SALESMAN
    CLERK MANAGER
    SALESMAN
    ANALYST EXEC
    CLERK MANAGER
    ANALYST EXEC
    I..E ALL THE CLERKS TO MANAGERS AND SAME THING WITH ANALYST
    OK
    NOW I WILL SHOW U ANOTHER QUERY
    select job,decode(job,'CLERK','MANAGER','ANALYST','EXEC',JOB) FROM EMP where job=&job;
    Enter value for job: 'CLERK'
    old 1: select job,decode(job,'CLERK','MANAGER','ANALYST','EXEC',JOB) FROM EMP where job=&job
    new 1: select job,decode(job,'CLERK','MANAGER','ANALYST','EXEC',JOB) FROM EMP where job='CLERK'
    JOB DECODE(JO
    CLERK MANAGER
    CLERK MANAGER
    CLERK MANAGER
    HERE OBSERVE THAT I PASSED JOB ='CLERKS AS PARAMETER AFTER EXECUTING THE QUERY
    IT ASKED LIKE THIS AND SHOWED THE REPLACED VALUES
    Enter value for job: 'CLERK'
    AS SHOWN ABOVE
    FOR THIS TO PASS VALUE
    IN TO THE QUERY BY USING AMPERSAND('&')
    TO TAKE INPUT AS CLERK
    IT CHECKED AND RETURNED THE VALUE
    IN THE SIMILAR WAY CAN I USE ":" COLON
    TO PASS PARAMETERS
    IN TO THE QUERY
    CAN I USE IT
    REGARDS,
    PHANI
    Edited by: user10652894 on Nov 26, 2008 3:24 AM

  • Error while replacing IF statements with DECODE function in procedure

    Hi All,
    I have created a procedure which has nested IF statements. Now I want to replace the IF statements with DECODE functions to improve performance.
    Procedure:
    IF (var_int_sev = '0')
    THEN
    var_sev := '2';
    ELSE
    SELECT sev
    INTO var_int_sev
    FROM errorconfig
    WHERE errorcode = var_errorcode;
    var_sev := var_int_sev;
    END IF;
    I converted the above IF statement into DECODE function as mentioned below:
    var_Sev := DECODE(var_int_sev,0,2,SELECT severity FROM errorconfig WHERE errorcode=var_ErrorCode)
    But it throws below error at the select statement used inside DECODE.
    Error(58,51): PLS-00103: Encountered the symbol "SELECT" when expecting one of the following: ( - + case mod new not null others <an identifier> <a double-quoted delimited-identifier> <a bind variable> avg count current exists max min prior sql stddev sum variance execute forall merge time timestamp interval date <a string literal with character set specification> <a number> <a single-quoted SQL string> pipe <an alternatively-quoted string literal with character set specification> <an alternativ
    Can someone help me in converting the IF to DECODE in the above case. Also how can we use a select statement inside decode.

    instead of trying to rewrite all your code and hoping that the performance will be better, it's a better option to investigate and find out which part of your application is slow
    read this:
    When your query takes too long ...

  • DECODE function to validate date value and sort the records

    Hi Friends,
    I am looking for some query which can give me the required output,
    I need to do this using SQL query only and I have tried using the MIN() and MAX() functions it was working fine with limited data, now after inserting the last record(in the below table) which has date for start_range and end_range in(mm/dd/yyyy hh24:mi:ss) format.
    Because the data type is VARCHAR2 if I am using the MIN() function it is sorting as a string value, hence the min date is incorrect. I tried using validating the value to date or non date and tried to using MIN() and MAX() functions using the DECODE function, I am getting this error "ORA-01840: input value not long enough for date format".
    select table_name,
    DECODE(substr(START_RANGE,3,1)||substr(START_RANGE,6,1)||substr(START_RANGE,11,1)||substr(START_RANGE,14,1)||substr(START_RANGE,17,1),'// ::',
    to_char(min(to_date(start_range,'mm/dd/yyyy hh24:mi:ss')),'MM/DD/YYYY HH24:MI:SS'),min(start_range)) MIN_RUNS_START_RANGE,
    DECODE(substr(END_RANGE,3,1)||substr(A.END_RANGE,6,1)||substr(END_RANGE,11,1)||substr(END_RANGE,14,1)||substr(END_RANGE,17,1),'// ::',
    to_char(max(to_date(END_RANGE,'mm/dd/yyyy hh24:mi:ss')),'MM/DD/YYYY HH24:MI:SS'),max(END_RANGE)) MAX_RUNS_END_RANGE
    from MY_TABLE
    GROUP BY table_name,
    (substr(START_RANGE,3,1)||substr(START_RANGE,6,1)||substr(START_RANGE,11,1)||substr(START_RANGE,14,1)||substr(START_RANGE,17,1)),
    (substr(END_RANGE,3,1)||substr(END_RANGE,6,1)||substr(END_RANGE,11,1)||substr(END_RANGE,14,1)||substr(END_RANGE,17,1))
    Can sombody please advise what is the best way I can query this data with the required output.
    The following are the source table and records and the out put records using the sql query.
    MY_TABLE
    TABLE_NAME(VARCHAR2),START_RANGE(VARCHAR2),END_RANGE(VARCHAR2)
    TABLE1,1000,10000
    TABLE2,ABCD,EEEE
    TABLE3,01/12/2010 00:00:00,12/31/2010 23:59:59
    TABLE1,10001,20000
    TABLE2,EEEF,GGGG
    TABLE3,01/01/2011 00:00:00,01/31/2011 23:59:59
    OUTPUT :
    TABLE_NAME,MIN(START_RANGE),MAX(END_RANGE)
    TABLE1,1000,20000
    TABLE2,ABCD,GGGG
    TABLE3,01/12/2010 00:00:00,01/31/2011 23:59:59
    Thanks
    Kalycs

    i also think this is a very bad table design ...
    but if you are not able to change it, you could split the select (date and non-date data) and combine the result with UNION like this:
    with t as
    SELECT 'TABLE1' table_name,'1000' start_range,'10000' end_range FROM dual UNION
    SELECT 'TABLE2','ABCD','EEEE' FROM dual UNION
    SELECT 'TABLE3','01/12/2010 00:00:00','12/31/2010 23:59:59' FROM dual UNION
    SELECT 'TABLE1','10001','20000' FROM dual UNION
    SELECT 'TABLE2','EEEF','GGGG' FROM dual UNION
    SELECT 'TABLE3','01/01/2011 00:00:00','01/31/2011 23:59:59' FROM dual
    SELECT table_name,
           TO_CHAR(MIN(TO_DATE(start_range, 'MM/DD/YYYY HH24:MI:SS')), 'MM/DD/YYYY HH24:MI:SS'),
           TO_CHAR(MAX(TO_DATE(end_range, 'MM/DD/YYYY HH24:MI:SS')), 'MM/DD/YYYY HH24:MI:SS')
    FROM t
    WHERE start_range LIKE '%/%/%:%:%'
    GROUP BY table_name
    UNION
    SELECT table_name,
           MIN(start_range),
           MAX(end_range)
    FROM t
    WHERE start_range NOT LIKE '%/%/%:%:%'
    GROUP BY
        table_name;
    TABLE_ MIN_VALUE           MAX_VALUE
    TABLE1 1000                20000
    TABLE2 ABCD                GGGG
    TABLE3 01/12/2010 00:00:00 01/31/2011 23:59:59

  • Decode function in Update statement

    Hello everyone,
    I'm trying to write a query where I can update a pastdue_fees column in a book_trans table based on a difference between return_dte and due_dte columns.
    I am using Oracle SQL. This is what I have so far for my decode function:
    SQL> SELECT
    2 DECODE(SIGN((return_dte - due_dte)*2),
    3 '-1', '0',
    4 '1', '12', 'Null')
    5 FROM book_trans;
    DECO
    Null
    12
    Null
    0
    So the logic is that if the sign is -1, the value in return_dte column should be 0; if it's +1 then it's 12 and everything else is Null.
    So now, I need to enter my decode function into the update statement to update the columns. However, I get error messages.
    The logic should be:
    UPDATE book_trans SET PastDue_fees = decode(expression)
    I've given it a couple of different tries with the following results:
    SQL> UPDATE book_trans
    2 SET pastdue_fees = SELECT
    3 DECODE(SIGN((return_dte - due_dte)*2),
    4 '-1', '0',
    5 '1', '12', 'Null')
    6 FROM book_trans;
    SET pastdue_fees = SELECT
    ERROR at line 2:
    ORA-00936: missing expression
    SQL> UPDATE book_trans
    2 SET pastdue_fees =
    3 DECODE(SIGN((return_dte - due_dte)*2),
    4 '-1', '0',
    5 '1', '12', 'Null')
    6 FROM book_trans;
    FROM book_trans
    ERROR at line 6:
    ORA-00933: SQL command not properly ended
    Any help or tips would be greatly appreciated as I've been taking SQL for about six weeks and not very proficient!
    Thanks!

    882300 wrote:
    Hello everyone,
    I'm trying to write a query where I can update a pastdue_fees column in a book_trans table based on a difference between return_dte and due_dte columns.
    I am using Oracle SQL. This is what I have so far for my decode function:
    SQL> SELECT
    2 DECODE(SIGN((return_dte - due_dte)*2),
    3 '-1', '0',
    4 '1', '12', 'Null')
    5 FROM book_trans;
    DECO
    Null
    12
    Null
    0
    So the logic is that if the sign is -1, the value in return_dte column should be 0; if it's +1 then it's 12 and everything else is Null.
    So now, I need to enter my decode function into the update statement to update the columns. However, I get error messages.
    The logic should be:
    UPDATE book_trans SET PastDue_fees = decode(expression)
    I've given it a couple of different tries with the following results:
    SQL> UPDATE book_trans
    2 SET pastdue_fees = SELECT
    3 DECODE(SIGN((return_dte - due_dte)*2),
    4 '-1', '0',
    5 '1', '12', 'Null')
    6 FROM book_trans;
    SET pastdue_fees = SELECT
    ERROR at line 2:
    ORA-00936: missing expression
    SQL> UPDATE book_trans
    2 SET pastdue_fees =
    3 DECODE(SIGN((return_dte - due_dte)*2),
    4 '-1', '0',
    5 '1', '12', 'Null')
    6 FROM book_trans;
    FROM book_trans
    ERROR at line 6:
    ORA-00933: SQL command not properly ended
    Any help or tips would be greatly appreciated as I've been taking SQL for about six weeks and not very proficient!
    Thanks!If you really really really want to update the entire table, the syntax would be...
    UPDATE book_trans
       SET
          pastdue_fees  = DECODE(SIGN((return_dte - due_dte)*2), -1, 0, 1, 12, Null);I took out all the single quotes. If you actually have a string column and you're storing entirely numbers in it then it should be declared as a NUMBER column and not a character (varchar2) column.
    ALWAYS use the proper data type, it'll save you a ton of headaches in the future.
    Also, since you're new to the forum, please read the FAQ so you learn the etiquette and what not.
    http://wikis.sun.com/display/Forums/Forums+FAQ

  • How to pass multiple query string values using the same parameter in Query String (URL) Filter Web Part

    Hi,
    I want to pass multiple query string values using the same parameter in Query String (URL) Filter Web Part like mentioned below:
    http://server/pages/Default.aspx?Title=Arup&Title=Ratan
    But it always return those items whose "Title" value is "Arup". It is not returned any items whose "Title" is "Ratan".
    I have followed the
    http://office.microsoft.com/en-us/sharepointserver/HA102509991033.aspx#1
    Please suggest me.
    Thanks | Arup
    THanks! Arup R(MCTS)
    SucCeSS DoEs NOT MatTer.

    Hi DH, sorry for not being clear.
    It works when I create the connection from that web part that you want to be connected with the Query String Filter Web part. So let's say you created a web part page. Then you could connect a parameterized Excel Workbook to an Excel Web Access Web Part
    (or a Performance Point Dashboard etc.) and you insert it into your page and add
    a Query String Filter Web Part . Then you can connect them by editing the Query String Filter Web Part but also by editing the Excel Web Access Web Part. And only when I created from the latter it worked
    with multiple values for one parameter. If you have any more questions let me know. See you, Ingo

  • How to use a decode function

    I want to use the following with decode, recently started on BODS.
    Can you please provide the steps to use decode function
    in source tabke fieldname is ordid and in target fieldname is Orderid
    decode(Order_ID = 1709,lpad(Order_ID,7,'700'),Order_ID)
    thank you very much for the helpful i

    1) In the mapping tab of target column, click on Functions, select Miscellaneous Functions category, you can find decode function in it. Lpad can be found in String functions category.
    OR
    2) You can directly script this or paste this code at the mapping tab. In this case, remove the Order_ID from the script wherever used, drag and drop this column from the input schema of Query transform to avoid the syntax error. 
    Regards,
    Suneer

  • Decode Function I asked this in the wrong section so I hope Im right now!

    select
    a11.SEQ_MEMB_ID,
    a11.Auth_Number,
    a11.Admit_Primary_Date,
    a11.Reviewer,
    Decode (a11.Reviewer,
    CLC, '2',
    HBR, '3',
    RAB, '4')
    a11.admit_primary_date
    from windsoradm.auth_master a11;
    I am trying to get if the Reviewer is CLC then they are code 2 HBR Code 3 etc and it does not work. I take out the decode function and the query works. I am getting ORA-00923 FROM KEYWORD NOT FOUND WHERE EXPECTED.

    Hi,
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    Simplify the problem as much as possible. Remove all tables and columns that play no role in this problem.
    Always say which version of Oracle you're using.
    This is the right forum for this question. Mark your question in the other forum {message:id=10266930} as "Answered", so people won't waste their time.
    925518 wrote:
    select
    a11.SEQ_MEMB_ID,
    a11.Auth_Number,
    a11.Admit_Primary_Date,
    a11.Reviewer,
    Decode (a11.Reviewer,
    CLC, '2',
    HBR, '3',
    RAB, '4')
    a11.admit_primary_date
    from windsoradm.auth_master a11;
    I am trying to get if the Reviewer is CLC then they are code 2 HBR Code 3 etc and it does not work. I take out the decode function and the query works. I am getting ORA-00923 FROM KEYWORD NOT FOUND WHERE EXPECTED.That's the correct DECODE syntax, where CLC, HBR and RAB are columns, and you want to return a string (not a number) such as '2'.
    If 'CLC', 'HBR' and 'RAB' are literal values, then enclose them in single-quotes. If you want to return a number, don't put it in quotes. (Anyhting inside single-quotes is a string literal.)
    Perhaps you meant something like:
    ,     DECODE ( a11.Reviewer
                , 'CLC'          , 1
                , 'HBR'          , 2
                , 'RAB'          , 3
                )      AS reviewer_codeThere's an error right after the DECODE. You can't use a11.admit_primary_date as a column alias. (This is probably what's causing the ORA-00923 error.) Either a11_admit_primary_date (with an underscore instead of a dot) or admit_primary_date would be okay. If a11.admit_priomary_date is the next column in the SELECT clause, put a comma befor it.
    You need a FROM clause.

  • Using mysql decode function in Java

    Hi everybody,
    mysql documentation says:
    DECODE(crypt_str,pass_str) -->
    Decrypts the encrypted string crypt_str using pass_str as the password. crypt_str should be a string returned from ENCODE().
    I used the above function in a Python script and had no problem, but have difficulty using the same thing in my Java code.
    I receive runtime error when tried decode() in my Java code in executeQuery("s");. As far as I know the decode() function should be compiled, I can't run the decode() in the mysql command tool and receive a response (as I compiled and ran it in my Python script).
    Has anybody ever used this function in the Java code? How? What format did you use? What I should use instead of "s" in this code?
    conn is a database connection:
    stmt = conn.createStatement();
    rs = stmt.executeQuery("s");
    I even tried PreparedStatement, but no luck.
    Any help is greatly appreciated.

    stmt.executeQuery("select blahblahblah, DECODE(fieldName, password), blahblahblah FROM blahblah...")

  • Order by clause using decode function

    Hi everybody,
    i need below order in my report.
    Connecticut
    greenwich
    stamford
    bridgeport
    New York
    NYC
    wrestcher
    byram
    Georgia
    atlanta
    athens
    oconny
    first i need above order in my view out put.
    so in order by clause i used first decode function for State ordering
    and in second decode function for city ordering.
    i do not need order by ascending or descending.
    so pls anybody can help me.
    any help is greatly appreciated.
    thanks.

    add asc after the decode. default is desc

  • Problem passing a table parameter in rfc call using the function control

    I try to pass a Table as parameter to a Function Module using the SAP.Functions library (part of SAP frontend controls) from a Visual Basic (VBA) program.
    The function module has been verified to work when invoked from SAP FrontEnd Function Builder.
    The SAP RFC Control is created with
    Set sapFunctions=CreateObject("SAP.Functions")
    Following code snippet shows how I attempt to set exports and add a table row before calling the function module:
    sapFunctions.Connection = sapConnection
    Set sapMaterialUpd = sapFunctions.Add("Z_SD_BAPI_SALES_DATA_UPD")
    With sapMaterialUpd
    <i>'set exports</i>
         .Exports("PA_GLPUPDLEVEL") = "S"
         .Exports("PA_VKORG") = "FI14"
    <i>'append table row</i>
         .Tables("IT_SALES_DATA_UPD").AppendRow
         .Tables("IT_SALES_DATA_UPD")(1, "VKORG") = "FI14"
         .Tables("IT_SALES_DATA_UPD")(1, "MATNR") = "W_3100"
         .Tables("IT_SALES_DATA_UPD")(1, "DATBI") = "99991231"
         .Tables("IT_SALES_DATA_UPD")(1, "DATAB") = "20041231"
         .Tables("IT_SALES_DATA_UPD")(1, "KBETR") = "2222"
         .Tables("IT_SALES_DATA_UPD")(1, "KONWA") = "EUR"
    End With
    <i>'call the function module</i>
    If sapMaterialUpd.Call() = True Then
        <i>'do something with the return tables here...</i>Else
        Debug.Print sapMaterialUpd.Exception
    End If
    The Call() returns <b>FALSE</b> and the exception is <b>"SYSTEM_FAILURE"</b>. The connection also resets.
    The local logfile that the control generates shows that an exception occurs at the point of the call:
    <i>10.02.2005  17:54:20.766 Packing Parameters for Z_SD_BAPI_SALES_DATA_UPD
    Packing Parameter PA_GLPUPDLEVEL.
    Packing Parameter PA_VKORG.
    Packing Table 0.
    Packing Table 1.
      10.02.2005  17:54:20.766 *** Calling  RFC Function 'Z_SD_BAPI_SALES_DATA_UPD'
      10.02.2005  17:54:20.986 RFC CALL status = RFC_SYS_EXCEPTION
      10.02.2005  17:54:20.986 RFC Error: RFC_IO27
      -Status:CODE=CM_DEALLOCATED_NORMAL STATUS=CM_NO_STATUS_RECEIVED DATA=CM_COMPLETE_DATA_RECEIVED ID=69415076
      -Message:connection closed
      -Internal Status:IO HANDLE=23 DRV=EXT LINE=1420 CODE=27 : GET ID=ffff LINE=861 CODE=7
      10.02.2005  17:54:20.986 Function call finished.</i>
    Seen next code snippet. If the Table object is not touched, the function call goes through without any problems:
    sapFunctions.Connection = sapConnection
    Set sapMaterialUpd = sapFunctions.Add("Z_SD_BAPI_SALES_DATA_UPD")
    With sapMaterialUpd
    'set exports
        .Exports("PA_GLPUPDLEVEL") = "S"
        .Exports("PA_VKORG") = "FI14"
        'do <b>not</b> append a table row, for testing only ;-)</b>
    End With
    <i>'call the function module</i>
    If sapMaterialUpd.Call() = True Then
    <i>    'do something with the return tables here...</i>
    Else
        Debug.Print sapMaterialUpd.Exception
    End If
    This code works perfectly when calling the function. It returns TRUE and behaves normally. The function module returns descriptive response text in a table telling that the table was empty, according to the BAPI implementation.
    So is there something special needed here <i>after</i> appending the table row and <i>before</i> making the Call to properly attach the table as a parameter for the function module?
    Can this be a bug in the SAP RFC Control? The version of the wdtfuncs.ocx is 6206.6.45.54.
    Any hints are welcome!

    hi All partner,
    who solved this problem , I meet it too and
    can't clear it.
    SAPfunc := sapfunctions1.Add('z_get_sfcs_dn_mo');    
    SAPitab := sapfunc.tables.item ('I_DNMO');
    SAPitab.appendrow;                                       SAPitab.value(1,'MANDT') := '220'; 
    SAPitab.Value(1,'VBELN') := '2150000001';
    SAPitab.Value(1,'POSNR') := '50';
    SAPitab.value(1,'MATNR') := '19-99999-00'; 
    SAPitab.value(1,'AUFNR') := '921241512001';
    SAPitab.value(1,'DEDAT') := '2005/09/09';
    SAPitab.value(1,'LFIMG') := '100';  
    IF  SAPfunc.call = true then
      begin
      end
    else
        begin
        showmessage('call fail!!') ;
        end;
    end;
    RFC source code as below
    FUNCTION z_get_sfcs_dn_mo.
    ""Local interface:
    *"  TABLES
    *"      I_DNMO STRUCTURE  ZDN_MO
      data: wa type zdn_mo.
      LOOP AT i_dnmo.
        wa-mandt = i_dnmo-mandt.
        wa-vbeln = i_dnmo-vbeln.
        wa-posnr = i_dnmo-posnr.
        wa-matnr = i_dnmo-matnr.
        wa-aufnr = i_dnmo-aufnr.
        wa-dedat = i_dnmo-dedat.
        wa-lfimg = i_dnmo-lfimg.
       modify  zdn_mo from wa.
        insert into zdn_mo values wa.  --dump at here
        commit work.
      ENDLOOP.
    T/C: ST22 error message say at
      insert into zdn_mo values wa. ---dump at here
    the sapfunc.call returns fail.
    Message was edited by: jorry wang

Maybe you are looking for