Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
371 views
in Technique[技术] by (71.8m points)

sql - Oracle APEX Application Builder: Search for specific employee and return their name, salary & department in an hard coded textfield

I am new to the Oracle APEX AB and currently trying to implement a specific mask that we need for work: We have a table in our SQL-Database for employees. It looks like the following:

| staff_id | name | salary | department_id|

The goal is to have an own input mask, where I have to write down the staff_id, e.g. 100600. Then I click a submit button and the output is created dynamically in the same mask as a text that consists the following (column value in brackets): "Employee [name] has a salary of [salary] € and works in department [department_id].

This scenario is visualized in the following picture:

image

My problem now is that I don't understand the following things:

  • Which element do I need to use in the page designer as an input? (Currently I am trying it with a numberfield)
  • How can I extract the value out of this numberfield and use it into an sql query for the output text.
  • Third: How can I create a hard coded textfield that will only appear after submitting with columns that dynamically adjust to the Input-ID?

So the workflow should be something like: First: Insert staff_id into numb_field and submit Second: SELECT name, salary, department_id FROM EMPLOYEE WHERE STAFF_ID = numb_field_value Third: Put the received values name, salary, department_id in a hardcoded text as the gap fillers and give it as an output on the screen.

Thank you for your help! :)

Visualization of the Input and Output of the procedure

image question from:https://stackoverflow.com/questions/65859662/oracle-apex-application-builder-search-for-specific-employee-and-return-their-n

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here's how:

  • create Number datatype item, let's call it P72_STAFF_ID

  • create a button; let it Submit the page

  • create a display only item with no label (so that it is "invisible")

  • create a process which runs PL/SQL code:

    select 'Employee ' || name || ' has a salary of ' || salary ||
           ' € and works in department ' || department_id
    into :P72_INFO
    from employees
    where staff_id = :P72_STAFF_ID;       
    

Run the page, enter employee's ID and hit the button. You'll see something like this:

image

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...