Problem using function call in WHERE part of a Report's SQL query

I tried doing some searches on this, but couldn't find anything. I'm trying to run something similar to the following query in my report, but keep getting a "Query cannot be parsed within the Builder" error:
SELECT function1(TABLE2.ID) A
FROM TABLE1, TABLE2
WHERE TABLE1.ID = TABLE2.ID AND
           TABLE1.NAME = 'BLAH' AND
           TABLE2.DATE > SYSTIMESTAMP AND
           (function2(TABLE2.ID) = 'YES' OR
            function3(:USER_ID) = 'YES')
ORDER BY TABLE1.NAMEWhy won't this work? I can take out the 2 lines with function calls from the WHERE clause, and it works, so I'm assuming that APEX doesn't like something about my function calls. I know the functions are valid and work properly, because I tested them independently. Can anyone see what the problem is? Thanks!

Here's the actual query:
SELECT BUILD_EXT_RES_LIST(EXT_FILE.ID) A
FROM EXT_FILE_RES, EXT_FILE
WHERE EXT_FILE_RES.ON_OWNER_PROFILE = 'Y' AND
      EXT_FILE.OWNER_ID = :PROFILE AND
      EXT_FILE.ID = EXT_FILE_RES.EXT_ID AND
     (RES_SUBSCRIBER_YN(EXT_FILE.ID,:CURR_ID) = 'YES' OR
      ADMINYESNO(:CURR_ID,:PROFILE) = 'YES')
ORDER BY EXT_FILE.FILE_NAMEAnd here's the actual error message:
1 error has occurred
Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the ''generic columns'' checkbox below the region source to proceed without parsing. ORA-00904: "SER_IS_ADMINYESNO": invalid identifier

Similar Messages

  • Can Portal Report from SQL Query use where column IN (:bind_variable)

    I would like to create a portal report from sql query with IN (:bind_variable) in the where clause. The idea is that the user would enter comma-separated or comma-quote-separated values for the bind_variable. I have tried this several ways but nothing seems to work. Can this be done?
    Trenton

    Hi,
    Which version of portal are you using. This is a bug. It has been fixed in 30984.
    Thanks,
    Sharmila

  • Problem for create report by sql query under Protal!

    I'm trying create report by sql query method, however it came out the error:
    ORA-00918: column ambiguously defined (WWV-11230)
    Failed to parse as SENTRYDB - select distinct t1.firstnames, t1.lastname, t4.PERSONGROUP, to_char( t1.dateofbirth, 'DD-MM-YYYY' ) as "Dateofbirth", t3.ADDRESS, t3.CITY, t3.STATE, t3.CODE, t3.HOMETELEPHONE, t3.WORKTELEPHONE, t3.INTERESTING, t3.personid from pnames t1, people t3, groups t4 where t3.persongroup = t4.groupid and t1.personid = t3.personid order by rowid (WWV-08300)
    Error: Unable to execute query (WWV-10201)
    The query is :
    select distinct t1.firstnames, t1.lastname, t4.PERSONGROUP, to_char( t1.dateofbirth, 'DD-MM-YYYY' )
    as "Dateofbirth", t3.ADDRESS, t3.CITY, t3.STATE, t3.CODE, t3.HOMETELEPHONE, t3.WORKTELEPHONE, t3.INTERESTING, t3.personid
    from pnames t1, people t3, groups t4
    where t3.persongroup = t4.groupid
    and t1.personid = t3.personid
    I have no problem to run that query under sqlplus!

    Hi,
    I'm cuurently using the portal inside of 9iAs 1.0.2.2.2a. What version of that Portal? By the way, how can I find out the version of Portal that I using? And also can I display image inside of report which created by Portal? I tried statement:
    select
    '<IMG SRC="'|| decode(IMAGE, '', SJAYARAM309.wwctx_api.get_image_path || 'noimg.jpg',
    owa_util.get_cgi_env('DOC_ACCESS_PATH') || '/' || IMAGE) ||'">' stu_pic,
    from stu
    However, it doesn't work. It came out error:
    Unable to describe SQL statement. Please correct it (WWV-13010)
    Invalid SQL statement: select '<IMG SRC="'|| decode(IMAGE, '', SJAYARAM309.wwctx_api.get_image_path || 'noimg.jpg', owa_util.get_cgi_env('DOC_ACCESS_PATH') || '/' || IMAGE) ||'">' pic from test (WWV-13005)
    ORA-01001: invalid cursor (WWV-11230)
    ORA-00904: invalid column name (WWV-11230)
    Failed to parse as SENTRYDB - select '<IMG SRC="'|| decode(IMAGE, '', SJAYARAM309.wwctx_api.get_image_path || 'noimg.jpg', owa_util.get_cgi_env('DOC_ACCESS_PATH') || '/' || IMAGE) ||'">' pic from test (WWV-08300)
    Do you know why?

  • Function calls in WHERE clause

    Hello,
    I have several procedures that all share a similar snippet of code in the WHERE clause. I tried to make this a function but, using a function increases the execution time of the calling procedure by a factor of ten. I am currently on 8i and will be moving to 9i soon. Was just wondering if there will be any performance increase from this type of function call on 9i vs. 8i.
    Thanks
    :)

    sometimes a perforance hit it worth the maintability factor.I disagree, strongly. The developer's Prime Directive is to make the user's experience a good one. Inflicting poorly performing code on the user in the name of maintinability is not on.
    Q: Why does the code have to be maintained so much?
    A: Because the users' keep complaining about how slow it runs....
    [SOAPBOX]
    Of course in the real world things get confused and it can be quite difficult to distinguish programmers' issues - encapsulation, flexibility, maintainability - from users' issues - correctness, completeness, performance.
    But the relative worth of these things is easy to assess. A highly-modular parameter driven architecture that delivers the wrong answer and takes an age to do it ain't worth jack. Even if it is so maintainable that it's easy to fix every bug in it.
    [SOAPBOX]
    "Whatever waits for us behind those doors, we have a better chance of survival if we stick together." Gladiator
    Cheers, APC

  • Filter using Function resulting incorrect where cause

    Hi,
    I have a requirement wherein i have to filter a column based on a combination of mutiple hierarchy dimensions for which i am using Filter Using Function
    ex.
    Filter Metric A Using Dimesion A - Range 50 -100
    Filter Metric A Using Dimension A - Range 25 - 50, Dimension B Range 0 -100
    When i have a report with these metrics alone then it works fine but when both metrics are exposed on a single report
    The where clause results in something like this
    (Dimension A > 50 OR Dimnesion B > 0) AND (Dimension A > 25 OR Dimension A < 100 OR Dimesnion B < 100) AND Dimesnion A < 50
    To sum it up its random and incorrect, any ideas as to why this could happen ??
    Any pointers etc would be highly appreciated.

    Hi,
    I have a requirement wherein i have to filter a column based on a combination of mutiple hierarchy dimensions for which i am using Filter Using Function
    ex.
    Filter Metric A Using Dimesion A - Range 50 -100
    Filter Metric A Using Dimension A - Range 25 - 50, Dimension B Range 0 -100
    When i have a report with these metrics alone then it works fine but when both metrics are exposed on a single report
    The where clause results in something like this
    (Dimension A > 50 OR Dimnesion B > 0) AND (Dimension A > 25 OR Dimension A < 100 OR Dimesnion B < 100) AND Dimesnion A < 50
    To sum it up its random and incorrect, any ideas as to why this could happen ??
    Any pointers etc would be highly appreciated.

  • Select type_address in Portal report's sql query using remote database

    how do i select type_address item from remote database table ?
    I've already create the database link called db_link.
    I've already execute the sql statement in the specified database, and it works.
    for example: ( sql plus in the specified database )
    select syk.alamat_syarikat.alamat1 from MCS_SYARIKAT syk
    for example: ( sql statement in portal report using database link )
    select nama_syarikat, syk.alamat_syarikat.alamat1 from MCS_SYARIKAT@dblink syk
    error massage:
    Unable to describe SQL statement. Please correct it (WWV-13010)
    Invalid SQL statement: select syk.alamat_syarikat.alamat1 from MCS_SYARIKAT@dblink syk (WWV-13005)
    ORA-01001: invalid cursor (WWV-11230)
    ORA-22804: remote operations not permitted on object tables or user-defined type columns (WWV-11230)
    Failed to parse as MCS_PUBLIC - select syk.alamat_syarikat.alamat1 from MCS_SYARIKAT@dblink syk (WWV-08300)

    Here's the actual query:
    SELECT BUILD_EXT_RES_LIST(EXT_FILE.ID) A
    FROM EXT_FILE_RES, EXT_FILE
    WHERE EXT_FILE_RES.ON_OWNER_PROFILE = 'Y' AND
          EXT_FILE.OWNER_ID = :PROFILE AND
          EXT_FILE.ID = EXT_FILE_RES.EXT_ID AND
         (RES_SUBSCRIBER_YN(EXT_FILE.ID,:CURR_ID) = 'YES' OR
          ADMINYESNO(:CURR_ID,:PROFILE) = 'YES')
    ORDER BY EXT_FILE.FILE_NAMEAnd here's the actual error message:
    1 error has occurred
    Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the ''generic columns'' checkbox below the region source to proceed without parsing. ORA-00904: "SER_IS_ADMINYESNO": invalid identifier

  • Problem with function call from sql when using distinct

    I have the following problem.
    SELECT DISTINCT colA from tabA where my_function(colB) = 'TRUE'
    This statement will return a handfull of results from a table with 70k + records. The function takes about 0.5 secs to execute.
    How do i force the optimizer to do the select distinct first then execute the function on the results rather than execute the function for every single line first?
    Thanks in advance
    Keith

    Let's compare some of those methods:
    michaels>  CREATE OR REPLACE FUNCTION my_function (tr VARCHAR2)
       RETURN VARCHAR2
    AS
    BEGIN
       DBMS_APPLICATION_INFO.set_client_info (SYS_CONTEXT ('userenv','client_info') + 1);
       IF LOWER (tr) LIKE '%name%'
       THEN
          RETURN 'TRUE';
       ELSE
          RETURN 'FALSE';
       END IF;
    END my_function;
    Function created.
    michaels>  CREATE TABLE taba AS SELECT object_id cola ,object_name colb FROM all_arguments
    Table created.
    michaels>  SELECT COUNT(*) FROM taba
      COUNT(*)
         78786
    michaels>  EXEC dbms_application_info.set_client_info(0)
    michaels>  SELECT DISTINCT colA from tabA where my_function(colB) = 'TRUE'
    167 rows selected.
    michaels>  SELECT SYS_CONTEXT ('userenv','client_info') ci FROM dual
    CI   
    78786
    michaels>  EXEC dbms_application_info.set_client_info(0)
    michaels>  SELECT DISTINCT cola FROM (SELECT ROWNUM r, t.* FROM (SELECT DISTINCT cola, colb FROM taba) t)
              WHERE my_function (colb) = 'TRUE'
    167 rows selected.
    michaels>  SELECT SYS_CONTEXT ('userenv','client_info') ci FROM dual
    CI   
    14225
    michaels>  EXEC dbms_application_info.set_client_info(0)
    michaels>  SELECT DISTINCT cola FROM taba WHERE (SELECT my_function (colb) FROM DUAL) = 'TRUE'
    167 rows selected.
    michaels>  SELECT SYS_CONTEXT ('userenv','client_info') ci FROM dual
    CI   
    14281
    michaels>  EXEC dbms_application_info.set_client_info(0)
    michaels>  SELECT DISTINCT cola FROM taba WHERE EXISTS (SELECT ROWNUM FROM dual WHERE my_function (colb) = 'TRUE')
    167 rows selected.
    michaels>  SELECT SYS_CONTEXT ('userenv','client_info') ci FROM dual
    CI   
    13913
    michaels>  EXEC dbms_application_info.set_client_info(0)
    michaels>  WITH temp AS
      (SELECT DISTINCT colA, colB FROM tabA)
    SELECT DISTINCT colA FROM temp WHERE  my_function(colB) = 'TRUE'
    167 rows selected.
    michaels>  SELECT SYS_CONTEXT ('userenv','client_info') ci FROM dual
    CI   
    78786
    michaels>  EXEC dbms_application_info.set_client_info(0)
    michaels>  WITH temp AS
      (SELECT colB, my_function(colB) func FROM (SELECT DISTINCT colB FROM   tabA))
    SELECT DISTINCT colA FROM tabA a, temp t WHERE  a.colB = t.colB AND t.func = 'TRUE'
    michaels>  SELECT SYS_CONTEXT ('userenv','client_info') ci FROM dual
    CI   
    78786 The combination with exists, rownum and dual gives the least calls to the function.

  • Problem using function SO_DOCUMENT_SEND_API1,

    Dear All,
    I used this function for attach the txt file and send the e-mail to relate user.
    Now, My output file print out all the data in the same line.
    how i can split the data line by line ?
    below is my coding.
    Please kindly to help me.
    Regards,
    Luke
    PERFORM send_file_as_email_attachment
                                   TABLES it_mess_bod
                                          it_mess_att
                                    USING  P_TITLE
                                          'FIX'
                                          gd_attachment_name
                                          gd_attachment_desc
                                          p_FROM
                                          'INT'
                                 CHANGING gd_error
                                          gd_reciever.
    *&      Form  send_file_as_email_attachment
          text
         -->IT_MESSAGE            text
         -->IT_ATTACH             text
         -->P_MTITLE              text
         -->P_FORMAT              text
         -->P_FILENAME            text
         -->P_ATTDESCRIPTION      text
         -->P_SENDER_ADDRESS      text
         -->P_SENDER_ADDRES_TYPE  text
         -->P_ERROR               text
         -->P_RECIEVER            text
    FORM send_file_as_email_attachment TABLES it_message
                                              it_attach
                                       USING p_email
                                        USING p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription
                                              p_sender_address
                                              p_sender_addres_type
                                     CHANGING p_error
                                              p_reciever.
      DATA: ld_error    TYPE sy-subrc,
             ld_reciever TYPE sy-subrc,
             ld_mtitle LIKE sodocchgi1-obj_descr,
             ld_email LIKE  somlreci1-receiver,
             ld_format TYPE  so_obj_tp ,
             ld_attdescription TYPE  so_obj_nam ,
             ld_attfilename TYPE  so_obj_des ,
             ld_sender_address LIKE  soextreci1-receiver,
             ld_sender_address_type LIKE  soextreci1-adr_typ,
             ld_receiver LIKE  sy-subrc.
      DATA:   t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
              t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
              t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
              t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
              t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
              w_cnt TYPE i,
              w_sent_all(1) TYPE c,
              w_doc_data LIKE sodocchgi1.
    ld_email   = p_email.
      ld_mtitle  = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    Fill the document data.
      w_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = it_attach[].
    Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 0.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      APPEND t_packing_list.
    Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      LOOP AT itab_mailto.
        t_receivers-receiver = itab_mailto-smtp_addr.
        t_receivers-rec_type = 'U'.
        t_receivers-com_type = 'INT'.
        t_receivers-notif_del = 'X'.
        t_receivers-notif_ndel = 'X'.
        t_receivers-copy       = ''.
        APPEND t_receivers.
      ENDLOOP.
      LOOP AT S_CC.
        t_receivers-receiver = S_CC-low.
        t_receivers-rec_type = 'U'.
        t_receivers-com_type = 'INT'.
        t_receivers-notif_del = 'X'.
        t_receivers-notif_ndel = 'X'.
        t_receivers-copy       = 'X'.
        APPEND t_receivers.
      ENDLOOP.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
        EXPORTING
          document_data              = w_doc_data
          put_in_outbox              = 'X'
          sender_address             = ld_sender_address
          sender_address_type        = ld_sender_address_type
          commit_work                = 'X'
        IMPORTING
          sent_to_all                = w_sent_all
        TABLES
          packing_list               = t_packing_list
          contents_bin               = t_attachment
          contents_txt               = it_message
          receivers                  = t_receivers
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          document_type_not_exist    = 3
          operation_no_authorization = 4
          parameter_error            = 5
          x_error                    = 6
          enqueue_error              = 7
          OTHERS                     = 8.
    Populate zerror return code
      ld_error = sy-subrc.
    Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.                    "send_file_as_email_attachment

    Hi,
    Try This ....
    DATA: l_tab_lines TYPE i,
            l_error TYPE string.
      CONSTANTS : l_c_name(13)  TYPE c VALUE 'HC Error File',   "#EC NOTEXT
                  l_c_255(255)  TYPE c VALUE '255',
                  l_c_txt(3)    TYPE c VALUE 'TXT'.
      DATA: lt_reclist  TYPE STANDARD TABLE OF somlreci1,        "Recipients
            lt_objpack  TYPE STANDARD TABLE OF sopcklsti1,
            lt_objhead  TYPE STANDARD TABLE OF solisti1,
            lt_objtxt   TYPE STANDARD TABLE OF solisti1,      "Body of EMail
            lt_objbin   TYPE STANDARD TABLE OF solisti1."Attachment of EMail
      DATA: l_wa_doc_chng TYPE sodocchgi1,   "attributes of document to send
            l_wa_reclist  LIKE LINE OF lt_reclist,
            l_wa_objpack  LIKE LINE OF lt_objpack,
            l_wa_obj      LIKE LINE OF lt_objhead.
    Begin of Insert CHRK941885
      DATA :
        l_hex LIKE solix,
        lt_contents_hex LIKE STANDARD TABLE OF solix ,
        conv TYPE REF TO cl_abap_conv_out_ce,
        l_buffer TYPE xstring,
        l_hexa(510) type x.
    End of Insert CHRK941885
    Fill attachment contents: body of email message
      CONCATENATE 'Click on attachment to view the extract file :'(t01)
                   l_c_name INTO l_wa_obj-line SEPARATED BY space.
      APPEND l_wa_obj TO lt_objtxt.   CLEAR l_wa_obj.
      APPEND l_wa_obj TO lt_objtxt.   CLEAR l_wa_obj.
      DESCRIBE TABLE lt_objtxt LINES l_tab_lines.
    Information about the email body data
      CLEAR l_wa_objpack-transf_bin.                  "Attachment not binary
      l_wa_objpack-head_start = 1.
      l_wa_objpack-head_num   = 0.
      l_wa_objpack-body_start = 1.
      l_wa_objpack-body_num   = l_tab_lines * l_c_255.
      l_wa_objpack-doc_type   = 'TXT'.
      APPEND l_wa_objpack TO lt_objpack.
      CLEAR :l_wa_objpack.
    Move error records to the file, semi-colon delimited
      LOOP AT e_error INTO g_error.
        CONCATENATE g_error-pernr ';'
                    g_error-nachn ';'
                    g_error-vorna ';'
                    g_error-werks ';'
                    g_error-persg ';'
                    g_error-eligr ';'
                    g_error-msg INTO l_error.
        APPEND l_error TO lt_objbin.
      ENDLOOP.
    Document type is TXT
      l_wa_objpack-doc_type   = l_c_txt.
    APPEND object_header.
      CALL FUNCTION 'SO_RAW_TO_RTF'
        TABLES
          objcont_old = lt_objbin
          objcont_new = lt_objbin.
    Begin of Insert CHRK941885
      LOOP AT lt_objbin into l_error.
       conv = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' endian = 'B').
        CALL METHOD conv->write( data = l_error ).
        l_buffer = conv->get_buffer( ).
        move l_buffer to l_hexa.
        move l_hexa to l_hex-line.
        APPEND l_hex to lt_contents_hex.
      ENDLOOP.
    End of Insert CHRK941885
    File name for attachment
      l_wa_obj = l_c_name.
      APPEND l_wa_obj TO lt_objhead.
      CLEAR  l_wa_obj.
      DESCRIBE TABLE lt_objbin LINES l_tab_lines.
    Creation of the entry for the compressed attachment
      l_wa_objpack-transf_bin = 'X'.
      l_wa_objpack-head_start = 1.
      l_wa_objpack-head_num   = 1.
      l_wa_objpack-body_start = 1.
      l_wa_objpack-obj_name   = l_c_name.
      l_wa_objpack-obj_descr  = l_c_name.
      l_wa_objpack-body_num   = l_tab_lines.
      l_wa_objpack-doc_size   = l_tab_lines * l_c_255.
      APPEND l_wa_objpack TO lt_objpack.
      CLEAR  l_wa_objpack.
    Completing the recipient list
      LOOP AT s_email.
        l_wa_reclist-receiver = s_email-low.
        l_wa_reclist-express  = 'X'.
        l_wa_reclist-rec_type = 'U'.
        APPEND l_wa_reclist TO lt_reclist.
        CLEAR  l_wa_reclist.
      ENDLOOP.
    Document to send
      MOVE 'Health Risk Assessment Batch extract'(h01)
        TO l_wa_doc_chng-obj_descr.
    Send mail as a confidential
      l_wa_doc_chng-sensitivty = 'P'.
    Send the document
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
        EXPORTING
          document_data              = l_wa_doc_chng
          put_in_outbox              = ' '
          commit_work                = 'X'
        TABLES
          packing_list               = lt_objpack
          object_header              = lt_objhead
         contents_bin               = lt_objbin       " Comment CHRK941885
          contents_txt               = lt_objtxt
          contents_hex               = lt_contents_hex  " Insert CHRK941885
          receivers                  = lt_reclist
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          document_type_not_exist    = 3
          operation_no_authorization = 4
          parameter_error            = 5
          x_error                    = 6
          enqueue_error              = 7
          OTHERS                     = 8.
      IF sy-subrc = 0.
        MESSAGE s000(oo) WITH 'Email sent to recipients'(s12).
      To refresh SAP Work Office so that mail can be recieved immediataly.
        WAIT UP TO 2 SECONDS.
        SUBMIT rsconn01 WITH mode = 'INT'
                      WITH output = ''
                      AND RETURN.
      ELSE.
        MESSAGE e000(oo) WITH 'Problem sending Email.'(e02).
      ENDIF.

  • Serious Problem using function

    Hello mates,
    I new to Oracle JDBC and im working on a project that uses Oracle as DB. There are some stored procedures and functions that i have to access , but some of them are getting me nervous. The problem is that when i call a simple function returning a simple CHAR i get the result OK, but when i call two specific functions that also returns CHAR i get null as result, the problem is that when i call them from sqlplus and from Perl i get the result OK, but i call the like SELECT USR_ONLINE.MONTAPOP(160008,'') AS TEST FROM DUAL. Plz help me solve this problem cause my project is stopped because of that.
    Ty Very much. Here comes my code:
    String sql ="{ ? = call USR_ONLINE.MONTAPOP(160008,'') }";
    OracleCallableStatement cstmt = (OracleCallableStatement) con.prepareCall(sql);
              cstmt.registerOutParameter(1,Types.CHAR);     
    cstmt.execute();
              System.out.println(cstmt.getString(1));

    Bruno,
    I get the impression that English is not your first language, so excuse me if I have misunderstood your question.
    From the code you posted, it looks like the "MONTAPOP" function takes two parameters -- a NUMBER and a VARCHAR2, I believe -- and that you are calling the function with a null second parameter.
    If the above is correct, then I suggest the following:
    [Note: Uncompiled and untested.]
    String sql ="{? = call USR_ONLINE.MONTAPOP(?,?)}";
    CallableStatement cstmt = con.prepareCall(sql);
    cstmt.registerOutParameter(1,Types.CHAR);
    cstmt.setBigDecimal(2, new BigDecimal(160008));
    cstmt.setNull(3, Types.VARCHAR);
    cstmt.execute();
    System.out.println(cstmt.getString(1));Good Luck,
    Avi.

  • REF CURSOR problem .. function call from select

    Hello,
    I am still on the search for a way to call a function from with in a select statement.
    I've done it in SQL*Plus like this and it works.
    SELECT name, f_format(name) FROM user WHERE id = 12;
    This returns first the unformatted (raw) version of the stored value for name and then the formmtted version of the stored value of name.
    Since multiple names will be returned I need to user a REF CURSOR (cursor variable). The above select statement does not work from within the OPEN . .FOR clause necessary for a REF CURSOR.
    What can I do instead? My goal is to return multiple records of formatted names.
    null

    I have declared the reference cursor as a weak one. Thank you for clarifying that though. I was wondering if it made a difference. Here is a simple package that shows you what I am trying to do. I will include the errors at the bottom. Please have a look and let me know what you think is wrong.
    /*--------- PL/SQL ------------*/
    CREATE OR REPLACE PACKAGE test_refcur AS
    PROCEDURE decrypt (
    i_string IN VARCHAR2
    ,o_string OUT VARCHAR2
    TYPE PwdCurTyp IS REF CURSOR;
    PROCEDURE get_pwd_info (
    i_user_id IN NUMBER
    ,io_pwd_cv IN OUT PwdCurTyp
    END test_refcur;
    CREATE OR REPLACE PACKAGE BODY test_refcur AS
    FUNCTION f_decrypt (
    i_string IN VARCHAR2
    ) RETURN VARCHAR2 IS
    l_string VARCHAR2(64);
    l_string_dec VARCHAR2(32);
    BEGIN
    l_string := i_string;
    dbms_obfuscation_toolkit.DESDecrypt(
    input_string => l_string
    ,key_string =>'12345678'
    ,decrypted_string=> l_string_dec );
    RETURN l_string_dec;
    END f_decrypt;
    PROCEDURE decrypt (
    i_string IN VARCHAR2
    ,o_string OUT VARCHAR2
    ) IS
    BEGIN
    o_string := f_decrypt(i_string);
    END decrypt;
    PROCEDURE get_pwd_info (
    i_user_id IN NUMBER
    ,io_pwd_cv IN OUT PwdCurTyp
    ) IS
    BEGIN
    OPEN io_pwd_cv FOR
    SELECT
    label
    ,f_decrypt(user_name_text) AS dec_user_name
    ,f_decrypt(text) AS dec_pwd
    FROM
    code_pwd
    WHERE
    id = i_user_id;
    END get_pwd_info;
    END test_refcur;
    /*--------- SQL*Plus -----------*/
    Warning: Package Body created with compilation errors.
    SHOW ERRORSErrors for PACKAGE BODY TEST_REFCUR:
    LINE/COL ERROR
    28/13 PL/SQL: SQL Statement ignored
    30/18 PLS-00231: function 'F_DECRYPT' may not be used in SQL
    Then I made the SELECT statement dynamic.
    OPEN io_pwd_cv FOR
    'SELECT label, f_decrypt(user_name_text) AS dec_user_name, f_decrypt(text) AS dec_pwd FROM code_pwd WHERE id = i_user_id';
    It compiled fine.
    Package body created.
    So then I tried to do the following. .
    SET AUTOPRINT ON
    SET SERVEROUTPUT ON
    VARIABLE cv REFCURSOR
    EXECUTE test_refcur.get_pwd_info(18, :cv)begin test_refcur.get_pwd_info(18, :cv); end;
    ERROR at line 1:
    ORA-00904: invalid column name
    ORA-06512: at "K.TEST_REFCUR", line 27
    ORA-06512: at line 1
    If I change the SELECT statement to the following, this is what I get. .
    OPEN io_pwd_cv FOR
    SELECT label
    -- ,f_decrypt(user_name_text) AS dec_user_name
    -- ,f_decrypt(text) AS dec_pwd
    FROM code_pwd
    WHERE id = i_user_id;
    SET AUTOPRINT ON
    SET SERVEROUTPUT ON
    VARIABLE cv REFCURSOR
    EXECUTE test_refcur.get_pwd_info(18, :cv)PL/SQL procedure successfully completed.
    LABEL
    Development Server
    That tells me that at least something is working. How can I get everything else to work?

  • Problem using Function Module IDOC_INBOUND_ASYNCHRONOUS

    Hi friends,
    I have a critical problem load idoc ARTMAS05. I development a program for load the data with idoc but my program call the function module IDOC_INBOUND_ASYNCHRONOUS close my session of the SAP GUI and lose the load. This problem begining today because yesterday was work well. This morning when I'm load the idoc gave to me a short dump with this message "SNAP_NO_NEW_ENTRY" I have find some notes and obtained this note 17537.
    Note Solution
    Solution
    When the SNAP Table is full: Reorganize the table e.g. via Transaction ST22->Go to->Reorganize. Please also refer to Note 16083. This may lead to other errors of this kind since not all dumps e.g. from SM21 can be displayed.
    In case of database problems, the errors should no longer occur with new short dumps after correcting the database error. Here, other errors of this kind may occur in SM21 as well.
    After apply the correction begin the error that I close me the Session of SapGui and lose all my data proccessing. Please need your help.
    Thank and regards..

    Hi Sir,
    I am also facing the same issue...i need to update dependents Information  Date Of Birth n Perid(Which is stored in IT0106)...in IT 0021..
    Kindly correct my code....
    I am using the following code for this...
    data: w_return type  bapireturn1.
    data: p0021_struc TYPE p0021,
          p0106_struc TYPE p0106,
          p_pskey   TYPE pskey.
    start-of-selection.
    get pernr.
    p0021_struc = p0021.
    p0021_struc-favor = 'Gaurav'.
    p0021_struc-fgbdt = '05/10/1955'.
    Move p0021_struc-favor to p0021-favor.
      p0106_struc = p0106.
      p0106_struc-stras = '2235 BOmbay Road'.
      p0106_struc-perid = '123456789'.
      MOVE p0106_struc-stras to p0106-stras.
    Enqueue personnel number
      call function 'BAPI_EMPLOYEE_ENQUEUE'
        exporting
          number = pernr-pernr
        importing
          return = w_return.
      CALL FUNCTION 'HR_INFOTYPE_OPERATION'
        EXPORTING
          infty            = p_pskey-infty
          number           = p_pskey-pernr
          subtype          = p_pskey-subty
          objectid         = p_pskey-objps
          lockindicator    = p_pskey-sprps
          validityend      = p0021-endda         " '99991231'
          validitybegin    = p0021-begda
          record           = p0021_struc
          operation        = 'mod'
          tclas            = 'A'
          dialog_mode      = '2'
         nocommit         = p_test
          VIEW_IDENTIFIER  = '07'              "p0003-viekn
          secondary_record = p0106_struc
        IMPORTING
          return           = w_return
         key              = familykey
        EXCEPTIONS
          OTHERS           = 0.
    Enqueue personnel number
      call function 'BAPI_EMPLOYEE_DEQUEUE'
        exporting
          number = pernr-pernr
        importing
          return = w_return.

  • Problem using functions in discov

    Hi all,
    I`m creating a report and I`m using 2 complex folders and 3 database functions as calculations.
    when I use the first two the report works fine, but when I use the third function the report stop working.
    works with almost 79000 rows. is it possible that the problem is I am using too much functios?
    thanx for your time.

    Another check would be to get the SQL generated by the worksheet, and run it in SQL Plus to see whether there are any errors that pop up there.

  • Problem using Function Module

    Hi,
    I am using RH_STRUC_GET with evalPath O-O-S-P and get the or g structure. I then loop through the table obtained from RH_STRUC_GET and re-use RH_STRUC_GET with a evaluation path 'bossonly' to find out who the managers are. But it does not work. I get No ROOTS FOUND error.
    When I try the function module RH_STRUC_GET separately with the same input fields then it works!!!
    Please let me know if I am doing anything wrong. My code is shown below....
    FUNCTION Z_ORGBUILDER_CONN.
    ""Local interface:
    *"  IMPORTING
    *"     VALUE(OTYPE) LIKE  OBJEC-OTYPE
    *"     VALUE(OBJID) LIKE  OBJEC-OBJID
    *"     VALUE(PATHID) LIKE  GDSTR-WEGID
    *"     VALUE(PLVAR) LIKE  OBJEC-PLVAR
    *"  EXPORTING
    *"     VALUE(RETURN) LIKE  BAPIRET2 STRUCTURE  BAPIRET2
    *"  TABLES
    *"      L_ZCONN_TAB TYPE  ZCONN_TAB
    *"      RESULT_TAB STRUCTURE  SWHACTOR OPTIONAL
    *"      RESULT_OBJEC STRUCTURE  OBJEC OPTIONAL
    *"      RESULT_STRUC STRUCTURE  STRUC OPTIONAL
    *"      L_ZCONN_ORG TYPE  ZCONN_TAB
    *"      L_ZCONN_POS_HOLDER TYPE  ZCONN_POS_TAB
    *"      L_MANAGERS STRUCTURE  OBJEC
    DATA: z_struc type zconn_struc.
    DATA: xresult_struc like result_struc.
    DATA: yresult_struc like result_struc.
    DATA: z_struc1 type zconn_struc.
    DATA: z_struc_pos type zconn_position.
    DATA: temp_tab LIKE SWHACTOR occurs 0 with HEADER LINE.
    DATA: temp like struc-objid.
            CALL FUNCTION 'RH_STRUC_GET'
              EXPORTING
                          act_otype = otype
                          act_objid = objid
                          act_plvar = plvar
                          act_wegid = pathid
              TABLES
                          result_tab = result_tab
                          result_struc = result_struc
                          result_objec = result_objec
              EXCEPTIONS
                          no_plvar_found = 1
                          no_entry_found = 2
                          OTHERS = 3.
              IF sy-subrc <> 0.
                          RAISE no_roots_found.
              ENDIF.
    LOOP AT result_struc into xresult_struc.
          read table result_struc into yresult_struc with key seqnr =
    xresult_struc-pup.
            if sy-subrc = 0.
            z_struc-objectID = xresult_struc-OBJID.
            z_struc-objectType = xresult_struc-otype.
            z_struc-parentID = yresult_struc-objid.
            z_struc-parentType = yresult_struc-otype.
    endif.
    Append z_struc to l_zconn_tab.
    ENDLOOP.
    LOOP AT l_zconn_tab.
      if l_zconn_tab-objectType = 'O' or l_zconn_tab-objectType = 'S'.
            z_struc1-objectID = l_zconn_tab-objectID.
            z_struc1-objectType = l_zconn_tab-objectType.
            z_struc1-parentID = l_zconn_tab-parentID.
            z_struc1-parentType = l_zconn_tab-parentType.
    Append z_struc1 to l_zconn_org.
        endif.
    ENDLOOP.
    LOOP AT l_zconn_tab.
      if l_zconn_tab-objectType = 'P'.
            z_struc_pos-position = l_zconn_tab-parentID.
            z_struc_pos-pos_holder = l_zconn_tab-objectID.
    Append z_struc_pos to l_zconn_pos_holder.
        endif.
    ENDLOOP.
    loop at result_struc.
      if result_struc-otype = 'O'.
            CALL FUNCTION 'RH_STRUC_GET'
              EXPORTING
                          act_otype = 'O'
                          act_objid = result_struc-objid
                          act_plvar = '01'
                          act_wegid = 'bossonly'
              TABLES
                          result_tab = temp_tab
              EXCEPTIONS
                          no_plvar_found = 1
                          no_entry_found = 2
                          OTHERS = 3.
              IF sy-subrc <> 0.
                          RAISE no_roots_found.
              ENDIF.
              APPEND LINES OF temp_tab to L_managers.
          endif.
    endloop.
    ENDFUNCTION.

    data: begin of itab occurs 0,
          orgunit(10) type c,
          mananger(30) type c,
          end of itab.
    * This will add a record to your itab
    loop at result.
      itab-orgunit = result-orgunit.   " I don't know what fields they are
      itab-manager = result-manager.
      append itab.
    endloop.
    Please remember to award points for helpful answers and mark this post as solved if you question has been answered.  Thanks.
    Regards,
    Rich Heilman

  • Problem using function module for infotype 21

    hi
    im uploading the infotype 21 (family details) through function module hr_infotype_operations. i found that infotype 0106 (family/related person)
    is a secondary infotype and that a record is created for 0106 ,everytime you create a record in 21. so i upload the family data of an employee using the function module for infotype 21 initially. and then fetch the same record from the table pa0106 and modify the same record with other information.
    for example : u have the address details of a dependent(father subtype 11) in infotype 21. this address data is stored in the table pa0106 .  im not able to modify the record for infotype 0106 using the function module 0106.
    i would like to know the reason for the same. Is it because that infotype 0106 is a secondary infotype and u cannot modify the record using the fn module..?/
    thanks
    sridharan

    Hi Sir,
    I am also facing the same issue...i need to update dependents Information  Date Of Birth n Perid(Which is stored in IT0106)...in IT 0021..
    Kindly correct my code....
    I am using the following code for this...
    data: w_return type  bapireturn1.
    data: p0021_struc TYPE p0021,
          p0106_struc TYPE p0106,
          p_pskey   TYPE pskey.
    start-of-selection.
    get pernr.
    p0021_struc = p0021.
    p0021_struc-favor = 'Gaurav'.
    p0021_struc-fgbdt = '05/10/1955'.
    Move p0021_struc-favor to p0021-favor.
      p0106_struc = p0106.
      p0106_struc-stras = '2235 BOmbay Road'.
      p0106_struc-perid = '123456789'.
      MOVE p0106_struc-stras to p0106-stras.
    Enqueue personnel number
      call function 'BAPI_EMPLOYEE_ENQUEUE'
        exporting
          number = pernr-pernr
        importing
          return = w_return.
      CALL FUNCTION 'HR_INFOTYPE_OPERATION'
        EXPORTING
          infty            = p_pskey-infty
          number           = p_pskey-pernr
          subtype          = p_pskey-subty
          objectid         = p_pskey-objps
          lockindicator    = p_pskey-sprps
          validityend      = p0021-endda         " '99991231'
          validitybegin    = p0021-begda
          record           = p0021_struc
          operation        = 'mod'
          tclas            = 'A'
          dialog_mode      = '2'
         nocommit         = p_test
          VIEW_IDENTIFIER  = '07'              "p0003-viekn
          secondary_record = p0106_struc
        IMPORTING
          return           = w_return
         key              = familykey
        EXCEPTIONS
          OTHERS           = 0.
    Enqueue personnel number
      call function 'BAPI_EMPLOYEE_DEQUEUE'
        exporting
          number = pernr-pernr
        importing
          return = w_return.

  • Function call in where cluse

    Hello
    i am trying to execute one statement in stored procedure.
    basically i need to pass split string in where clause. it goes like this..
    in put is : E,R,T.
    i have written the function which will split the string into 'T','R','E'.
    CREATE OR REPLACE FUNCTION FN_SPLIT_STRING(P_STR_VALUE VARCHAR2)
    RETURN VARCHAR2 is
    V_TEMP VARCHAR2(100);
    V_VALUE VARCHAR2(100);
    V_OUT VARCHAR2(100);
    BEGIN
    V_TEMP := P_STR_VALUE||',';
    WHILE (V_TEMP IS NOT NULL)
    LOOP
    V_VALUE := SUBSTR(V_TEMP, 1, INSTR(V_TEMP, ',')-1);
    --DBMS_OUTPUT.PUT_LINE(V_VALUE);
    V_OUT := ''''||V_VALUE||''''||',' ||V_OUT;
    V_TEMP := SUBSTR(V_TEMP, INSTR(V_TEMP, ',')+1);
    END LOOP;
    return(SUBSTR(V_OUT, 1, LENGTH(V_OUT)-1));
    END FN_SPLIT_STRING;
    i have to execute the below query now
    select * from TABLE_X_TXN_VAR
    where process_flag IN ( FN_SPLIT_STRING (E,S,T) ) and X_LAST_UPDATE_DATE < To_Date('1/22/2006','MM/DD/YYYY');
    i am ideally expecting it to pass Process_flag In ('T','R','E') but it is instead comparing whole string like it is searching for process flag as "('T','R','E')" instead it should do one by one like normal In clause. i.e. first it should check for 'E' then for 'R' then for 'T'.

    Explore these threads:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:110612348061
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:210612357425
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2189860818012
    and you'll discover several examples.

Maybe you are looking for

  • ITunes freezes every time I open after upgrading to 9.1.1

    So every time I open iTunes now (after I upgraded to 9.1.1) it starts updating my iTunes library. Problem is that it gets to a certain point in the updating (maybe 5%) and then it freezes the whole computer. I've never had any problems with iTunes be

  • How to remap keyboard characters?

    I'd like to remap my Russian phonetic keyboard layout to match what this guy did for the Mac: (scroll down to Usage to see the layout that I'm wanting): http://www.users.bigpond.com/sphynx1/RussianPhonetic/ Does anyone know what files I can edit to g

  • [Solved] Gnome-Shell and separating programs in the program switcher

    Hi, I would like to treat different instances of Emacs as different programs in Super-Tab program switcher in Gnome-Shell (I run mail and music in different instances). In the overview they show as different programs via .desktop files.  But with Sup

  • Writing contact with computer

    How can you access the contents of contact with a mac? I dont want to have to enter all of them with the key board...

  • Long time launching the WAD 7.0

    Dear gurus, Every time I launch WAD7.0 I get a window with message: BI metadata for system <SID> in language EN is outdated or not yet installed ... Then It downloads several minutes and the WAD is launched. did anyone experience this ? know how to s