How to write a procedure?

Hi all

I am using oracle 11g,

I have the table as

EmpID, ename

1           x

2         Y

3         Z

4         M

5          N

6         P

7         Q

8          R

I need a procedure if I pass any column in the procedure, then it should should show all data for a particular column

as if I spend empid, it should show all emp_id

Concerning

Dale

SQL > create or replace procedure test_proc (p_col_name in varchar2,

res 2 the sys_refcursor)

3 is

4 start

5. open to

6 ' select '. p_col_name | "" employee ";

7 end;

8.

Created procedure.

PL/SQL procedure successfully completed.

SQL > var res refcursor

SQL > start

2 test_proc ('employe_id',: res);

3 end;

4.

PL/SQL procedure successfully completed.

SQL > print;

EMPLOYEE_ID

-----------

100

101

102

103

104

105

106

107...

Hello

Above code will be useful

913349 wrote:

I need a procedure if I pass any column in the procedure, then it should should show all data for a particular column

as if I spend empid, it should show all emp_id

Concerning

Dale

See you soon,.

Suri ;-)

Post edited by: Suri
Misunderstood the requirement. Now, I fixed it

Tags: Database

Similar Questions

  • How to write a procedure to call and run the custom package backend

    Hi all

    Oracle 10g
    Oracle Apps R12

    I work with here oracle order management, we have a package called (Pick Release) to customize. Due to a problem, we have this concurrent program execution manually giving Route_id as parameter. The route_id comes from the road to the Table. By using this query

    Select distinct route@DB_LINK_APPS_TO_ROADSHOW route_id
    When trunc (route_date) = trunc (sysdate + 2).

    on a daily basis, we have almost 42 routes and we run this simultaneous program manually close times.

    so now how to write a procedure for this

    Step 1 make the route to the routing table. (By cursor we can get the route_id accordingly)

    Step 2 How to trigger custom backend package and run accordingly to this output of the cursor (route_id)

    If 40 routes of cursor get is - that the simultaneous program runs 40 times according to this route_id.


    can some could provide the steps to do this


    Thanks and greetings

    Srikkanth.M

    To submit a competing request from the back - end:

    FND_REQUEST. SUBMIT_REQUEST (Client or server)

    Summary

    function FND_REQUEST. SUBMIT_REQUEST

    (application IN varchar2 default NULL,

    program IN varchar2 NULL by default,

    Description IN varchar2 default NULL,

    start_time IN varchar2 default NULL,

    sub_request IN default boolean FALSE

    Argument1,

    argument2,..., argument99.

    Return to argument100 number);

    Description

    Submits a competing treatment by a simultaneous Manager. If the query is successful, this function returns the ID of the concurrent request; Otherwise, it returns 0.

    ATTENTION: FND_REQUEST needs to know information about the user and accountability whose application is submitted. Therefore, this feature works of concurrent programs or forms within the Oracle Applications.

    The FND_REQUEST. SUBMIT_REQUEST function returns the ID of the concurrent application after successfully. It is up to the caller to issue a commit to complete the application.

    Your code should retrieve and handle the error message generated if there is a problem of presentation (the ID of the concurrent request returned is 0). Use FND_MESSAGE. RETRIEVE and FND_MESSAGE. ERROR to retrieve and display the error (if the application is made on the client side).

    Related essays: overview of the Message dictionary (see page)

    You must call FND_REQUEST. SET_MODE before calling FND_REQUEST. SUBMIT_REQUEST of a database trigger.

    If FND_REQUEST. SUBMIT_REQUEST fails to go anywhere but a database trigger, database changes are cancelled until the time of the function call.

    After a call to the FND_REQUEST. SUBMIT_REQUEST function, installation of all parameters are reset to their default values.

    Arguments (input)

    short name of the application associated with the concurrent request for enforcement.
    short simultaneous program (not the executable) name of the program for which the application must be made.
    Description Description of the application that appears in the form of concurrent requests (optional).
    start_time time during which demand is expected to start running in the (optional) HH24 or HH24:MI:SS format.
    sub_request set to TRUE if the request is made by another application and should be treated as a subquery.
    From version 11, this parameter can be used if you submit requests for in a concurrent program of PL/SQL stored procedure.
    argument1... 100 arguments for the concurrent request; up to 100 arguments are allowed. If the Oracle Forms submitted, you must specify all arguments of 100.

  • How to write a procedure to recover data in a collection of a table?

    create or replace type of subject as object)
    number of subject_id,
    subject_Desc varchar2 (50)
    )
    /


    create or replace type Subjects_All in the varray (10) of the subject
    /


    create table (student)
    StudentID varchar (10),
    Subjects_all topics
    );


    so, how can I write a procedure to display information like this:


    Topics:
    101 "Mathematics".
    102 'science '.

    Topics:
    ...


    I've written a procedure similar to the following, but it didn't work enough :(

    CREATE OR REPLACE PROCEDURE StudentLoop AS
    all_subj subjects_all;
    subject to each_subj;
    CURSOR all_subjectsrow IS select * from the student;
    BEGIN
    FOR all_subj IN all_subjectsrow LOOP
    FOR each_subj IN all_subj LOOP
    DBMS_OUTPUT. Put_line ('last selected line a ID' | each_subj.subject_id | each_subj.subject_desc);
    END LOOP;
    END LOOP;
    END StudentLoop;


    Any advice?

    Well, it would help if you post the code that produces this result. I'm suspecting try you at the exit of the integer type and not it's content:

    SQL> insert into student(studentid, subjects) values (1, subjects_all(subject(1, 'MATH'), subject(2, 'SCIENCE')));
    
    1 row created.
    
    SQL> select * from student;
    
    STUDENTID |SUBJECTS(SUBJECT_ID, SUBJECT_DESC)
    ----------|-----------------------------------------------------------------------------------------------------------------------------------
    1         |SUBJECTS_ALL(SUBJECT(1, 'MATH'), SUBJECT(2, 'SCIENCE'))
    
    SQL> declare
      2  cursor all_subjectsrow is select * from student;
      3  begin
      4  for rStudent in all_subjectsrow loop
      5    for i in 1..rStudent.subjects.count loop
      6      dbms_output.put_line(rStudent.subjects(i).subject_id||' '||rStudent.subjects(i).subject_desc);
      7    end loop;
      8  end loop;
      9  end;
     10  /
    1 MATH
    2 SCIENCE
    
    PL/SQL procedure successfully completed.
    

    see you soon

  • How to write a procedure using collections

    How can we define the collections inside the procedure and use it

    I get an error of execution of this proc
    create or replace procedure p_collections
    
    is
    
    type calendar is varray(366) of  date;
    calendar c1;
    
    
    begin
    
    
    for i in 1 .. 100
    loop
    
    select sysdate bulk collect into c1 from dual;
    
    
    end loop;
    DBMS_OUTPUT.PUT_LINE(c1);
    
    end;
    Published by: Rahul_India on Sep 12, 2012 14:54

    Published by: Rahul_India on Sep 12, 2012 15:07

    Hello

    Rahul_India wrote:
    I found the error

    it should be
    c1 calendar;
    

    How can I print the values of 100 dates stored in the varray

    If you had 100 DATEs stored in the array, we can say:

    ... FOR  i  IN  1 .. 100
        LOOP
            dbms_output.put_line (c1 (i));
        END LOOP;
    

    Since you have only 1, which will trigger an error.

    You might be better to use the attributes of the FIRST and the LAST:

    ... FOR  i  IN  c1.FIRST .. c1.LAST
        LOOP
            dbms_output.put_line (c1 (i));
        END LOOP;
    
  • How to write a procedure for setting Out when the condition fails

    Here's my query, it works very well when the condition is fulfilled with the valid user ID and password

    create or replace
    PROCEDURE ISVALIDUSER / * this is procedure created to validate the connection information to users created on 09212012 by Charbonneau * /.
    (
    pUSERID IN VARCHAR2,
    Ppassword IN VARCHAR2,
    pUSERTYPE OUT NUMBER
    )
    AS
    tmpUSERID VARCHAR2 (30);
    tmpPASSWORD VARCHAR2 (150);
    tmpIsative VARCHAR2 (10);
    BEGIN
    SELECT Userid, PASSWORD IN tmpUSERID, tmpPASSWORD FROM USERMASTER WHERE USERMASTER. USERID = pUSERID and USERMASTER. PASSWORD = Ppassword AND isactive = "Y";
    / * Check ID USER Existed or not * / / * PASSWORD verification is Existed or not * /.
    IF tmpPASSWORD = AND tmpuserid = pUSERID THEN pPassword
    USERTYPE of SELECT INTO pUSERTYPE FROM USERMASTER WHERE USERMASTER. USERID = pUSERID and USERMASTER. PASSWORD = pPassword;
    ON THE OTHER
    BEGIN
    1 SELECT INTO pUSERTYPE FROM DUAL;
    END;
    END IF;
    END;


    Here I am facing a problem when I get invalid user or password ID it is failed - 1 in pUSERTYPE which is OUT setting
    Please suggest

    You need to read about the exceptions - {message identifier: = 9360013}

    create or replace
    PROCEDURE ISVALIDUSER /*This is Procedure created to validate Login users information Created on 09212012 by Chakravarthy*/
    (
    pUSERID IN VARCHAR2,
    pPASSWORD IN VARCHAR2,
    pUSERTYPE OUT NUMBER
    )
    AS
         tmpIsative VARCHAR2(10);
    BEGIN
         SELECT USERTYPE INTO pUSERTYPE
         FROM USERMASTER WHERE USERMASTER.USERID=pUSERID
         and USERMASTER.PASSWORD=pPASSWORD AND isactive='Y';
    exception
         when no_data_found then
              pUSERTYPE := -1;
    END;
    

    You store your password without encrypting? One who is to have access to your table will see the password...

  • How to create a procedure for REF CURSOR output with any WHERE clause?

    I have a requirement like this: I have a huge question that need to reuse in my code over 10 times. This SQL has about 50 lines. Here for these 10 odd times sometimes changes in WHERE clause (columns are the same). So I can't create a view as SQL is not static.

    I thought to write a procedure with a para of WHERE_CLAUSE entry. I pulled out a refcursor sys by adding where clause. But I can't do it because you cannot add a clause like this where clause.

    i.e.
    PROCEDURE dynamyic_query (p_where_clause IN VARCHAR2, p_out_query OUT SYS_REFCURSOR ) IS
    BEGIN
    
      OPEN p_out_query FOR SELECT ......... FROM table WHERE || ' ' || p_where_clause;
    
    END;
    The foregoing gives an error.

    How to handle such a situation? Any help would be greatly appreciated.

    Hello

    Channa wrote:
    ... However, when I change the procedure like this:

    PROCEDURE FORMS_TEXT_DYN_SQL_TEST(p_where_cluase IN VARCHAR2, p_out_cursor OUT SYS_REFCURSOR) IS
    v_stmt VARCHAR2(1000);
    BEGIN
    v_stmt := 'SELECT tname FROM tab_test WHERE tname LIKE ''%ABS_V4%'' AND :y';
    
    OPEN p_out_cursor FOR v_stmt using p_where_cluase;
    
    END;
    

    And run this block of code:

    declare
    v_tname varchar2(200);
    out_cursor sys_refcursor;
    begin
    forms_text_dyn_sql_test(' 1 = 1 ', out_cursor );
    LOOP
    fetch out_cursor INTO v_tname;
    exit when out_cursor%NOTFOUND;
    DBMS_OUTPUT.PUT_LINE(v_tname);
    END LOOP;
    end;
    /
    

    I get the error:

    [1]: (Error): ORA-00920: invalid relational operator ORA-06512: at "ABS.FORMS_TEXT_DYN_SQL_TEST", line 6 ORA-06512: at line 5
    

    Looks like you can only set column_name =: z, column_name =: values of type y. You can not it seems to replace it with no WHERE CLAUSE?

    A bind variable, such as: it, represents a single value.
    If: is the VARCHAR2 '1 = 1', then

    SELECT tname FROM tab_test WHERE tname LIKE '%ABS_V4%' AND :y
    

    takes the value

    SELECT tname FROM tab_test WHERE tname LIKE '%ABS_V4%' AND '1 = 1'
    

    I think you want something like this:

    CREATE OR REPLACE PROCEDURE FORMS_TEXT_DYN_SQL_TEST
    (     p_where_clause      IN      VARCHAR2
    ,      p_out_cursor      OUT      SYS_REFCURSOR
    ) IS
      v_stmt VARCHAR2(1000);
    BEGIN
      v_stmt := 'SELECT ename FROM scott.emp WHERE ename LIKE ''%A%'' AND '
              || p_where_clause;
    
      OPEN p_out_cursor FOR v_stmt;
    
    END;
    /
    show errors
    
    SET  SERVEROUTPUT  ON
    
    declare
      v_tname varchar2(200);
      out_cursor sys_refcursor;
    begin
      forms_text_dyn_sql_test(' 1 = 1 ', out_cursor );
      LOOP
        fetch out_cursor INTO v_tname;
        exit when out_cursor%NOTFOUND;
        DBMS_OUTPUT.PUT_LINE(v_tname);
      END LOOP;
    end;
    / 
    

    Output:

    ALLEN
    WARD
    MARTIN
    BLAKE
    CLARK
    ADAMS
    JAMES
    
  • Where the photos are stored... How to write on a dvd?

    Where the photos are stored... How to write on a dvd?

    http://www.Macworld.com/article/3015458/software/how-to-share-slideshows-created-in-photos-for-mac.html

    How can I backup my photos in Photos?  Can I use a DVD?

  • HP - 50g written problem complex number. How to write (3 + i * 3 * sqr (3)) to RPN? (3, i3sqr (3))

    Hello everyone, I don't know how to write (i 3, * (3 * sqr (3))) RPN mode.

    Can someone help me please? I already searched the gug pdf guide help, without result.

    Thank you.

    Hello

    A few notes in the representation of a complex number as a vector:

    (1) the i is omitted, the second number is supposed to be the imaginary part.

    (2) the 50 g accepts only decimal numbers for vector representation

    Thus, at the entrance there. I guess you have the calculator in complex mode and exact mode (about not checked in "MODE"-> "SAE"), i.e. "C =" displayed at the top of the screen.

    RPN mode:

    Press 3 then ENTRY (3 is at level 1)

    Press ENTER again (3 is now duplicated and on both levels 1 and 2 - one advantage of RPN)

    Press ENTER again (3 is now duplicated and on levels 1, 2 and 3)

    Press the button of sqrt (x). Level 1 shows a 3 with a sign of the square root.

    Press on multiply key, level 1 shows 3· SQRT (3)

    Press LeftShift (white), then I (above the TOOL key), level 1 indicates an i

    Press on multiply key, level 1 shows 3· SQRT (3)· I have

    Press + key, level 1 shows 3 + 3· SQRT (3)· I have (or 3· SQRT (3)· i + 3 according to the parameter Flag - 27)

    If you want to keep the symbolic result (with the symbol of the 'SQUARE root'), leave it in this form, if you want to convert to vector format press (red) RightShift, then -> NUM (above the ENTER key).

    The result will be a decimal vector shape (3, 5.19615242271).

    Kind regards

    BartdB

  • How to write data in mode intertwined with TDMS C DLL 2.0?

    Hello

    How to write data in mode intertwined with TDMS C DLL 2.0?

    I use DAQmx features in Visual Studio C++ without Measurment Studio.

    This function returns the data in interlaced mode.

    How can I configure the functions of DLL C TDMS to store this data in the tdms files?

    I see that it is not possible with the PDM version 2.0 with 1.0.

    Thank you

    -TDM C Dll is not able to do

    -TDM header writer may be usable for this but is not able to be used for tdms files.

  • Does anyone know of a VI or how to write one that will stop the computers time be disabled if an application is run.

    Does anyone know of a VI or how to write one that will stop the computers clock be turned off if an application is run. The time and date can be reset normally while an application is running by clicking on the time in the lower right of the screen of the computer. I have an application that runs over several days and it is essential that the time and date of the computer not be changed. Is there an easy way of this lockout the user? Note that I am what I consider a beginner advanced in LV

    Thank you

    Chuck

    This isn't something that you can from LabVIEW, because this is an operating system operation, and it will depend on the operating system you are using. Under Windows, you can use Group Policy to control this. Please Google on "prevent changing the date and time of windows."

    Also, please try to refrain from stuffing your message in its entirety in the block of material. Keep short, but descriptive enough topic so we can understand what you're asking basically. Thank you.

  • How to write a unique number in a single Excel cell

    I'm using Labview 2013 SP1 with the Microsoft Report Builder and I can't understand how to write a number of DP to a specific cell in an Excel spreadsheet. I have no problem writing tables of numbers to specific cell ranges, formatting of cells, the writing of titles, using models, everything I need, except the possibility to write a number to a specific cell. All vi who write the numbers seems to require tables 2D for the entries. I must be missing something, but I think I crossed every vi in the palette of MRG and found nothing.

    Any help/examples were greatly appreciated.

    ... and you probably know that the best way to do it is with build table, twice.

    Note the lines is 'thick' goes from left to right.

    Bob Schor

  • How to write a function block?

    Hello

    Someone knows how to write a function block with LabVIEW?  Something like those in real time live > function blocks >.

    Thank you very much in advance?

    Assuming you are referring to these specifically...

    http://www.NI.com/white-paper/7339/en/

    .. then the answer is that it is almost impossible to make a new. However, there is really nothing special all that to their topic. They are essentially normal subVIs (which you can learn about the other links) which just happened to have some terminals connected to shared variables. I personally would not normally recommend that anyway. If you could clarify what exactly you are trying to do, it might be possible to give more specific advice.

  • How to write a single line instead of the entire port?

    Hello

    I followed the example for writing to the digital line as follows

    int taskHandle;

    given int [8];

    char linename [] = "" dev2/port0 / line0:7 ";"

    DAQmxErrChk (DAQmxCreateTask ("", & taskHandle));

    DAQmxErrChk (DAQmxCreateDOChan (taskHandle, linename, "", DAQmx_Val_ChanPerLine));
    DAQmxErrChk (DAQmxStartTask (taskHandle));
    DAQmxErrChk (DAQmxWriteDigitalU8 (taskHandle, 1, 1, 10.0, DAQmx_Val_GroupByChannel, data, NULL, NULL)); Here the data have 8 digits
     
    Error:
    SetWaitCursor (0);
    If (DAQmxFailed (error)) DAQmxGetExtendedErrorInfo (errBuff, 2048);
    If (taskHandle! = 0)
    {
    DAQmxStopTask (taskHandle);
    DAQmxClearTask (taskHandle);
    }
    If (DAQmxFailed (error)) MessagePopup("DAQmx Error", errBuff);

    The example above shows how to write 8 binary to 8 lines, but how to write only one line? I try the following code, but it does not work

    char linename [] = "dev2/port0/line 2;

    ...

    DAQmxErrChk (DAQmxWriteDigitalU8 (taskHandle, 1, 1, 10.0, DAQmx_Val_GroupByChannel, & data [2], NULL, NULL)); Here the data have 8 digits

    The data format for the DAQmxWriteDigitalLines() function will do exactly what you want.

    The data format for the DAQmxWriteDigitalU8() function is a full port (even if you do not have a value of a harbour full of lines in your task).

  • How to write to the system event log

    Windows 7 Home Premium 64-bit Service Pack 1

    I run a daily work to create an image of my drive system hard. Repeatedly the work began and, due to a material error, be abandoned. In some cases (mostly), this will result in the image of yesterday being destroyed, leaving me with no viable image in case I need to restore. Although the reader is old enough (3 years), I'm not want to replace it, because I know no other activity that has had a problem with it and diagnoses reported no problem.

    So I want to execute a batch file or a script before the regular daily system backup operation. The script would go to a SMART short self-test, and if no errors are reported, would signal the backup task to run. Conversely, if the self-test report any error, the script don't trigger not the backup task to run. I think I will need to write an entry in a kind of system event log, which would be defined in the trigger condition in the entrance to the Windows Task Scheduler for the backup task. If anyone can help with the details of how to write an entry to a log of system events?

    Or, perhaps, there is better way to achieve what I want to do?

    I guess that there is not a very high probability that the script will always truly detect a problem and prevent the last image of the destruction. But I tell myself that it is worth the effort.

    TIA

    Assuming that smartctl generates an errorlevel nonzero in case it failed, the following script will work, as long as Smartctl is run under the same account as Casper.

    I also made your script more transparent control setting. The if/then/else/if/then embedded instructions are perfect for computers, but are often misconstructed by the human mind. I'm a big believer in the KISS principle.

    OFF @echo
    FOR %%d Ko (% Date %) Today SET = %% A

    SET now = time %
    echo =.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.
    ECHO% now %%d now %%d %2
    echo"=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.
    Si (« %3 « == » »
    echo of the provided insufficient parameters
    output/b 1
    )

    IF/i %1 is goto short Action
    IF/i %1 is goto long Action
    ECHO 1 Parm [%1] is INVALID
    output/b 1

    : Action
    smartctl t %1 %2
    the echo of SECONDS to WAIT for selftest %3
    choice/n/t %3/d N
    smartctl-l selftest %2%

    Set Flag="%temp%\Smartctl.log".
    If exist % del % % flag flag
    If %ERRORLEVEL% is 0 echo. > Flag %

    For the handshake to work, you must place the CASPER command inside a file of commands as follows:

    off @echo

    If exist c:\Casper\Casper.exe '% temp%\Smartctl.log '.

  • How to write a program that allows an HTTPs connection to the APACHE TOMCAT server in blackberry JDE

    Hello.. I am very new to the blackberry JDE environment. But then, I have a project in which I should write a program that will make an HTTPs connection to the apache tomcat server using blackberry JDE. The simulator which I use is 8330-JDE.

    Here is my code...

    import java.io.IOException;

    Import java.io.InputStream;

    Import javax.microedition.io.Connector;

    Import javax.microedition.io.HttpsConnection;

    Import net.rim.device.api.ui.UiApplication;

    Import net.rim.device.api.ui.container.MainScreen;

    public class Httproto extends UiApplication

    {

    public public static void main (String [] args)

    {

    Httproto instance = new Httproto();

    instance.enterEventDispatcher ();

    }

    public Httproto()

    {

    pushScreen (new HttpsConnectionScreen());

    }

    }

    final class HttpsConnectionScreen extends screen

    {

    public HttpsConnectionScreen()

    {

    HttpsConnection c = null;

    InputStream is = null;

    int rc;

    try {String url =

    "https://192.168.2.3: 8443/cit/j_acegi_security_check? j_username = sanogo & j_password = redhat;

    c = (HttpsConnection) Connector.open (url);

    c.setRequestMethod (HttpsConnection.POST);

    System.out.println ("connection is open with the server");

    Get the response code is open the connection,

    Send the request and read HTTP response headers.

    The headers are stored until asked.

    RC = c.getResponseCode ();

    System.out.println ("response from the server" + rc);

    if (rc! = HttpsConnection.HTTP_OK) {

    throw new IOException ("HTTP response code:" + rc);

    }

    is = c.openInputStream ();

    Get the ContentType

    The string of type = c.getType ();

    The length and process data

    int len = (int) c.getLength ();

    if (len > 0) {

    int actual = 0;

    int BytesRead = 0;

    byte data = new byte[len]; while ((bytesread! = len) & (real! = - 1)) {

    real = is.read (data, bytesread, len - bytesread);

    bytesRead += real;

    }

    } else {}

    int ch;

    while ((ch = is.read (())! = - 1). {

    }

    }

    } catch (ClassCastException e) { throw new IllegalArgumentException ("not a HTTP URL");}

    }

    catch (IOException ioe) {}

    finally {

    Try

    {

    if (is! = null)

    is. Close();

    if (c! = null)

    c.Close ();

    }

    catch (IOException ioe) {}

    }

    }

    }

    When I run this program in the Simulator, I can do nothing. Please correct me if I'm wrong in coding.

    As I am new to this blackberry JDE environment, ideas and suggestions on how to write and run the sample applications in the blackberry are more welcomed.

    Concerning

    Hinduja

    Make sure that your MDS starts when the Simulator starts.  In the JDE will in Edition > Preferences > Simulator > General and click the checkbox "launch Mobile Data System connection with Simulator Service.

Maybe you are looking for