Problem calling program unit function in Forms 6i

Hi,
I'm new to programming with Oracle Forms. I have a question that I cannot seem to figure out. In Forms 6i, I have created a program unit function that compiles correctly. The trouble I'm having is calling it and displaying the function's contents into a non-database display item I created. When I run my app, the display item it blank while my other fields populate.
I first tried to call it in a POST-QUERY trigger but I get an error stating "function cannot be called in SQL." Can you not call a function in a form's trigger? If so, what would be the correct syntax?
Then I tried to call it in the non-database item's Calculation => Formula (property) by just stating the function_name(parameter). This appears to compile fine too, but still no display at runtime.
What would be the best way to reference my function to display its contents properly? Does anyone have any examples? Any help would be greatly appreciated. Thank you.

First, get rid of the
EXCEPTION WHEN NO_DATA_FOUND
in your function. Summary queries never raise no_data_found; They just return null.
Your ":history.consecutive_years := NumberOfYears(:student.id);" is the proper way to call the function. That is what I was trying to tell you with the example: ':Myblock.Item_x := function_name(some_parm);' code
If your post-query trigger only executes the function, then I think your problem is somewhere else:
'FRM-40735 POST-QUERY trigger raised unhandled exception' looks like a problem elsewhere.
Don't know of a good website. Just keep asking here -- somebody is bound to pop in and help you out.
One more thing: drop this into your form-level on-error trigger. It often helps to find problems:
-- On-error form-level trigger                                       --*
DECLARE
  Err_Code NUMBER(5)     := ERROR_CODE;
  Err_Text VARCHAR2(100) := ERROR_TEXT;
  MSG      VARCHAR2(150)
          := SUBSTR('   '||ERROR_TYPE||'-'||TO_CHAR(Err_Code)||': '
                                     ||Err_Text,1,150);
  DBMS_TXT VARCHAR2(500);
BEGIN
  IF Err_Code IN (40401,40405,     --No changes to save/apply
                  40100,40352) THEN --at first/last record
    MESSAGE(MSG,NO_ACKNOWLEDGE); -- Don't raise Form_Trigger_Failure
  ELSE -- all other messages
    -- check database error message --
    DBMS_TXT := SUBSTR(DBMS_ERROR_TEXT,1,500);
    if  DBMS_TXT is not null
    and substr(DBMS_TXT,5,5)
      not in('00000',
             '01403') then --1403=no data found
      -- show entire msg, add new_line chars.
      DBMS_TXT := replace(DBMS_TXT,'ORA-',chr(10)||'ORA-');
      DBMS_TXT := replace(DBMS_TXT,' '||chr(10), chr(10));
      -- show MSG and DBMS_TXT both as an alert --
      --PLL_ALERT( ltrim(MSG) || DBMS_TXT );
      Message(ltrim(MSG) || DBMS_TXT );
      Message(' ',no_acknowledge);
      Raise Form_Trigger_Failure;
    else
      Message(MSG);
      Message(' ',no_acknowledge);
      Raise Form_Trigger_Failure;
    End if;
  END IF;
END; -- end of on-error trigger

Similar Messages

  • SQL Statement in Program Unit (function)

    When I tried to create a Program Unit(function) in the Form
    module I have got an error
    message "..identifier "SALES.USER_ADMIN" must be declared.."
    How can I fixed it or may be some suggestions..
    Thank you.
    FUNCTION DEF_USER_STATUS (User_Name VARCHAR2)
    RETURN VARCHAR2
    IS
    Security_Stat VARCHAR2(20);
    BEGIN
    SELECT ALL UPPER(SECURITY_STATUS)
    INTO Security_Stat
    FROM SALES.USER_ADMIN
    WHERE LOGIN_NAME = :GLOBAL.LOGIN_NAME;
    IF NO_DATA_FOUND THEN
    Security_Stat := 'GUEST';
    END IF;
    RETURN Security_Stat;
    END DEF_USER_STATUS;

    Check if you are connected before compiling your function. The other thing you should check is if you have proper GRANTs to access tables under SALES schema.
    Also, IF NO_DATA_FOUND is not the way to handle EXCEPTION. Code it as
    EXCEPTION WHEN NO_DATA_FOUND THEN
    END ;
    Hope this helps.
    Parag Kansara

  • How Do I Make Updated Procedure in the Program Unit of the Form to Work?

    I have updated a procedure in the Program Unit of the Form that I modified. I am not sure what are the proper ways to compile or load the changed procedure in my form to make sure the changes work. Please help me with the following questions:
    Do I have to use Oracle Procedure Builder to compile the updated procedure in order to have the form work properly? If so, how do I make the list of procedures in the program unit of my form to come up after I have the Oracle Procedure Builder opened and connected to our database?
    Couldn't I just compile the form after the changes are made to the procedure (Body) in the Program Unit of the form in the Forms Builder?
    Any thoughts and/or suggestions on this are welcome.
    FYI, we are in Oracle Forms 6.i with Oracle database version 10.2.0.2.
    Thanks.

    There was no errors what so ever, no triggers and other module errors, when I compiled and created an executable for my form.
    If the database is not connected, Forms Builder would not allow me to compile/execute any forms so I am pretty sure that the database was connected when I did 'CTRL' + 't' to create an executable.
    FYI, the following is an excerpt from Oracle Procedure Builder Help:
    A procedure is a subprogram that performs a specific action. ...
    A procedure has two parts:
    *     specification (spec for short)
    *     the body
    Specification
    The procedure spec begins with the keyword PROCEDURE and ends with the procedure name or a parameter list. Parameter declarations are optional. Procedures that take no parameters are written without parentheses. For example, the specification of procedure proc1 is displayed below:
    PROCEDURE proc1 (param CHAR);
    Body
    The procedure body begins with the keyword IS and ends with the keyword END followed by an optional procedure name. The procedure body has three parts: a declarative part, an executable part, and an optional exception-handling part.
    and all of other procedures, that do not have an '*' next to the procedure name in the Program Units of my form, contain both Spec and Body.
    p.s. I remember the '*' next to the procedure name means the procedure has been changed, and ... (sorry, I don't remember the rest...)
    Thanks.

  • How to use one forms fields, program units in another form.

    The whole proceessing and update is happening in one main form.
    Main form has all the fields and a reprocess button which re-creates records if they have error. Record name is the primary key.
    I have another small form, which just shows the list of record names in the system. I want a reprocess button next to each record name so that user will be able to just select any record name and press reprocess button to recreate any record data.
    There are a lot of fields in main form and program units , which are used by the reprocess button.
    Any suggestions like how to go for it?

    You can either pass all the relevant data from the Small Form to the Larger form and make it reprocess the data or you can move the Program Units to a PL/SQL Library (.pll) and attach the library to your smaller form where you can call the program units. Either option requires changes to the Larger form to enable it to process a record passed to the form as a parameter or to externalize the Forms Program Units to a library.
    Personaly, I would recommend you move the Program Units to a Library. This would enable you to use the processes in any form (that has the library attached).
    Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • FRM-40734 when calling external DLL Function from Forms 6

    Even though some answers were given to my previous help request ("Again: Forms 6 and user-defined data types") I wasn't able to solve the problem of passing a parameter of an user-defined type to an external DLL function residing in the SECURSIGN.DLL library (the closest solution was to declare that "composite" parameter using the ROWTYPE clause referencing a custom-made table created just for the sake of defining that perticular datatype).
    So I concentrated on SECURSIGN.DLL functions using more trivial data types, like a function requiring just four character strings as parameters.
    I generated the necessary PL/SQL support using the FFI.
    I discovered that also the simplest calls to external functions fail at runtime with the generic error FRM-40734.
    I located the error: it happens just at the moment of calling the function from within the FFI-generated package body. Before that, the DLL is loaded with no problem, the function is correctly registered, and a function handle is regularly returned.
    As long as I can regularly issue the very same call with the very same parameters from Visual Basic, I can't understand what's going wrong (ALL the needed DLL are in the same directory as the FMB/FMX forms).
    I will greatly appreciate any help that You may be able to provide.

    I have noticed just now that a dump file having a name like ifrun60_dump_299, is generated by FORMS every time I issue the aborted call to the foreign function.
    Inside the form dump file, apart from useless info like Registers and so on, the message:
    "Could not find Module32First"
    By a FILE/FIND/CONTAINING TEXT I searched all the DLLs, and I noticed that Module32First is a routine that can be found within each of the following DLLs:
    Cl32
    d2kwut32
    d2kwut60
    I tried to load those DLLs along with SECURSIGN.DLL by modifying the PROCEDURE LoadLibrary into the FFI-generated PLL code, and I have apparently no problem in loading all the DLLs that I wish, but the error persists, and that dump file is constantly generated, always looking for the "Module32First" routine.
    How can I avoid all that mess and the FRM-40734 error??

  • Can I create a dynamic cursor in a program unit on oracle form....

    Hello folks,
    can I create a dynamic cursor on client side ( in a program unit on the oracle form), is it possible, I Know how to create it on server side using Ref cursor, but on client side i got this message (can't be created on client side or something like that).... please if someone can help

    > select count(*) from t_comsis
    <p>But when you put that select string into a varchar2 variable, it won't compile. Which makes it hard to create anything "dynamic".
    <p>In Forms, you can create and populate a record group dynamically, which is ok as long as your select will not retrieve too many (more than several hundred) rows.
    <p>Or, your other option is to use the Forms Exec_SQL dynamic sql package.

  • Calling a procedure/function in forms personalization

    Hi,
    Can any one please help me in calling a procedure/function from the forms personalization? The requirement is to create an attachment when ever a new order line is created in R12. So for this, I created a procedure which calls attachment creation API. And in the forms personalization, I am doing the following.
    Trigger Event: WHEN-VALIDATE-RECORD
    Trigger Object: LINE
    Condition: :LINE.INVENTORY_ITEM_ID is not null
    Action Type: Builtin
    Builtin Type: Execute a Procedure
    Argument: =xx_test_attachment_new(:LINE.LINE_ID,20,'OE_ORDER_LINES',1,'test123')
    This procedure works individually if I call it from TOAD.
    Help is really appreciated?
    Thanks,
    Sri.

    A question for the Forms ?
    Nicolas.

  • Problem calling a packaged function from an authorization scheme

    I wrote a package and body called pkg_auth with a function returning a boolean called is_authorized with 2 parameters (username and functional area).
    i.e.
    CREATE OR REPLACE PACKAGE pkg_auth
    AS
    FUNCTION is_authorized(p_username VARCHAR2, p_functional_area VARCHAR2) RETURN BOOLEAN;
    END;
    additionally i created a public synonym for it and granted execute access on it to apex_public_user and htmldb_public_user;
    i then created an authorization scheme called 'access_control_db' defined as Scheme Type 'PLSQL Function Returning Boolean' and placed the following:
    pkg_auth.is_authorized(v('APP_USER'),'DATABASE')
    in the Expression 1 field.
    and the following:
    Not permitted to edit database information.
    in the error field.
    However when I apply this authorization scheme to a buton I receive the following error when I go to the page containing that button:
    ORA-06550: line 1, column 44: PLS-00221: 'IS_AUTHORIZED' is not a procedure or is undefined ORA-06550: line 1, column 44: PL/SQL: Statement ignored
         Error      ERR-1082 Error in executing authorization scheme code.
    Any help would be most appreciated.

    Hello,
    Does putting 'return' infront -
    return pkg_auth.is_authorized(v('APP_USER'),'DATABASE')fix your problem?
    John.
    Blog: http://jes.blogs.shellprompt.net
    Work: http://www.apex-evangelists.com
    Author of Pro Application Express: http://tinyurl.com/3gu7cd
    REWARDS: Please remember to mark helpful or correct posts on the forum, not just for my answers but for everyone!

  • Call program from function

    Hallow I build a function in se37 ,and in the function I wont to delete file from server now I have  a program
    in se 80 that can do that (YHR_DELETE_FILE_FROM_SERVER)the program have just one parameters  (the path of the file I wont to delete )
    How I can call to this program in my function.
    regards
    did some one now  about function that can delete file from server?

    Hi antonio,
    1.in se 80 that can do that (YHR_DELETE_FILE_FROM_SERVER)t
    2. use like this in your FM
    <b>SUBMIT YHR_DELETE_FILE_FROM_SERVER
    WITH
    parameter1 = myfilename.</b>
    regards,
    amit m.

  • Problem calling a report from a form

    Hello,
    i thought about 5 hours what causes this. but i didn't found a solution..
    [http://img188.imageshack.us/i/67205607.jpg/]
    in when-button-pressed i have:
    DECLARE
    report_id REPORT_OBJECT;
    report_job_id VARCHAR2(200);
    rep_status VARCHAR2(200);
    JOB_NUMBER number;
    server_name VARCHAR2(200) := 'roger';
    BEGIN
    /* Check to see if forms application is WEB deployed */
    IF get_application_property(user_interface) = 'WEB' THEN
         report_id:= FIND_REPORT_OBJECT('report104');
         /* Set Report parameters given WEB deployment */
         SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_SERVER , server_name);
         SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_DESTYPE,CACHE);
         /* DESFORMAT could be HTML, HTMLCSS or PDF here*/
         SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_DESFORMAT,'PDF');
         /* Run the report */
         report_job_id := RUN_REPORT_OBJECT(report_id);
         /* Check the report status */
         rep_status:=REPORT_OBJECT_STATUS(report_job_id);
         WHILE rep_status IN ('RUNNING','OPENING_REPORT','ENQUEUED')
         LOOP
         rep_status := report_object_status(report_job_id);
         END LOOP;
         IF rep_status='FINISHED' THEN
         message('REPORT WAS CORRECTLY RUN');
         /* Display the report output in the client browser */
         JOB_NUMBER := length(server_name) + 2;
         WEB.SHOW_DOCUMENT ('/reports/rwservlet/getjobid'||substr(report_job_id,JOB_NUMBER)||'?server=' || server_name ||'&param_cls='||to_number(:control.lst_clase));
         /* If report has failed display message to user */
         ELSE
              message('REPORT FAILED WITH STATUS: '||rep_status, no_acknowledge);
         END IF;
    ELSE
         /* Else if forms application is Client-Server deployed */
         /* Set Report parameters given Client-Server deployment */
         report_id:= FIND_REPORT_OBJECT('report104');
         SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_SERVER ,'');
         /* Report to be executed via Reports Background Engine, not the 'new' Reports Multi-Tier Server */
         /* Destype SCREEN or PREVIEW can be used here */
         SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_DESTYPE,SCREEN);
         /* Run the report */
         report_job_id := RUN_REPORT_OBJECT(report_id);
    END IF;
    END;report104 is the name of the repord added in the Reports node (in Forms).
    in the left window from the image, i checked for the value of parameter param_cls, and it's ok (16).
    when i run the report from the Reports, i see all the repors (that table), but when i run from forms, i got just the headers of the table, the rest is invisible. i don't know why happens this..
    :control.lst_clase returns a char, so i convert that char to a number, and that's the parameter passed from Forms.
    Please help me..
    edit: i saw in Reports that there are two buttons: Run Web Layout and Run Paper Layout. from the Forms, i wanna run the web layout
    Thanks
    Edited by: Roger22 on 22.06.2009 18:24

    finally solved. there was a problem at passing parameters
    this is the code
    DECLARE
    report_id REPORT_OBJECT;
    report_job_id VARCHAR2(200);
    rep_status VARCHAR2(200);
    JOB_NUMBER number;
    server_name VARCHAR2(200) := 'roger';
    rep_url varchar2(500);
    BEGIN
    /* Check to see if forms application is WEB deployed */
    IF get_application_property(user_interface) = 'WEB' THEN
         report_id:= FIND_REPORT_OBJECT('report107');
         /* Set Report parameters given WEB deployment */
         SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_SERVER , server_name);
         SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_DESTYPE,CACHE);
         /* DESFORMAT could be HTML, HTMLCSS or PDF here*/
         SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_DESFORMAT,'HTML');
         /* Run the report */
         report_job_id := RUN_REPORT_OBJECT(report_id);
         /* Check the report status */
         rep_status:=REPORT_OBJECT_STATUS(report_job_id);
         WHILE rep_status IN ('RUNNING','OPENING_REPORT','ENQUEUED')
         LOOP
         rep_status := report_object_status(report_job_id);
         END LOOP;
         IF rep_status='FINISHED' THEN
         message('REPORT WAS CORRECTLY RUN');
         /* Display the report output in the client browser */
         JOB_NUMBER := length(server_name) + 2;
         rep_url:='/reports/rwservlet?report=D:\Oracle\product\10.2.0\DevSuiteHome_1\reports\ORAR.jsp'
         ||'&userid='||get_application_property(username)||'/'||get_application_property(password)||'@'||get_application_property(connect_string)
         ||'&desformat=htmlcss'
         ||'&destype=cache'
         ||'&paramform=yes'
         ||'&getjobid'||substr(report_job_id,JOB_NUMBER)
         ||'&param_cls='||to_char(:control.lst_clase)
         ||'&param_ansc='||to_char(:control.lst_an)
         ||'&param_sem='||to_char(:control.text_item26);
         WEB.SHOW_DOCUMENT (rep_url,'_blank');
         /* If report has failed display message to user */
         ELSE
              message('REPORT FAILED WITH STATUS: '||rep_status, no_acknowledge);
         END IF;
    ELSE
         /* Else if forms application is Client-Server deployed */
         /* Set Report parameters given Client-Server deployment */
         report_id:= FIND_REPORT_OBJECT('report107');
         SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_SERVER ,'');
         /* Report to be executed via Reports Background Engine, not the 'new' Reports Multi-Tier Server */
         /* Destype SCREEN or PREVIEW can be used here */
         SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_DESTYPE,SCREEN);
         /* Run the report */
         report_job_id := RUN_REPORT_OBJECT(report_id);
    END IF;
    END;but the report is running in Paper Layout. i wanna run in Web Layout (in Reports Builder there are two buttons, Paper Layout and Web Layout). from forms how can i run the report in Web Layout?
    Regards,

  • Problem calling a report (9i) from forms (9i)

    I keep getting the errors when I try to run a report from a form:
    REP-0110: Unable to Open File '~aads' (there is always garbage in this field)
    REP-1070: Error while opening or saving a document
    In my form I have:
    DECLARE
    repid REPORT_OBJECT;
    v_rep     VARCHAR2(100);
    rep_status      VARCHAR2(20);
    BEGIN
    repid := FIND_REPORT_OBJECT('MYREP');
    v_rep := RUN_REPORT_OBJECT(repid);
    END;
    I have the report MYREP created under the Report Node in the Object Navigator as follows:
    Name: MYREP
    Filename: f:\rep_version44.rdf
    Execution Mode: Runtime
    Communication Mode: Synchronous
    Report Destination Type: Screen
    Everything else is blank. I have no idea what to put in for Report Server name or if I need one at all.
    Thanks for any help or suggestions.

    Hi,
    is Filename: f:\rep_version44.rdf a n etwork drive ? If yes then this is the problem if not having assigned the HTTP process a network username with teh required privileges.
    Btw.: Your should sue the Reports Server to run Reports as explained in the Whitepaper on otn.oracle.com/products/forms
    Frank

  • Problem in Program unit

    Hi all experts,
    PROCEDURE fun_a(cond varchar2) IS
    declare
    cursor m_cur1 is
    select name, id from member where sex = 'F';
    cursor m_cur2 is
    select name,id from member;
    BEGIN
    if cond = 'F' then
         m_cur1 := m_cur1;
    else
         m_cur1 := m_cur2;
    end if;
    for mc in m_cur1
    loop
    -- Do something. many lines
    end loop;
    END;
    it appears error during compiling in assign cursor to cursor,
    anyone have ideas how to solve this problem.
    This program has to base on the cond to use the correct sql.
    I cant duplicate the for loop coz it has many lines.
    Thanks

    Or maybe use a REF Cursor:
    PROCEDURE fun_a(cond varchar2) IS
      Type     Ref_cursor_type is REF CURSOR;
      m_cur    Ref_cursor_type;
      v_sql    Varchar2(4000);
      cursor mc_row is
        select name,id from member;
      mc mc_row%rowtype;
    BEGIN
      if cond = 'F' then
        v_sql := 'select name,id from member where sex = ''F''';
      else
        v_sql := 'select name,id from member';
      end if;
      Open m_cur for v_sql;
      Loop
        Fetch m_cur into mc;
        Exit when m_cur%NotFound;
        -- Do something, many lines
      End loop;
      Close m_cur;
    END;

  • Urgent please : program unit in htmldb

    Hi,
    if I have some code that I will repeat in the same region,
    is there in htmldb somwhere where I can store it and then
    call it with parameters (like a program unit in oracle forms)
    Thanks

    Sergio,
    Just curious, can a PL/SQL routine/process be written within an HTMLDB application which can be called from any page/process/validation from within the same application?
    In our shop, to store packages/procedures, we need to get our DBA's involved. They would make sense if they were to be called from a myriad of applications. However, if a block of PL/SQL is going to be called many times within a single HTMLDB app and used nowhere else, this would be very handy.
    Thanks Much,
    Howard

  • How to detect caller of a function module

    Hello,
    how is it possible to detect who is calling a function module?
    Thanks a lot,
    Tanguy Mezzano

    Hi, May i know why you need the caller name. If suppose you want to know currently who is executing the function. then you can check the sy-uname inside the calling program or function module that will have. If you want to know from another program then you need to pass some parameter id in side the function module and check your second program for the parameter id having any value.
    Thanks.
    Regards,
    Jey

  • Preferred - PL/SQL library or Program Unit

    Hi all,
    Please tell me which is preferred - a procedure in an attached library or a program unit (forms program unit)
    And the reasons for it?
    Thanks
    Ranjan

    You can go for PL/SQL library, when two or more forms are accessing the same program unit. Otherwise u can have it in the program unit of the form itself. Performance wise, i dont think much difference will be there.

Maybe you are looking for