Querying and Assigning Date Value

Hello, this query is not working. I am trying to assign the date value to the from_date variable.
set result_list [execsql "select TCM_DATE_BEGIN_REQD into: TO_CHAR(from_date, 'YYYY/MM/DD') from tcm_tau_component where tcm_reference_number = $tau_reference_number" ]
This is the error I get:
The following bind variable(s) are not defined:
Please help.

I don't know what language this is but you're trying to select into a format mask. That looks suspicious. Try this:
select TO_CHAR(TCM_DATE_BEGIN_REQD, 'YYYY/MM/DD') into :from_date ...

Similar Messages

  • ALV Report how to display from and to date values in the header.

    I develoeped alv report . i want to display selection screen from and to date values in  top of page...
    any sample code pls guide me..

    You have to do many things...
    first find the selection details using the FM.
    RS_REFRESH_FROM_SELECTOPTIONS
    use the Blog to Align/populate the Header  from the selection table
    /people/community.user/blog/2007/05/07/alignment-of-data-in-top-of-page-in-alv-grid

  • Web Analysis Error -- Error while executing query and retrieving data

    Regarding Web Analysis:
    We have a number of reports that we created. yesterday they were all working fine. today we try to open them and most are generating an error.
    The error is:
    Error while executing query and retrieving data.; nested exception is:
    com.hyperion.ap.APException: [1033] Native:
    1013033[Thu Oct 22 09:08:17
    2009]server name/application name/database name/user name/Error91013033)
    ReportWriter exit abnormally
    Does anyone have any insight into what is going on?
    My version information is:
    Hyperion System 9 BI+ Analytic Administration Services 9.3.0.1.1 Build 2
    Web Analysis 9.3.0.0.0.286
    Thanks in advance for your help.
    DaveW

    Hi,
    And also click on check option by opening the query in Query designer,as Mr . Arun suggested.
    And if you get any error in checking, see the long message(detail).
    With rgds,
    Anil Kumar Sharma .P

  • How to retrieve start and end date values from sharepoint 2013

    Hi,
    How to retrieve start and end date values from new event form of calendar in SharePoint foundation2013
    Thanks
    Gowri Balaguru

    Hi Srini
    Yes i need to have parallel flow for both and in the cube where my reporting will be on monthly basis i need to read these 2 master data and get the required attributes ( considering last/first day of that month as per the requirement).......but i am just wondering this is common scenario....while there are so many threads written for populating 0employee from 0person......don't they have such requirement.....
    Thanks
    Tripple k

  • Bring 2 datas at the same time and assign that value to my item

    Hi everybody, I have a trigger called WHEN-NEW-FORM-INSTANCE where I have the following select: Select to_char(sysdate,'yy') into :mat from dual.
    This select brings me the year from the system, but I would like to put together the year and the consecutive number of another table to have something like this: 09-0001 and add this value to the item called :mat.
    Is this possible?

    You can try what Brown has suggested.
    But in case you want a running number , then sequence might not help.
    What we used to do in this case is, we used to store a number in one seperate table (with other parameters like year, item code and so on), and select the max of this number +1 concatinated with year or whatever format you require.
    And at the end update that number with number+1.
    Say table series has columns
    year month series
    09 01 22
    Now when you select this number series+1 and update in you empid prefixed/suficed with some other field, then do remember to update this field. That means at the end of the transaction the record in this table would be
    09 01 23.
    This is a unique idea and can be utilized for generating ID based on year month series format.
    Just define them in the table and use them accordingly in your code.

  • Is it possible to read the contents of an Excel cell in DIAdem and assign its value to a variable in a VBS script.

    Hi All,
    Initially I thought this little problem would be relatively straight forward but now I’m not so sure. I am familiar with the mechanism by which DIAdem communicates with Excel and how to change the contents of a cell via a VBS script. In my task the contents of the cell in the first row, first column of MyProblem.xls contains the text “DIAdem”. I would like to be able to read this value and assign it to the variable MyString. I originally thought of doing something simple like this:
    Dim MyString
    Dim Excel, ExcelSheet
    Set Excel = CreateObject(“Excel.Application”)
    Excel.Workbooks.Open(“C\MyProblem.xls”)
    Set ExcelSheet = Excel.Workbooks(“MyProblem.xls”).Sheets(“Sheet1”)
    MyString = ExcelSheet.Cells(1,1)
    At this point I would have hoped that MyString would have been set equal to “DIAdem” and I could have used MyString to change the name of a channel in the data portal if I desired using the following code:
    Data.Root.ChannelGroups(1).Channels(1).Name = MyString
    Doesn’t seem to work though. I’m guessing it is because MyString has not picked up the value of the contents of the cell? Can anybody propose a solution to my problem or indeed confirm whether what I am proposing to do is technically feasible.
    Thanks in advance for any responses.
    Matthew

    Hi Matthew,
    Just staring at your ActiveX code, it looks fine to me.  My first thought is that this should work as you outlined it, and I've done this sort of thing many times, so I know it can work.  My second thought though, is that what you probably really want is a DataPlugin and not a VBScript.  Then you could just drag&drop the Excel file into the Data Portal and load all the properties and channels you want from the Excel file.  If you have DIAdem 2010 or later you can use the SpreadSheet reader object in the DataPlugin to avoid the Excel ActiveX functions (and Excel's jealously with other applications trying to read a file it has open already).
    Feel free to send me a few sample Excel files and describe what you want to load from the various cells, and I'd be happy to help you get a DataPlugin written to load your data.  You can also email me at [email protected]
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments

  • Dynamic Structure creation and assigning data.

    Hi,
    I have a structure and a work area,
    DATA: begin of sample_struct,
          elem1 type xxx,
          elem2 type yyy,
          elem3 type zzz,
          end of sample_struct.
    DATA: wa_sample_struct type sample_struct.
    DATA: lr_rtti_struc TYPE REF TO cl_abap_structdescr.
    DATA: lt_comp       TYPE cl_abap_structdescr=>component_table.
    DATA: ls_comp       LIKE LINE OF lt_comp.
    DATA: l_index       TYPE string.
    DATA: lr_data       TYPE REF TO data.
    DATA: lr_table      TYPE REF TO
    I create a new structure at run time extending the sample_struct to add few more components at run time like this.
    lr_rtti_struc ?= cl_abap_structdescr=>describe_by_data(wa_sample_struct).
        lt_comp = lr_rtti_struc->get_components( ).
    do 10 times.
          l_index = sy-index
          concatename 'element' l_index into ls_comp-name
          ls_comp-type = cl_abap_elemdescr=>get_string( ).
          APPEND ls_comp TO lt_comp.
    enddo.
    Then i create a work area of this new structure like this.
    lr_rtti_struc = cl_abap_structdescr=>create( p_components = lt_comp ).
        CREATE DATA lr_data TYPE HANDLE lr_rtti_struc.
        ASSIGN lr_data->* TO <fs_data>.
    Now <fs_data> is a work area for the structure.
    I can move the data in wa_sample_struct into <fs_data> like this.
    move-corresponding wa_sample_struct to <fs_data>.
    My problem is how do i access the dynamic components of this work area so that i can assign data to those components.
    If anybody knows how to access the dynamically added components of <fs_data> so that I can assgin data to those.
    Thanks in advance
    Sesh
    Message was edited by: Seshatalpasai Madala

    Hi,
          Looks like the problem is not well stated as I am getting answers which are not relevent.
    My existing structure.
    DATA: begin of sample_struct,
    elem1 type xxx,
    elem2 type yyy,
    elem3 type zzz,
    end of sample_struct.
    I create a new structure using this structure at runtime by adding new fields which are in a internal table. I add the new fields as follows.
    loop at it_tab into wa_tab.
    ls_comp-name = wa_tab.
    ls_comp-type = cl_abap_elemdescr=>get_string( ).
    APPEND ls_comp TO lt_comp.
    endloop.
    This internal table is built using the user input. So I dont know how many and what are the values in the internal table.
    LT_COMP has the existing structure field's as well as the newly added fields for my new structure.
    I create a new structure using this component list LT_COMP.
    DATA: lr_rtti_struc TYPE REF TO cl_abap_structdescr.
    lr_rtti_struc = cl_abap_structdescr=>create( p_components = lt_comp ).
    Now I have an object of cl_abap_structdescr. Which I can use as a data type for defining Workarea and internal table of this structure like this.
    CREATE DATA lr_data TYPE HANDLE lr_rtti_struc.
    ASSIGN lr_data->* TO <fs_data>.
    I can access all the existing fields of the strucutre like this.
    <fs_data>-elem1
    <fs_data>-elem2
    My problem is how do i access the newly added fields of the strucutre as I dont know the names of the fileds(I know them only at runtime).
    I hope I have explained it well enough, hope to see a relevent answer for the above problem.
    Thanks in advance.
    Sesh

  • How to Create a View of a Query and assign it into my web template?

    Hi All,
    I need to create 3 views for my query and show that on my web template. I have never done this before. Can you please let me know step-by step procedure to create views for a query and how to show it on my WAD report?
    Thanks,
    Satyam

    Hi Satyam,
    Include the Dropdown Box web item in your web template. In the Web Item Parameters tab, select the Data Binding type as Query View Selection. Assign the Dataprovider from Selection of Query Views button below the Data Binding Type. You also have the option to Display Specific list of Query Views or all views based on that Query. For this you have to choose Selection of Query Views button. Here you can turn on Specific List of Query Views checkbox and select the Views depending on your requirement.
    Regards,
    Hari.
    Edited by: Hari Krishnan K on Aug 18, 2010 2:33 PM

  • Jsp:useBean and assigning a value to that bean

    Hello,
    I have a type called Country and I have declared a bean using the "jsp:useBean" syntax.
    I then try to assign a value to that bean in a scriptlet. Eventually I try to retrieve the values using "jsp:getProperty". The problem is that it appears to null.
    Here is the code of the jsp
    <%@ page language="java" %>
    <%@ page import="com.parispano.latinamericaguide.*" %>
    <%
    /* We retrieve the Countries object from the servlet context. */
    ServletContext sc = getServletContext();
    Countries cs = (Countries)sc.getAttribute("countries");
    %>
    <jsp:useBean id="country" class="com.parispano.latinamericaguide.Country"/>
    <%
    /* If the request contains a country id, then we set the variable. */
    country = cs.getCountryFromId(Integer.parseInt(request.getParameter("countryID")));
    %>
    <html>
    <head>
    <title>Country details</title>
    </head>
    <body>
    <table>
    <tr><td>Name</td><td><jsp:getProperty name="country" property="name"/><!-- This is not working--></td></tr>
    <table>
    <%
    out.println(country.getName());//This is working
    %>
    </body>
    </html>This is the code for the bean
    package com.parispano.latinamericaguide;
    * @author Julien Martin
    * Represents a country.
    public class Country implements Comparable {
         private int id;
         private String name;
         private int landArea;
         private String capital;
         private String currency;
         private String flag;
         private String internet_domain;
         private String dialling_code;
         private float literacy;
         private float male_life_expectancy;
         private float female_life_expectancy;
         private String map;
         private int population;
         private int population_year;
         private float birth_rate;
         private int birth_rate_year;
         private float death_rate;
         private int death_rate_year;
         private int gdp;
         private int gdp_per_head;
         private int gdp_year;
         private float unemployment_rate;
         private int unemployment_rate_year;
         public Country() {
         public Country(
              int id,
              String name,
              int landArea,
              String capital,
              String currency,
              String flag,
              String internet_domain,
              String dialling_code,
              float literacy,
              float male_life_expectancy,
              float female_life_expectancy,
              String map,
              int population,
              int population_year,
              float birth_rate,
              int birth_rate_year,
              float death_rate,
              int death_year_rate,
              int gdp,
              int gdp_year,
              float unemployment_rate,
              int unemployment_rate_year) {
              this.id = id;
              this.name = name;
              this.landArea = landArea;
              this.capital = capital;
              this.currency = currency;
              this.flag = flag;
              this.internet_domain = internet_domain;
              this.dialling_code = dialling_code;
              this.literacy = literacy;
              this.male_life_expectancy = male_life_expectancy;
              this.female_life_expectancy = female_life_expectancy;
              this.map = map;
              this.population = population;
              this.population_year = population_year;
              this.birth_rate = birth_rate;
              this.birth_rate_year = birth_rate_year;
              this.death_rate = death_rate;
              this.death_rate_year = death_year_rate;
              this.gdp = gdp;
              this.gdp_year = gdp_year;
              this.unemployment_rate = unemployment_rate;
              this.unemployment_rate_year = unemployment_rate_year;
         public float getBirth_rate() {
              return birth_rate;
         public int getBirth_rate_year() {
              return birth_rate_year;
         public String getCapital() {
              return capital;
         public String getCurrency() {
              return currency;
         public float getDeath_rate() {
              return death_rate;
         public int getDeath_rate_year() {
              return death_rate_year;
         public String getDialling_code() {
              return dialling_code;
         public float getFemale_life_expectancy() {
              return female_life_expectancy;
         public String getFlag() {
              return flag;
         public int getGdp() {
              return gdp;
         public int getGdp_per_head() {
              return gdp / population;
         public int getGdp_year() {
              return gdp_year;
         public int getId() {
              return id;
         public String getInternet_domain() {
              return internet_domain;
         public float getLiteracy() {
              return literacy;
         public float getMale_life_expectancy() {
              return male_life_expectancy;
         public String getMap() {
              return map;
         public String getName() {
              return name;
         public int getPopulation() {
              return population;
         public int getPopulation_year() {
              return population_year;
         public int getLandArea() {
              return landArea;
         public float getUnemployment_rate() {
              return unemployment_rate;
         public int getUnemployment_rate_year() {
              return unemployment_rate_year;
         public void setBirth_rate(float f) {
              birth_rate = f;
         public void setBirth_rate_year(int i) {
              birth_rate_year = i;
         public void setCapital(String string) {
              capital = string;
         public void setCurrency(String string) {
              currency = string;
         public void setDeath_rate(float f) {
              death_rate = f;
         public void setDeath_rate_year(int i) {
              death_rate_year = i;
         public void setDialling_code(String string) {
              dialling_code = string;
         public void setFemale_life_expectancy(float f) {
              female_life_expectancy = f;
         public void setFlag(String string) {
              flag = string;
         public void setGdp(int i) {
              gdp = i;
         public void setGdp_per_head(int i) {
              gdp_per_head = gdp/population;
         public void setGdp_year(int i) {
              gdp_year = i;
         public void setId(int i) {
              id = i;
         public void setInternet_domain(String string) {
              internet_domain = string;
         public void setLiteracy(float f) {
              literacy = f;
         public void setMale_life_expectancy(float f) {
              male_life_expectancy = f;
         public void setMap(String string) {
              map = string;
         public void setName(String string) {
              name = string;
         public void setPopulation(int i) {
              population = i;
         public void setPopulation_year(int i) {
              population_year = i;
         public void setlandArea(int i) {
              landArea = i;
         public void setUnemployement_rate(float f) {
              unemployment_rate = f;
         public void setUnemployment_rate_year(int i) {
              unemployment_rate_year = i;
         public String toString() {
              return name;
         public int compareTo(Object o) {
              Country c = (Country)o;
              int cmp = name.compareTo(c.name);
              System.out.println(cmp);
              return cmp;
    }Can anyone please help?
    Thanks in advance,
    Julien.

    Thanks,
    I have added scope="application". It still show "null" indicating that the bean is not initialized with the properties. I would like a quicker way to initialize a bean property than invoking the setProperty tag for each property.
    Here is a simple example that demonstrates the problem:
    <%@ page language="java" %>
    <%@ page import="com.tests.*" %>
    <jsp:useBean id="monBean" class="com.tests.MonBean" scope="application"/>
    <%
    MonBean mb = new MonBean();
    mb.setName("toto");
    monBean= mb;
    %>
    <html>
    <head>
    <title>Lomboz JSP</title>
    </head>
    <body bgcolor="#FFFFFF">
    <jsp:getProperty name="monBean" property="name"/>
    </body>
    </html>And the bean
    package com.tests;
    public class MonBean {
    private String name;
    public String getName() {
         return name;
    public void setName(String name) {
         this.name = name;
    }This show "null".
    Any other idea why this is not working?
    Thanks,
    Julien

  • Transfer Rule Routine: Assign Date Value into Blank Field

    Can anyone help me with regards to writing some ABAP code in a transfer rule so that I can assign "99991231" value into a date characteristics if it is blank?
    Many thanks for advance.

    I would like to check if the value of EXPIRYDATE is blank in data source. If its value is blank, assign '99991231' to it. Otherwise, it will get the value of EXPIRYDATE in transfer rule. I have rewritten the routine as follows. But there is no effects on the result.
    if TRAN_STRUCTURE-EXPIRYDATE IS INITIAL.
      RESULT = '99991231'.
    else.
      RESULT = TRAN_STRUCTURE-EXPIRYDATE.
    endif.
    Many thanks in advance.

  • Union two query and get a value

    hello...i am new in programming..need some help..i have one union query like this..
    select tb_user.userid,
    NVL((SUM(TB_class.time)),0) AS day
    FROM tb_user, TB_class, TB_classcon, TB_DETAIL, TB_partner, tbl_department
    where TB_classcon.userid = tb_user.userid
    AND TB_classcon.IDDETAIL = TB_DETAIL.IDDETAIL
    AND TB_DETAIL.IDpartner = TB_partner.IDpartner
    AND TB_partner.code = TB_class.code
    and tbl_department.deptcode = tb_user.deptcode
    and tb_user.deptcode='70'
    AND to_char(TB_DETAIL.statdate,'YYYY') = 2011
    AND TB_classcon.STATUS = 'come'
    group by tb_user.userid
    UNION
    select tb_user.userid,
    (SELECT NVL((SUM(TB_KURBAH.time)),0) FROM TB_KURBAH WHERE TB_KURBAH.IDSTAF = tb_user.userid) AS day
    FROM tb_user, TB_class, TB_classcon, TB_DETAIL, TB_partner, tbl_department,TB_KURBAH
    where TB_KURBAH.userid != tb_user.userid
    AND TB_classcon.IDDETAIL = TB_DETAIL.IDDETAIL
    AND TB_DETAIL.IDpartner = TB_partner.IDpartner
    AND TB_partner.code = TB_class.code
    and tbl_department.deptcode = tb_user.deptcode
    and tb_user.deptcode='70'
    AND to_char(TB_DETAIL.statdate,'YYYY') = 2011
    AND TB_classcon.STATUS = 'come'
    group by tb_user.userid
    Result
    userid day
    33478 5
    33478 6
    33500 8
    33655 3
    34260 0
    34260 2
    Query 1 result
    userid day
    33478 6
    34260 2
    Query 2 result
    userid day
    33655 3
    33478 5
    33500 8
    34260 0
    But i need help to get result like this..
    userid day
    33478 11 (6+5)
    33500 8 (0+8)
    33655 3 (0+3)
    34260 2 (2+0)
    help me plz...tq..

    select userid, sum(day)
    from
    select tb_user.userid,
    NVL((SUM(TB_class.time)),0) AS day
    FROM tb_user, TB_class, TB_classcon, TB_DETAIL, TB_partner, tbl_department
    where TB_classcon.userid = tb_user.userid
    AND TB_classcon.IDDETAIL = TB_DETAIL.IDDETAIL
    AND TB_DETAIL.IDpartner = TB_partner.IDpartner
    AND TB_partner.code = TB_class.code
    and tbl_department.deptcode = tb_user.deptcode
    and tb_user.deptcode='70'
    AND to_char(TB_DETAIL.statdate,'YYYY') = 2011
    AND TB_classcon.STATUS = 'come'
    group by tb_user.userid
    UNION ALL
    select tb_user.userid,
    (SELECT NVL((SUM(TB_KURBAH.time)),0) FROM TB_KURBAH WHERE TB_KURBAH.IDSTAF = tb_user.userid) AS day
    FROM tb_user, TB_class, TB_classcon, TB_DETAIL, TB_partner, tbl_department,TB_KURBAH
    where TB_KURBAH.userid != tb_user.userid
    AND TB_classcon.IDDETAIL = TB_DETAIL.IDDETAIL
    AND TB_DETAIL.IDpartner = TB_partner.IDpartner
    AND TB_partner.code = TB_class.code
    and tbl_department.deptcode = tb_user.deptcode
    and tb_user.deptcode='70'
    AND to_char(TB_DETAIL.statdate,'YYYY') = 2011
    AND TB_classcon.STATUS = 'come'
    group by tb_user.userid
    group by userid;Edited by: hm on 08.11.2011 23:17
    Please use "UNION ALL" in this case!
    (Otherwise duplicates will be removed in union query and it would fail if days would be the same in both queries)

  • Different results for the same query and same data !  (oracle 9i)

    Hi,
    This is a mystery for me. I've got on my database exactly the same data that my customer (exported schema). We both launch the same query (generated by the software that we sold him). This query has a criteria IN (SELECT MAX()...) to get only data from the last year.
    The query gives 477 rows on my computer (correct answer), but no row on his! We have the same data! The only difference is the Oracle release : 9.2.0.6.0 for him, 9.2.0.1.0 for me.
    If he executes the subquery alone, it gives the expected result.
    If he replaces the MAX() in the subquery by the returned value (year 2016), he gets his 477 rows.
    I've rewritten the query with a NOT EXISTS, and now all is fine. (Less efficient but it works).
    I have no rational explication. Did I miss something ?
    Thanks for any answer.
    This is the query:
    SELECT ...
    FROM
    CRA, GRA, ...
    WHERE
    /* subselect */
    (CRA.COLLCOD, CRA.CRANEXE, CRA.CRANCODBUD, CRA.GRANNUM, CRA.CRANCOD1, CRA.CRANCOD2, CRA.CRANCOD3, CRA.CRANCOD4)
    IN (
    SELECT b.COLLCOD, MAX(cranexe), b.CRANCODBUD, b.GRANNUM, b.CRANCOD1, b.CRANCOD2, b.CRANCOD3, b.CRANCOD4
    FROM CRA b
    GROUP BY b.COLLCOD, b.CRANCODBUD, b.GRANNUM, b.CRANCOD1, b.CRANCOD2, b.CRANCOD3, b.CRANCOD4
    AND... /* other filters and joins */

    v9.2.0.1 was full of bugs. a lot of these bugs had to do with "incorrect results", typically associated with old stats or complex queries (certain types of subqueries were very likely to give wrong resutls, due to the way they were rewritten by the optimizer).
    apply the 9.2.0.6 patch set

  • Query says master data value is invalid in selection screen.

    Hi,
    I am experiencing an issue that is occurring across many reports in our BW QA system, not just one. My InfoProvider clearly contains data with plant = US33. However, when I run the report and in the selection screen I enter US33 I get the error message saying that the value US33 is invalid.
    If I open the selection box, it even shows US33 as an available option (selections are restricted to values in the infoprovider), but again if I select US33 and click ok I get the same error message saying that the value US33 is invalid.
    If I run the report open the report returns records with plant = US33. However, if I try to filter on plant US33 in the report it returns no data.
    US33 is available in the 0PLANT master data and yes the data is active. I even tried modifying this record and saving it and that didn't work. I also tried reloading the data and still nothing.
    I also tried running tests in RSRT on the 0PLANT master data but there are no errors.
    I can query data in the infoprovider successfully when I select plant = US33 in the BW.
    I suspect that since this is occurring across multiple reports that report off of different infoproviders, that this is a master data or system issue but I can't solve it.
    Please advise.
    Thanks,
    Anthony

    what is the length of 0plant .
    it should be 4 characters with lower case on.
    ensure cases are same in 0plant and report selection screen if lowercase is allowed in plant data.
    if it still gives your problem try to create a new variable on 0plant and use it.
    revert back nothing works..

  • Splitting string separated by commas into words and assigning numerical values

    Project details :
    I have a project where a description field is being looked at and based on the values (multiple words) I have to do a vlookup from another spreadsheet to get the dates from the appropriate date fields.
    I have created a user defined function to extract keywords from a list from a table. It extracts words from the string separated by comma delimiter.
        I am thinking of assigning values something like this: cooler = 1, compressor = 2, frame = 2, change of order = b etc.
        So if there is a “cooler, compressor, frame, change of order” in the cell, then it should read as: b12 (unique values). Based on the values, I can do a vlookup on the dates. I tried sumproduct in conjuction with search function but did not
    work. Tried split function but did not quite work.
    Any help regarding this is greatly appreciated. Thank you, regards
    keywords
    engine, compressor, frame, cooler     =Keywords(Wordlist,A2) is the function I am calling
    frame, cooler
    engine, cooler, change order
    cooler

    Hi,
    You're asking this question in the wrong forum, this is a PowerShell forum.
    The Excel VBA forum is this way:
    http://social.msdn.microsoft.com/Forums/en-us/home?forum=exceldev&filter=alltypes&sort=lastpostdesc
    Side note to whoever voted up the OP - why??
    Don't retire TechNet! -
    (Don't give up yet - 12,950+ strong and growing)

  • Regarding "select into" query and "no data found" exception

    So i have included the following into my procedure:
    select div_cd into c_div_cd
                   from division_tab d, emp_tab y
                   where d.div_name=y.div_text and y.emp_code=d.emp_code;
    and also an exception
    exception
    when no data found
    -- print something
    The above select query results into "no data found" and the control passes directly to the exception and prints something.
    How do I do the following?
    select div_cd into c_div_cd
                   from division_tab d, emp_tab y
                   where d.div_name=y.div_text and y.emp_code=d.emp_code;
    if c_div_cd is null then
    --enter this employee into some other table without raising an exception
    No need to write a code for an answer. Please just guide me with something I can incorporate or do.

    use explicit cursors
    DECLARE
    c_div_cd division_tab.div_cd%type;
    cursor c_div is
    select div_cd
    from division_tab d, emp_tab y
    where d.div_name=y.div_text and y.emp_code=d.emp_code;
    BEGIN
    open c_div;
    fetch c_div into c_div_cd;
    --You can either use c_div%NOTFOUND or c_div_cd is null in the below if condition to check the data
    -- Note if your select query returns multiple records then you have to do mutiple fetches for getting all records, so in that case your FETCH
    -- should be inside the LOOP statement
    if c_div_cd is null then
    --enter this employee into some other table without raising an exception
    end if;
    close c_div;
    EXCEPTION
    IF c_div%ISOPEN then
    close c_div;
    END IF;
    END;
    Regards
    JJ

Maybe you are looking for