How to write procedure or function or any sql statement for requirement

Hi,
i have a table named letter,it contains 2 columns named as letter_id and letter_content.
select * from letter;
letter_id letter_content
103 Dear MFR
103 This is in regards to the attached DM List
103 Please Credit us after reviewing it.
103 Thanks
103 Regards
103 xxxx
108 Dear customer
108 This is to inform that ur DM List is as follows
108 Credit us according to the Dm after reviewing it.
108 Thanks
108 Regards
108 xxxx
now my requirement is,i need send a parameter as letter_id to a procedure or function in pl/sql in oracle,the output should be as follows:
if we will pass parameter(letter_id) = 103 then it displays as follows:
Dear MFR
This is in regards to the attached DM List.Please Credit us after reviewing it.
Thanks
Regards,
XXXXX.
if we will pass parameter(letter_id) = 108 then it should displays as follows:
Dear customer,
This is to inform that ur DM List is as follows. Credit us according to the Dm after reviewing it.
Thanks
Regards,
XXXXX.
---------------------------------------------------------------------------------------------------------

i am really appriciate ur help.
thank u so much for ur suggestions.
when i am uning line_seq its giving an error
ORA-00904: "LINE_SEQ": invalid identifier
so,in my table i had created a sequense named content_seq.
select * from letter;
content_seq letter_id letter_content
1 103 Dear MFR
2 103 This is in regards to the attached DM List
3 103 Please Credit us after reviewing it.
4 103 Thanks
5 103 Regards
6 103 xxxx
7 108 Dear customer
8 108 This is to inform that ur DM List is as follows
9 108 Credit us according to the Dm after reviewing it.
10 108 Thanks
11 108 Regards
12 108 xxxx
then i had used ur code as follows:
select linefrom ( select content_seq , letter_content || case content_seq when 2 then ' ' || lead(letter_content) over (partition by letter_id order by content_seq) end as line from letter where letter_id = 103 )where content_seq <> 3;
LETTER_CONTENT
Dear MFR
this is in regards to the attached DM List Please credit us after reviewing it
thanks
Regards
EXP
but when i take letter_id = 108 the format is comming different.it was unable to combine 2lines.
Message was edited by:
user579585
Message was edited by:
user579585

Similar Messages

  • How to test procedures and functions of pl/sql

    I am working as a QA basically i got a new assignment of testing functions and procedures, and packeged bodies. Can any one help me in this matter.
    Please help me.
    Hi i am new to oracle I want to test procedures and functions,
    and packaged bodies of pl/sql.

    It depends on what you meant by "testing". I guess you need to check that routines (functions, procedures, packages etc) in valid state and execute without errors. The simpliest way is to get some development tool like TOAD (http://www.quest.com), Oracle Maestro (http://www.sqlmaestro.com) or PL/SQL Developer (http://www.allroundautomations.com). You can connect with them to database and look at the routine state VALID or INVALID. You can recompile them, run and even debug. I guess this should be enough.
    Alternatively you can do same thing from sqlplus. Of course with lesser comfort. You need to write certain SQL statements. For example i want to find invalid procedures:
    SQL> select OBJECT_NAME, OBJECT_TYPE from USER_OBJECTS where STATUS='INVALID';
    To check how procedures work you need to execute anonymous PL/SQL block like this:
    declare
         /* local variables declaration */
         NAME VARCHAR2(4000);
         PRESIDENT_ID NUMBER(38);
         ID NUMBER(38);
    begin
         /* setting up variables */
         NAME:='MICROSOFT';
         PRESIDENT_ID:='BILLY';
         ID:=NULL;
         /* calling routine */
         GEOMETRY.ADD_COMPANY(NAME,PRESIDENT_ID,ID);
    end;

  • How to call a FoxPro .prg file through SQL statement

    I created a program exclusive.prg which basically consisted of the statement USE my table exclusive. How can i call this function through a SQL statement using java

    Hi,
    Thank you for he reply.
    Runtime.getRuntime().exec(..)works fine with .exe files.
    but, when a foxpro program file(.prg) is compiled, a (.fxp) file is produced and not a .exe file
    when i write some thing like
    statement.execute("exclusive.fxp")i'm getting an error. here is the stack trace
    java.sql.SQLException: [Microsoft][ODBC Visual FoxPro Driver]Syntax error or access violation
         at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
         at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
         at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(Unknown Source)
         at sun.jdbc.odbc.JdbcOdbcStatement.execute(Unknown Source)
         at excel.TestMom.main(TestMom.java:28)i also tried using
    statement.execute("do exclusive.fxp") and
    statement.execute("do exclusive.prg")I got the same error.
    Dont know what else to do.Can you please suggest some way to work around.

  • How to write the given query using 'ANY ' operator

    Hi,
    How to write the given query using 'ANY ' operator , I dont need to fetch to grade_master table twice in database, just need to fetch within the result set.
    SELECT dsg_code,dsg_name,dsg_grade FROM designation_master WHERE dsg_orgn='&&Orgn' and dsg_ctry='&&ctry'
    And dsg_loc ='&&loc' And dsg_oru = '&&oru' and dsg_grade in decode('&&radio_group',
    1, SELECT grd_code FROM grade_master WHERE grd_osm_code in (Select grd_osm_code FROM grade_master WHERE grd_orgn='&&Orgn' and grd_ctry='&&ctry' And grd_loc ='&&loc' And grd_oru = '&&oru' and grd_code ='&&emp_grade'),
    2, SELECT grd_code FROM grade_master WHERE grd_osm_code > (Select grd_osm_code FROM grade_master WHERE grd_orgn='&&orgn' and grd_ctry='&&ctry' and grd_loc ='&&loc' And grd_oru = '&&oru' and grd_code),
    3, SELECT grd_code FROM grade_master WHERE grd_osm_code < (Select grd_osm_code FROM grade_master WHERE grd_orgn='&&orgn' and grd_ctry='&&ctry' And grd_loc ='&&loc' And grd_oru = '&&oru' and grd_code ='&&emp_grade'))
    thanks
    rincy

    Hi,
    One thing I understood my your issue is you want to perform, execution of query once or fetch the results sets my minimizing the number of times executions of queries. It would be hard for us to check in this way, atleast provide some temporary data and some business rules. Only I can IN, >, < (queries logical conditons on inner query)
    - Pavan Kumar N
    - ORACLE OCP - 9i/10g
    https://www.oracleinternals.blogspot.com

  • How to write  procedure for creating a row

    Hi
    How to write procedure for creating a new row in data table when button clicked.

    Hi
    I am able to create a row.by writing a method in Application module class.
    method for creating a row in fin_years view:
    public void createRow() {
    Row newRow = (Row)getFinYearsView1().createRow();
    newRow.setNewRowState(Row.STATUS_INITIALIZED);
    //get instance of the above created view object
    ViewObjectImpl vo=getFinYearsView1();
    // to insert row at the end of the table
    vo.insertRowAtRangeIndex(vo.getRangeSize()-1, (Row)newRow);
    System.out.println(getFinYearsView1().getCurrentRowIndex());
    but it doest not create row at last in the data table.Instead it insert row in middle..

  • How to write a file using mod pl/sql

    hi,
    i am having a submit button in my procedure. which should inturn create .sql file in a file path.
    is there any way to create a fileusing htp and htf methods.
    Thanks in advance
    Hari

    >
    i am having a submit button in my procedure. which should in turn create .sql file in a file path.
    is there any way to create a file using htp and htf methods.
    >
    Why are you wasting your time coding from scratch using the PL/SQL Web Toolkit instead of the APEX framework?
    From Re: how to write a file using mod pl/sql it appears that you are not using APEX, so a number of the approaches APEX offers are not relevant. You appear to be looking for a file download solution using the <tt>wpg_docload.download_file</tt> method, such as:
    create or replace procedure download_file (
        p_filename  in     varchar2
      , p_mimetype  in     varchar2
      , p_content   in out nocopy blob)
    is
    begin
      -- Set up HTTP header.
      -- Use "application/octet" as default MIME type.
      owa_util.mime_header(nvl(p_mimetype, 'application/octet'), false);
      -- Set the size so the browser knows how much to download.
      htp.p('Content-length: ' || dbms_lob.getlength(p_content));
      -- Filename will be used as default by the browser in "Save as..."
      htp.p('Content-Disposition: attachment; filename="' || p_filename || '"');
      -- Close header.
      owa_util.http_header_close();
      -- Stream the file content to the browser.
      wpg_docload.download_file(p_content);
    end download_file;

  • Create stored procedure or function of pl/sql in jdeveloper

    How can we create a stored procedure or function of pl/sql in jdeveloper 11.1.2.1.0? And how it will be called? Please help me?
    Edited by: mrs on 4 Jul, 2012 3:07 AM

    I am a beginner to jdeveloper and adf so please give a step by step method for how to create a stored procedure of pl/sql in jdeveloper 11.1.2.1.0

  • I want to block a number from calling and message me but how do i do this is there any app avalible for this

    I want to block a number from calling and message me but how do i do this is there any app avalible for this

    Sadly, as Call Bliss uses the built in Do Not Disturb feature, it requires that your screen be locked in order to function.
    I'm hoping (and have submitted feedback) that Apple will beef up DND to work even when the screen isn't locked.

  • How to use a Sybase table in Oracle SQL statement?

    How to use a Sybase table in Oracle SQL statement?
    Sybase version : 11.9.2.4
    Oracle version : 10.2.05
    Thanks.

    user12088323 wrote:
    How to use a Sybase table in Oracle SQL statement?
    Sybase version : 11.9.2.4
    Oracle version : 10.2.05
    Thanks.Any Oracle client connected to the Oracle database can access Sybase data through the <font style="background-color: #FFFFCC">Database Gateway for Sybase</font> (it requires an additional license) or the <font style="background-color: #FFFFCC">Database gateway for ODBC</font> (it's free).
    The Oracle client and the Oracle database can reside on different machines. The gateway accepts connections only from the Oracle database.
    A connection to the gateway is established through a database link when it is first used in an Oracle session. In this context, a connection refers to the connection between the Oracle database and the gateway. The connection remains established until the Oracle session ends. Another session or user can access the same database link and get a distinct connection to the gateway and Sybase database.
    Database links are active for the duration of a gateway session. If you want to close a database link during a session, you can do so with the ALTER SESSION statement.
    To access the Sybase server, you must create a <font style="background-color: #FFFFCC">database link</font>. A public database link is the most common of database links.
    SQL> CREATE PUBLIC DATABASE LINK dblink CONNECT TO
    2  "user" IDENTIFIED BY "password" USING 'tns_name_entry';
    --dblink is the complete database link name.
    --tns_name_entry specifies the Oracle Net connect descriptor specified in the tnsnames.ora file that identifies the gatewayAfter the database link is created you can verify the connection to the Sybase database, as follows:
    SQL> SELECT * FROM DUAL@dblink;
    Configuring Oracle Database Gateway for Sybase
    <font style="background-color: #FFFFCC">{message:id=10649126}</font>

  • How to get the process id of a sql statement or a session  ....

    How to get the process id of a sql statement or a session . ..?
    Thanks

    What about this?
    SELECT pid
      FROM v$session s, v$process p
    WHERE p.addr = s.paddr
       AND s.sid = :sid;   -- replace :sid with your session idRegards.
    Al

  • HOW do I create a href to an sql statement?

    Answer to query:
    “You sould create a href to an sql statement ( create new user / passwd : and insert in a table (C_user,C_PASSWD), to have a list of users registred at your application)
    A htp page can manage this
    you should create roles that be granted to users,
    1- create &user dientified by &passwd;
    2- create role1....;
    3- grant &role1 to &user1;
    :user will be added by user if he chooses registration href.
    then he must add information in order to continue registration or push OK to confirm registration and let oracle grant previleges to the new user, a trigger can insert the new informations to the user_table_traces.”
    MY QUESTION:
    HOW do I create a href to an sql statement?
    Thank You

    Hello,
    I have an application written in PL/SQL that sits on top of an Oracle database. I want to know how add a password/login feature to the application. In other words the user can go to a certain URL to access and use the application. However when the user clicks on a certain link that is restricted, then the webpage displays fields so that the user has to enter a username and password. In order to access restricted features of the application such as ADD, UPDATE and DELETE.
    Thanks

  • What procedures do you use in your organisation for requirements analysis..

    What procedures do you use in your organisation for requirements analysis, quality management and change control for your custom abap development?
    which process do you think work best for each stage\phase? is there are sap recommended process for each of these phases?
    thanks
    Bijo

    ezzetabi wrote:I was using terminus, but I found it too thin for my tastes (or maybe for my bad eyes...) so I sought around and I read many persons like the Microsoft's Consolas and I have to say that it is indeed very nice. Probably MS should stop doing OSes and start drawings fonts only...
    I never saw this particular font, but I second that, fonts is the only thing MS do well imo
    And so I wondered, what do you use? IMO a terminal font should be, readable, monospaced (doh) and a little thick.
    Of course if you do not use the terminal this post is not for you.
    terminus

  • Single select query or any sql statement with o/p

    Hi,
    I have one table test_tab with column names empno,empname.The test_tab values is as follows,
    empno empname
    01 siva
    02 ram
    03 kamal
    04 sathish
    i will give the empname values like 'siva,kamal,roshan,sathish' and empno >03,but in the table roshan name is not there.I need the below mentioned o/p
    example qry: select empno,empname from test_tab where empname in('siva','kamal','roshan','sathish') and empno>03;
    my o/p should be like this,
    empname empno
    sathish 04
    roshan ''
    But the empname 'roshan' is not there in table.I need the empname as 'roshan' and empno is null value in a single select query or subquery or any sql statements.
    Please help me the resolve this issue.
    Thanks
    Sivaraman

    Hi,
    Do you want this?
    with data as
    (select 1 EMPNO, 'siva' as empname from  DUAL union all
    select 2 EMPNO, 'ram' from  DUAL union all
    select 3 EMPNO, 'kamal' from  DUAL union all
    select 4 EMPNO, 'sathish' from  DUAL union all
    select null EMPNO, 'roshan' from  DUAL )
    select *  from data
    where EMPNAME in ('siva','kamal','roshan','sathish')
       and nvl2(empno,empno,4) > 3 

  • How to monitor/capture SQL statement for an event?

    I want to capture all sql statements for 10 minutes that ran against the database. How should i do that?
    Thanks,
    Dave

    The following document will give u the requred know how.
    http://www.oracle.com/technology/products/manageability/database/pdf/ow05/PS_S001_274001_106-1_FIN_v1.pdf

  • How to reconcile procedure or function in a mapping using OMB Plus?

    HI,
    Could any one please explain, how to reconcile a procedure or function used in a mapping?
    Thank you,
    Regards,
    Gowtham Sen.

    Hi,
    You can only reconcile Inbound (from Procedure to the mapping) :
    OMBRECONCILE PROCEDURE \
    '/[Project_name]/[Module_name]/[Procedure_name]
    TO MAPPING '[Mapping_name]' \
    OPERATOR '[for example name of a Post-Mapping Process in the mapping]' \
    USE (RECONCILE_STRATEGY 'REPLACE', MATCHING_STRATEGY 'MATCH_BY_OBJECT_ID')
    Hope that will help.
    Best Regards
    Samy

Maybe you are looking for

  • MS Office Report problems after compliing (application builder)

    I'm finishing up an application that includes several MS office reports (opens a MS Word template). The template is opened, the bookmarks are filled, then the file is saved (to our internal network) as a .doc file. The New Report.vi is used to open t

  • Error while configuring GCM: The push settings were not saved. Error 400

    Hi, While configuring push settings for google cloud messaging in azure mobile services, i entered the server key received from google developer console. When i try to save the entry, i get the message The push settings were not saved <mobile-servers

  • Oracle equivalent of sql server CLRSplitSting function

    Hello Friends, I have a query in SQL Server - which is getting data . select addl_info_id, sort_seq, code, row_data, addl_info_group_id, group_sort_seq, group_row_data       from dbo.CLRSplitString('2406081,2410381,2427008,2430449,2466981,2495083,158

  • Firefox 19 will not allow computer to shut down

    firefox 19 will not allow computer to shut down I have my computer set to shutdown at 2 pm and at 2 a notice comes up and starts to count down for 10 min. Firefox and thunderbird are still running. at the end of 10 min I get a notice that application

  • Collapsing of sections of a dialog screen

    Hi guys, I have a requirement to develop a dialog with the functionality to expand and collapse certain sections of the screen. An example of this would be transaction ME23N. Can anybody point me in the right direction wrt. classes to be used or wher