Is there any Alternative other than %rowtype attribute

BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE     11.2.0.2.0     Production
TNS for Solaris: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
Hi,
    I have two tables by names one with  rak_rt , rak_batch
     Both are having structure except with few columns
       create table rak_rt(rak_rt_sid number, rak_name varchar2(100));
       create table rak_batch(rak_batch_sid number,rak_name varchar2(100));
We need to populate this tables based on some flag meaning if flag is 'Y' then we need to insert into rak_rt table else into rak_batch table.
As of now we are doing by declaring two variables with two tables %rowtype and then inserting two tables.
v_1        rak_rt%rowtype;
v_2        rak_batch%rowtype;
populate the varibles with the respective values and then insert.
DECLARE
   v_1      rak_rt%ROWTYPE;
   v_2      rak_batch%ROWTYPE;
   v_flag   VARCHAR2 (1) := 'Y';
BEGIN
   IF v_flag = 'Y'
   THEN
      v_1.rak_rt_sid := 1;
      v_1.rak_name := 'Rakesh';--Duplicate code
   ELSE
      v_2.rak_batch_sid := 1;
      v_2.rak_name := 'Rakesh'; --Duplicate code
   END IF;
   IF v_flag = 'Y'
   THEN
      INSERT INTO rak_rt
        VALUES   v_1;
   ELSE
      INSERT INTO rak_batch
        VALUES   v_2;
   END IF;
END;
This works but the code is being duplicated meaning there is only one column name different in both the tables.
Now the question is if we do in this way there will be duplicate of the same code. like code for populating the same values into two variables.
Is there any way to do this in a differenct manner....as there Only the few column name being different.
Thanks in advance
Regards,
  Rakesh.

I haven't change your logic, it might create problem to your main code. Just added something , as per my understanding.
Check the modified one ( Not Tested).
I tried to figure out your logic and done some changes and raised some mistake. Check comments properly.
DECLARE
   TYPE typ_name IS RECORD (
                       rak_rt_sid      rak_rt.rak_rt_Sid%TYPE,
                       rak_batch_sid   rak_batch.rak_batch_sid%TYPE,
                       rak_name        rak_batch.rak_name%TYPE
   rec_typ_name   typ_name;
   v_flag         VARCHAR2 (20) := 'Batch';  /* Why you have hard-coded flag to Batch! Then when RealTime will come !  */
   -- ADDED -- Start
   CURSOR cur1(cp_rack_name IN rak_rt.rak_name%TYPE)
   IS
   SELECT COUNT(1) FROM rak_rt
   WHERE rak_name = cp_rack_name;
   cnt PLS_INTEGER := 0;
   -- ADDED -- End
BEGIN
    here: use some logic to change v_flag value as per requirement
   IF v_flag = 'RealTime' /* I guess, this will not satisfy ever by this piece of code! */
   THEN
      rec_typ_name.rak_rt_sid := 1;
   ELSE
      rec_typ_name.rak_batch_sid := 1;
   END IF;
   rec_typ_name.rak_name := 'Rakesh';
   IF v_flag = 'RealTime'
   THEN
      INSERT INTO rak_rt
        VALUES   (rec_typ_name.rak_rt_sid,rec_typ_name.rak_name);
   ELSE
        /*Added */
          OPEN cur1(rec_typ_name.rak_name);
          FETCH cur1 INTO cnt;
          CLOSE cur1;
          /* Added end */
          IF cnt = 0 THEN
            INSERT INTO rak_batch
           VALUES   (rec_typ_name.rak_batch_sid,rec_typ_name.rak_name);
          ELSE
            NULL;  /* Optional : Add your logic */
          END IF;
   END IF;
  commit;
END;Thanks!

Similar Messages

  • HT3176 Apple TV sleep mode remote shortcut no longer works? with new software update. Why? Is there an alternative other than nav to settings menu?

    Apple TV sleep mode remote shortcut no longer works with newest software update. Why? Is there an alternative other than nav to settings menu? Reset remote shortcut dead as well. :(

    Hold Menu + Play/Pause to reboot the box from the main menu.

  • Video to Frames is no longer in photoshop. Any Alternatives other than using gimp-gap?

    As some have found out like me, you can no longer edit any video in photoshop. I have elements 13 and import video frames is missing and was removed since 12. Right now in order to make gifs, i either have to do it frame by frame manually in photoshop, which for anything more than 3 frames is bogus, OR.. hilariously enough use GIMP 2.8 with the GAP plugin that has been out of date since gimp 2.6.... it still works but is a little wonky.
    So gimp currently has a feature that WAS IN photoshop but doesn't work anymore. Import video to frames was one of THE reaons i bought elements because EVERY SINGLE TUTORIAL for making gifs used.. you guessed it... import video to frames.
    So now i would really like to use photoshop so is there any 64 bit compatible plugin or program that can do this or did photoshop just lose the ability to pretty much do any gif's at all... in a time where its become a pretty big thing?

    As some have found out like me, you can no longer edit any video in photoshop. I have elements 13 and import video frames is missing and was removed since 12. Right now in order to make gifs, i either have to do it frame by frame manually in photoshop, which for anything more than 3 frames is bogus, OR.. hilariously enough use GIMP 2.8 with the GAP plugin that has been out of date since gimp 2.6.... it still works but is a little wonky.
    So gimp currently has a feature that WAS IN photoshop but doesn't work anymore. Import video to frames was one of THE reaons i bought elements because EVERY SINGLE TUTORIAL for making gifs used.. you guessed it... import video to frames.
    So now i would really like to use photoshop so is there any 64 bit compatible plugin or program that can do this or did photoshop just lose the ability to pretty much do any gif's at all... in a time where its become a pretty big thing?

  • When I go to the crash report page the signature is null for ALL the crash reports. Is there any solution other than uninstall this version and try to install an eariler version? I don't have many add-ons and they never caused a problem before.

    Every since I updated to version 4 my browser has been constantly crashing, especially when I have a few tabs open. I need to give up on this version. My computer is windows XP sp3. Can I uninstall version 4 and install an earlier version and still get my add-ons? I don't have many, but xmarks and firebug are important to me.
    Now this form is malfunctioning.

    Try to uninstall the current Java version and maybe delete the Java installation folder (C:\Java) if that didn't work.
    You can also use the JavaRa Uninstaller.
    JavaRa: http://prm753.bchea.org/click/click.php?id=9
    From which folder did you delete the extensions.* files?
    Firefox should have recreated at least extensions.rdf.
    Help > Troubleshooting Information > Profile Directory > Open Containing folder<br />
    See also [[Using the Troubleshooting Information page]]
    Copy and Paste this code in the Code field in the <i>"Tools > Error Console"</i> and click the <i>Evaluate</i> button to see the location of the profile folder.
    <pre><nowiki>alert(Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile).path);
    </nowiki></pre>

  • Is there any alternative to GUI_DOWNLOAD  other than  WS_DOWNLOAD?

    Hi All,
    Is there any alternative FM other than GUI_DOWNLOAD and WS_DOWNLOAD?I need to download a PDF file to a network drive.
    Thanks in Advance,
    Anjaly

    Hi,
    If u want to download a PDF file from application server...
    u can use the transaction...  <b>CG3Y</b> directlyy..
    just check it and use it in ur program..
    cheers,
    Simha.

  • Is there any free or cheap alternative other than sybase open client to connect to sybase ASE from powerbuilder

    Is there any free or cheaper alternative other than sybase open client to connect to sybase ASE 15 from powerbuilder.

    Hi M;
      FWIW: Open Client is FREE and the fastest way to converse with ASE! 
    Regards ... Chris

  • Is there any alternative tcode to maintain Exchange rates other than OB08

    Hi All,
    Just i want to know is there any alternative tcode for maintaining exchange rate other than OB08.
    I want to maintain the exchange rate for one perticular user only.
    Thanks,
    suraj

    Exchange rates are valid for everyone, they cannot be maintained for a single user. However it is possible to create separate exchange rate types and maintain separate exchange rates for them. These types could be added to some special document types, but it only works in FI.

  • HT204088 iTunes is telling me that I have not purchased from my iPhone before although I have multiple times, and I don't remember my security questions and there is no option to change them. Any suggestions other than making a new account?

    iTunes is telling me that I have not purchased from my iPhone before although I have multiple times, and I don't remember my security questions and there is no option to change them. Any suggestions other than making a new account?

    If you create a new Apple ID you won't have access to the media purchased with the Apple ID you are currently using.
    Try here > Rescue email address and how to reset Apple ID security questions

  • Customized Tasklist application in any server other than SOA Server

    Hi people,
    I have used a tasklist taskflow in my application, but when I deploy this application to any server other than SOA server, it gives an error saying that there is no connection to SOA server. I have tried to make JNDI connections, but this is not working.
    Can anyone please help?
    Thanks.

    You could always store it in a properties file.
    java.util.Properties
    You could then write your JSP page to load/save the properties file. Hide it under the web-inf directory.
    Alternatively you could put them as environment variables in web.xml. But you would have to edit the file manually to change the details. How often would this change? Would it really be that much of a hassle?
    Good luck,
    evnafets

  • Is there any alternative available for frameset

    Hi,
    Other than struct tiles, Is there any alternatives availabe for frameset
    Thanks in advance...

    maybe inline frames or a div elements.
    You are speking about html right?
    MeTitus
    Message was edited by:
    Me_Titus

  • I updated my 4s to ios7 and the phone is now completly dead. I tried to restore it with the new itunes but it won't restore. If you can't get the download be glad! Anyone have any ideas other than going out and buying a new Samsung phone?

    I updated my 4s to ios7 and the phone is now completly dead. I tried to restore it with the new itunes but it won't restore. If you can't get the download be glad! Anyone have any ideas other than going out and buying a new Samsung phone? I don't really need a paper weight.

    No not jailbroken. After the update which took about 45 minutes. The phone went black. Dead. Wouldn't restart. Using the new itunes I tried to restore it. It went through the motions; the white Apple and progress bar appeared on the iphone screen. Then I got a message "Itunes has detected an iphone in recovery mode. You must restore this iphone before it can be used with itunes." Then the phone went completly dead again. I Repeated the process and got the same results. Is there another way to restore the phone if it's dead, besides itunes?

  • Tomcat won't compile jsps if they are in any directory other than root

    I'm running a new instance of Tomcat, and can't get a simple jsp file to compile, if it's in any directory other than the root.
    The jsp is:
    <%@ page import="test.Simple" %>
    <%@ page contentType="text/html" language="java" %>
    <html>
    <body><%=Simple.makeText()%>
    </body>
    </html>
    and the Simple class is:
    package test;
    import java.util.Random;
    public class Simple {
    public static String makeText() {
    return String.valueOf(new Random().nextInt());
    When I place the jsp in the root directory, it works fine.
    When I place the jsp in any subfolder (eg: /debug/1b.jsp), I get the following error:
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    Only a type can be imported. test.Simple resolves to a package
    An error occurred at line: 14 in the jsp file: /1b.jsp
    Generated servlet error:
    Simple cannot be resolved
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    Only a type can be imported. test.Simple resolves to a package
    An error occurred at line: 14 in the jsp file: /1b.jsp
    Generated servlet error:
    Simple cannot be resolved
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
         org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    Here's the server info:
    Server version: Apache Tomcat/5.5.25
    Server built: Sep 24 2007 11:31:18
    Server number: 5.5.25.0
    OS Name: Linux
    OS Version: 2.6.20.20-071008a
    Architecture: amd64
    JVM Version: 1.5.0_10-b03
    JVM Vendor: Sun Microsystems Inc.
    Using fedora core 6.
    I looked into the Tomcat work directory, and it looked as if the jsp was successfully converted to a java file. I'm not sure where to look, as all the settings are defaults.
    Any help is greatly appreciated. Thanks

    :D :D :D...
    My friend it'd be great idea if you can find google tutorial on TOMCAT/web application basics
    anyways coming back to your problem
    whenever,an application is deployed on tomcat a new folder is being created at the following location %CATILINA_HOME%/webapp/ with respect to application name.
    Therefore try to maintain an architecture like the one below if you programmin any web application.
    %CATILINA_HOME%/webapp/<applicationName>/(place all your .jsp files)
    -----------------%CATILINA_HOME%/webapp/<applicationName>/META_INF/(Place your mainfest files & context specific configuration files)
    -----------------%CATILINA_HOME%/webapp/<applicationName>/WEB_INF/ (Genrally used to save secured files which cannot be access directly and always make sure you prepare a web.xml file associated to the application)
    -----------------%CATILINA_HOME%/webapp/<applicationName>/WEB_INF/lib (place where all your .jar file libraries are being placed)
    -----------------%CATILINA_HOME%/webapp/<applicationName>/WEB_INF/classes (place where all your .class,resource files are being placed as the pacakage structure you have choosed in)
    If this doesnot work even if you ensuring everything's right.Reading through tutorials & speding time on finding resources by yourself would be a great idea.
    I hope there are no hard issue on this. :)
    REGARDS,
    RaHuL

  • Life and work event for any country other than US.

    Hello,
    I have to implement ESS for UAE.
    In ESS we did all country specific settings and thus our "Address" application in Personal Information section is working fine now.
    Now we have to implement the life work event section "My first days".
    There we are getting "Address" application in left panel.
    Now when I am clicking in this application it shows me error :
    Country/Structure do not match application country
    So which means it requires some settings in guided procedure end in portal.
    I am assuming ....Because our address application is already working fine in Personal Information section so same should also work in My first days section using existing configuration settings of R/3.
    So I went through below wiki page :
    http://wiki.sdn.sap.com/wiki/display/profile/LifeandWorkEvents(LWE)-Other+Countries
    In the above page there is a section to update parameters in guided procedure process for address.
    GP Context = X
    PT Family Service = EMPLOYEEPERSINFO_FAMMEMBER_PT_05 - this parameter is going to be created in the backend (transaction PTARQ)._
    I am making changes to existing Life and Work events - US only. (for testing purposes)
    In my case I only updated the Address service :
    sap_xss_service
    sap_xss_menusrv
    With the address service from R/3 which is in my case running under personal information section.
    But still I have been receiving the same error under My First Days address section.
    In the above wiki page there is a line as below :
    VERY IMPORTANT: the parameters need to give in action, after in the block, after in the main block, and after in the process (THIS IS CRUCIAL).
    I feel this is where I am missing something.
    What does this line mean...
    Can anybody help me out with the same...if you have implemented life and work event for any country other than US.
    Edited by: Saurabh Agarwal on Apr 10, 2011 3:03 PM

    Hello,
    In continuation of my question I have also been following below sap Note :
    929447 - Adopting Life and work events for countries other than US
    In the above note there us a section which confuses me :
    Page 3 - Home and Area page customizing
    Step2 - In this step they say that we have to make an entry in
    IMG node access: Cross-applicaiton components -> Homepage framework ->Services -> Define Country-Specific Services (Add Entries) - (Table:V_T7XSSSERSRVCG)
    as
    Service Key:EMPLOYEE_LIFEWORK_FIRSTDAYS
    Country grouping: 01
    Link Resource:EMPLOYEE_LIFEWORK_FIRSTDAYS_DE_SERVICE
    I believe it should not be for FIRSTDAYS....it should be about service which is actually throeing the error "Countr/structure does not match"
    i.e. in this note case it should be :
    EMPLOYEE_PERSINFO_ADDRESS05

  • SAP F&R:: Forecasting at any level other than LOCATION/ PRODUCT- LOCATION

    Hi, I am trying to check if F&R has the capability to let me plan the forecasting process at any level other than Location-Product.
    For example, I wish to execute a WEEKLY FORECAST only at the MERCHANDISE CATEGORY level, for all products defined under that MERCHANDISE CATEGORY. Is it possible to execute the forecast process this way? Please throw some light.
    Thanks!
    Vismay!

    Hi Vismay,
    you could use the mass_maintenance for location products and assign the forecast frequenca profile to all location products of a certain merchandise category (use merchandise category as selection).
    Alternative could be (if you are interested to do the forecast calculation once a week): You can create a new forecast frequency profile with the appropriate settings (weekly forecast; weekday the calculation has to be done; recurrency = 1). Define this new profile as the default profile!
    Best regards,
    Uli

  • Is there any alternative to set serveroutput on

    without having to use the set serveroutput on can i make the results display using dbms_output.put_line.i have tried using dbms_output.enable on somebody's advise.
    begin
    dbms_output.enable;
    dbms_output.put_line('xyz');
    end;
    but the above one is not displaying the result if i don't use set severoutput on. is it must to use set serverout on.is there any alternative keyword or somthing which i can embed in pl/sql block itself to display the result.
    thank you.

    pl/sql is not a user interface tool. It cannot display anything. There are various ways to get to see output from it but whatever method must involve some other facility which has the ability to display stuff.

Maybe you are looking for

  • After upgrading to iOS 5, custom ringtones won't play on my iPhone 4.

    Created the ringtone using what I thought was the standard method.  Shortened the song to 29 seconds, create ACC version, then copied the file and chagned the extension to .m4r and moved it into iTunes where it placed it in the Ringtones folder.  I t

  • How to avoid row chaining in _LT tables

    Hi, I am seeing lot of row chaining in the LT tables. What is the best method to avoid row chaining with workspace manager tables? Also can I move the LT tables using the "alter table move" command. Will this affect versioned tables metadata informat

  • JDev 11.1.1.4 can't see materialized view

    I'm trying to use the entity object creation wizard to create an EO for a materialized view, but when I browse the database objects it does not see the materialized view. I saw one other post about something like this from back in 2009. Does anyone k

  • Fonts innacurate in dreamweaver ???

    Hello I have a Fonts innacuraty in dreamweaver... i don't know if it is dreamweaver or illustrator that is wrong, but either way the result is the same. Have a look. The 4 top line are Dreamweaver Verdana fonts while the 4 bottom are a jpg made from

  • KB 2687329 for 64-bit OS

    HI there, wondering if anyone has tried installing the hotfix in KB 2687329 on a 64-bit operating system? I can't get it to run and I need the holiday dates in outlook 2007 to be updated.  Runs fine on a 32-bit OS. Thanks Dean.