Better method of coding.

In my program i have to take the name of the first record and store it in a variable.I am using this value down in my program. I am simulating the scenario with an
example
declare
vname emp.ename%type;
begin
select * from
(select ename into vname from emp where deptno in(10,20) and rownum =1)
dbms_output.put_line (vname);
end;
ERROR at line 6:
ORA-06550: line 5, column 15:
PL/SQL: ORA-01744: inappropriate INTO
ORA-06550: line 4, column 1:
PL/SQL: SQL Statement ignored
So i modified the code like this..
declare
vname emp.ename%type;
begin
for emprec in(select * from
(select ename from emp where deptno in(10,20) and rownum =1))
loop
vname:=emprec.ename;
end loop;
dbms_output.put_line (vname);
end;
Is there any better method of doing this?

declare
vname emp.ename%type;
begin
select ename into vname from emp where deptno in(10,20) and rownum =1;
dbms_output.put_line (vname);
end;

Similar Messages

  • I want to transfer my iPhoto from my old MacBook Pro to my new MacBook Pro. I have a firewire or I could also do it from my TimeCapsule. Would one be a better method than the other?

    I want to transfer my iPhoto from my old MacBook Pro to my new MacBook Pro. I have a firewire or I could also do it from my TimeCapsule. Would one be a better method than the other?

    Hi brotherbrown,
    A direct FireWire transfer (especially if it's 800 to 800) is going to be the fastest method. TimeCapsule would work, if you connect to it via Ethernet, via wireless it would be quite slow (especially if you have a large library).

  • Better method to search

    Hallo,
    the user want to habe a better method for searching.
    Example: 0customer. They want to have the change to search for M....er and geht all results like
    Maier, Meier, Mayer etc..... ist this possible.
    Thanks
    Santra

    Santra,
    M*er and then press F4...
    It doesn't work ?
    Bye,
    Roberto

  • A better method?

    Hi, I use Forte for Java development. I tried to define a menu with some items having icons but not other. How can I align vertically the menu_item_text from a popup composed from both icon and non icon menu items? For now I'am thinking to add an empty icon to the non icon items. Is there any better method?
    thanx

    Hi, I use Forte for Java development. I tried to define a menu with some items having icons but not other. How can I align vertically the menu_item_text from a popup composed from both icon and non icon menu items? For now I'am thinking to add an empty icon to the non icon items. Is there any better method?
    thanx

  • Lock and semaphore, what's better method for my case

    Hi all,
    I'm implementing a classic case: a consumption queue with infinite capacity. That's say I have a queue of infinity capacity, a thread to put objects into the queue, another thread take it out. Pseudo code is smth like below:
    void put(Object o) {
    put message into the queue
    if (consume thread is waiting) {
    lock();
    signal();
    unlock();
    void eat() {
    if (queue not empty)
    take object out;
    else
    lock;
    wait for signal from producer;
    wake up and take object out;
    unlock;
    I don't know if I should use semaphore or Lock interface to get the job done. Do you know which one is better in my case? I'm writing an apps which is very sensitive in latency so basically I want the eater to get the object as soon as possible. Any advices?
    Message was edited by:
    principles

    Blocking queue doesn't work for me as it is too slow.
    I don't need to lock the data because one thread
    adds too the tail, one thread consumes the head, so
    why bother?LinkedBlockingQueue allows concurrent access to the head and tail ie it uses two different locks.
    A Lock is a mechanism for mutual exclusion. It generally has a notion of ownership and so the thread that locks must be the thread that unlocks.
    A Semaphore is a resource counter. There are no constraints on which thread signals() after await(). It is only a protocol that you establish in your code that allows it to be used for exclusion.
    A bounded-buffer generally needs two synchronization aids:
    a) an exclusion control to ensure the data structure is not corrupted by concurrent access
    b) a coordination control to allow consumers to block when the buffer is empty, or producers to block when the buffer is full.
    These two can be combined by using "synchronized" methods and wait/notify. Or by using Lock and associated Condition objects. Or you can use "synchronized" blocks or Lock for exclusion, and handle the coordination using a seperate semaphore (which must use some form of internal synchronization too - but perhaps more efficient.)
    If you have a lock-free data structure, such as ConcurrentLinkedQueue then you don't need anything for (a) and so you only need coordination. So try using a Semaphore: put() increments it and take() decrements it.
    But the Semaphore still becomes a serialization point in your code.

  • Better method than switch?

    I have the following code.
    public Animalinfo(int animalInfo){
            switch (animalInfo) {
                case 1:File inputFile1 = new File("monkey.txt"); FileInputAnimal monkey = new FileInputAnimal(inputFile1);break ;
                case 2:File inputFile2 = new File("rooster.txt"); FileInputAnimal rooster = new FileInputAnimal(inputFile2);break ;
                case 3:File inputFile3 = new File("dog.txt"); FileInputAnimal dog = new FileInputAnimal(inputFile3);break ;
                case 4:File inputFile4 = new File("boar.txt"); FileInputAnimal boar = new FileInputAnimal(inputFile4);break ;
                case 5:File inputFile5 = new File("rat.txt"); FileInputAnimal rat = new FileInputAnimal(inputFile5);break ;
                case 6:File inputFile6 = new File("ox.txt"); FileInputAnimal ox = new FileInputAnimal(inputFile6);break ;
                case 7:File inputFile7 = new File("tiger.txt"); FileInputAnimal tiger = new FileInputAnimal(inputFile7);break ;
                case 8:File inputFile8 = new File("rabbit.txt"); FileInputAnimal rabbit = new FileInputAnimal(inputFile8);break ;
                case 9:File inputFile9 = new File("dragon.txt"); FileInputAnimal dragon = new FileInputAnimal(inputFile9);break ;
                case 10:File inputFile10 = new File("snake.txt"); FileInputAnimal snake = new FileInputAnimal(inputFile10);break ;
                case 11:File inputFile11 = new File("horse.txt"); FileInputAnimal horse = new FileInputAnimal(inputFile11);break ;
                case 12:File inputFile12 = new File("sheep.txt"); FileInputAnimal sheep = new FileInputAnimal(inputFile12);break ;
    //where fileinputanimal prints the text file in the window
            }It works and i can't see much else to addto it. But i was just wondering if anyone had other possible improvements on it, like a way of not adding a number to the end of each File inputFilex. Also, is there an alternate method to switce. I can't think of any myself, but that means i'll have to start working on a switch like above but containing around 500 cases in it this time.
    Any suggestions appreciated.

    Sazazezer_Mililipili wrote:
    Jeez, so much help in fifteen minutes alone. I feel bad for taking a day to respond.
    The animalInfo int comes from the user input. The user types in their date of birth. It then converts to a float so i can do 'year % 12', Okay, that makes sense. But an int would be better.
    Now...to learn about maps.Nah, since it's always going to be 0-11, and it's the numerical value that has significance, not some arbitrary "key", it's simpler to just stick with the switch statement. Do pay attention to the simplifications I gave you though, and rather than having the constructor do anything besides initialize the state of an object, after construction, call a print or display or whatever method.
    EDIT: Or, possibly better, go with the other poster's suggestion of an array of Strings, whose values are the file names.
    Edited by: jverd on Sep 25, 2008 2:15 PM

  • Better method than using a large number of shift registers?

    I'm trying to work with example code provided free by stanford research systems (http://www.srsys.com/downloads/soft.htm).
    Their example software alows the user to run an analog scan across 100 masses (the x axis) which progressively produces a graph of all the data. It repeats scanning (and updating the graph)until the user hits stop.
    My goal is to find a way to make the program display the graph of the last scan while it is displaying the current scan (this way it is possible to compare the graphs and see how they change). But as best I can tell the data is generated and plotted in a while loop piece by piece so the best thing my labview inept mind has managed so far is using a large nu
    mber of shift registers and graphing the points as they generated along with points that were generated 10 cycles ago in a different color.
    So I hope to either find a good way to use shift registers to get values from over 100 cycles ago (which doesn't really seem to work unless i just make space for over 100 little arrows in my loop) or to find a better approach to the whole mess.
    The example does not seem to use XY plot and to tell the truth I don't know exactly what its using to plot.
    Can anyone offer any guidance or at least understand my question enough to point me in the right direction.
    I'm including the stock example and my adaptation to it but if you need to use the included sub vi's the package is on that SRS webpage I listed above (look under RGA).
    I suppose this may all be too much to ask but I can dream can't I?
    Attachments:
    original.vi ‏87 KB
    changed.vi ‏92 KB

    I certainly agree that the DAQ programming is the part leaving me most confused. I'll attach the package that I am trying to modify, the trouble is there are so many sub vis involved in actually acquiring the data that I am not entirely sure what format the data comes out in.
    Perhaps to someone more skilled than I am with lab view the inner workings of this package would be clearer. If you are up for it then look at SRSRGAa simple analog.vi in SRSRGA61.lib and you can see what I'm working with.
    I'll also attach my attempt to modify the code to make it work like altenbachs example... however somehow it would seem my timing/synchronization is off. Hope some of this makes sense, I'll see what luck I can have with get w
    aveform components, I suppose I have been approaching this so far as if my DAQ was just giving me data points as opposed to a waveform.
    Attachments:
    rga_lv_61.zip ‏2132 KB
    graph_app.1.vi ‏101 KB

  • Better method for newspaper editing

    I've been able to make some news articles and export them to PDF with pleasing results and have been improving my efficiency with each completed document, but feel that there is a better way of doing it still.  Basically, what I'm making are articles that have about two to three images embedded in each article, and have maybe two to three jump lines which redirect the reader to other pages. 
    I have about 35 articles total.  Is there a way to enter them all into InDesign, add appropriate images and captions to the articles, and add appropriate jump lines (if there's a way to add meta data to each article and specify a "jump line title" variable that will automatically fill in before "Next Page Number" / "Previous Page Number")?  So that way, I can pick and choose which articles to add to each newsletter volume instead of undertaking the laborious task of adding an article and having to manually edit every component.
    Thx!

    Hey, it sounds like you could use Section Markers. If you name your pages (assuming each article starts on a new page) you can have the section names be filled in automatically. Take at the document numbering options for more information on this: http://help.adobe.com/en_US/indesign/cs/using/WSa285fff53dea4f8617383751001ea8cb3f-7111a.h tml
    Your jump box could look like this: "[SectionMarker] continued on [NextPageNumber]"
    Let me know if you still need help.

  • Which is better kind of coding

    is it better to use types rather than data in Internal tabe declerations

    <b>For practical purpose, we can directly create using data, and no need of using types.
    Types is generally used for oo programming.</b>
    To construct a new structured data type struc_typein a program, you use several TYPES statements:
    TYPES BEGIN OF struc_type.
    {TYPES dtype ...} | {INCLUDE {TYPE|STRUCTURE} ...}.
    TYPES END OF struc_type.
    The syntax for directly declaring a variable as a structure is the same as you would use to define a structured data type using the TYPES statement:
    DATA BEGIN OF struc.
    {DATA comp ...} | {INCLUDE {TYPE|STRUCTURE} ...}.
    DATA END OF struc.
    The individual components of a structure are addressed in the program with the structure component selector between the structure name and component name as follows: struc_comp.
    Have a look at below link.
    http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb3364358411d1829f0000e829fbfe/content.htm
    I hope it helps.
    Best Regards,
    Vibha
    *Please mark all the helpful answers
    Again a request for you:U have raised so many queries in this forum and many people have answered also but you have not marked the answers which are helpful to you. Many abapers are using their time to give answers so u can just thank them by marking helpful answers.

  • Better method to convert pixels to ems

    Don't know if my Dreamweaver CS5 can help me do this:
    I'm experimenting with making my site more accessible for vision-impaired people by using ems in my CSS style sheet for image sizes as described at http://sperling.com/examples/zoom/
    The problem I have is calculating the ems. I have to open the image in Photoshop, use Image Size to figure what the height and width pixels would be at a slightly smaller size, then go to an online site that lets me convert pixels to ems. What a hassle. Shorter path?
    - Keith Purtell

    First you must establish the base font-size in your CSS like so:  This assumes 1em = 100% = 16px (standard browser default).
    html {font-size: 100%}
    body {font-size: 1em}
    Then define your page layout and division widths in ems using the following formula:
    1 divided by 16 = 0.0625
    multiplied by the number of pixels required
    = value in ems.
    0.0625 X 900px = 56.25em
    0.0625 X 300px = 18.75em
    0.0625 X 150px = 9.375em
    #wrapper { width: 56.25em}
    #divName {width: 18.75em}
    #divName img {width: 9.375em; height: 9.375em}
    IMPORTANT!  If you don't wrap elastic images inside elastic containers, your page will fall apart when people increase text size in browser.
    You can see a working DEMO of this method here:
    http://alt-web.com/TEST/Resizable-ems-test.html
    Good luck,
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb

  • Better method for update query

    Thanks in advance for any help you can offer on this...
    I have two tables:
    DETAIL_TABLE with columns: email_address, invalid_format_indicator, source, create_date
    SUMM_TABLE with columns: run_date, source, email_address_cnt, invalid_email_address_cnt
    Each week I run a job that truncates, then inserts new rows into the DETAIL_TABLE of email addresses that are likely invalid (invalid_format_indicator = 'Y'), and the source system ("source") that created them, as well as the date they were created in our system. Later in the process of that same job, I add new rows into SUMM_TABLE with counts.
    So, for data:
    DETAIL_TABLE:
    email_address|invalid_format_indicator|source|create_date
    joe.aol.com|Y|web|2011-03-01
    mary@myurl|Y|web|2011-03-05
    larry 2yahoo.com|Y|phone|2011-03-06
    After the DETAIL_TABLE is refreshed, new rows (14 of them) are inserted into the SUMM_TABLE whereby it creates a new row for each source. What I then want to do is update the 'invalid_email_address_cnt' field by counting the number of rows in DETAIL_TABLE, grouping by source.
    Right now, I'm running 14 update queries simultaneously--one for each source.
    Data looks like this after the update is complete (bear in mind, it's being updated via 14 separate queries):
    SUMM_TABLE
    run_date|source|email_address_cnt|invalid_email_address_cnt
    2011-03-06|web|25|5
    2011-03-06|phone|3|1
    2011-03-06|loader|20|4
    2011-03-06|source14|5|2
    It looks like this BEFORE the update:
    run_date|source|email_address_cnt|invalid_email_address_cnt
    2011-03-06|web||
    2011-03-06|phone||
    2011-03-06|loader||
    2011-03-06|source14||
    I'm currently running this update statement:
    Update SUMM_TABLE S
    set invalid_email_address_cnt =
    (Select count(*)
    from DETAIL_TABLE D
    where D.source = 'web'
    and D.invalid_format_indicator = 'Y')
    where S.run_date = sysdate
    and S.source = 'web';
    I repeat this query 13 more times-- one for each source. Ick...
    I'd like to consolidate it to one query. I prefer not using PL/SQL. The tool I'm using doesn't support PL/SQL (It's an open source ETL tool), so if I can do this via straight SQL (Oracle compliant) that would be ideal.
    Any help would be greatly appreciated!

    I believe you just want a correlated update
    Update SUMM_TABLE S
       set invalid_email_address_cnt =
          (Select count(*)
            from DETAIL_TABLE D
           where D.source = s.source
             and D.invalid_format_indicator = 'Y')
    where S.run_date = sysdate;I'm not sure, though, about the WHERE clause. Surely you mean TRUNC(sysdate) or you're using a local variable that you used to insert the row into the summary table. Otherwise, if you get unlucky and the clock ticks while your procedure is running, the update may not affect any rows.
    Justin

  • Better method of design question

    Before starting another project, I thought I'd check opinion on the most efficient design and processing of the forms.
    It's an extremely simple application that needs to track 7 different types of meetings, their dates, and the people in attendance.
    Originally, I was going to create 3 separate tables, one for the meetings with TYPE,DATE & PRIMARY_KEY field from a sequence, another table for personnel of the type PRESIDENT with PRES_NAME & FOREIGN KEY fields populating FOREIGN_KEY with MEETINGS SEQUENCE, and a third table for personnel called VICE_PRES with VICE_NAME & FOREIGN_KEY fields also populated with MEETINGS SEQUENCE.
    There are times when there will only be 1 president and 5 vice, other times there will be 2 presidents and 6 vice. So I figured a separate table for PRES and VICE would ensure that every column entered into the table would have data in it rather than creating one table with TYPE, DATE, AUTOID, 2 PRES and 6 VICE and have several empty columns per record.
    After creating the 3 tables I've now run into more complex processing that I have in the past. I now need to display additional PRES and VICE fields when a radio element indicates Y and submits. I also only let this radio display when the meeting type select list is VIS and submits.
    The display issues appear to be correct at this point. The major problem I have is how to process multiple rows into 3 separate tables with one submit.
    How would one go about adding 2 PRES and 6 VICE names as separate rows at one time? This would be simple if I had used poor table design and just put everything into one table, but now that I have 3 tables to insert data into at the same time, and considering I have to add multiple records into one table at the same time I've run into more of a challenge than in the past.
    In addition, I've searched for how to process a form with blank items into a table without entering the nulls and haven't had much luck. This problem comes into play when I have 2 PRES items and 6 VICE items but only enter 1 PRES and 5 VICE. How to process multiple rows into the same tables and remove any null values from that process.
    Also, I may have the wrong idea as to how to link the 3 tables personnel records with the meeting records using one sequence and putting that number into all the tables, sometimes into multiple records at the same time. If I do, please do tell me about it. It seemd the most logical way of keying across tables.
    Thanks for any help on this thing!
    Jacob

    Took a couple days off... I made a quick page indicating the items on the page. It's at link http://htmldb.oracle.com/pls/otn/f?p=15398:1
    Originally I wanted 3 tables for this. 1 stores the meeting type& date. 1 stores the PRESIDENT name and his COMPANY. 1 stores the VICE president name and COMPANY. This way, I won't be accumulating a ton of null values in one larger table.
    I need these items to submit to their respective tables with 1 submit. Additionally, if there is only one value for PRES and one for VICE, I would need to submit only those items that are not NULL so I'm not loading up the null values in the tables.
    This has to be simple, I just don't immediately see how to accomplish this.
    Thanks 2 anyone.

  • Better method to backup the database via EM 12c

    I want to use EM to schedule backup jobs and would like to get some feedback from someone who already been used the product. Let's say you have 100 databases.
    1. do you create 100 backup job for each database? if so, everytime you created a new database, you have to create another new job. if you have a large env, this can be a nightmare to manage.
    2. you can create a job in library and submit a job. everytime you have new database, you just need to add the database to the job library. The only thing I am not sure is how does the backup files go to the right folder for each DB?
    thx

    If you want to go this way, you should use Groups.
    In a Group you could assign Databases
    Next, submit your Backup job to this Group
    If you create a new database you only need to add this Database to the Group
    Automatically the next time your Job get started, it will take your new Database aswell.
    Regards
    Rob
    http://oemgc.wordpress.com

  • Need a better method to block junk email senders

    Suddenly flooded with spam on my seldom used private email account. How do I block junk email senders.

    No offence, but Just a simple question : Why is Thunderbird still behind ?
    Other online mail can block a sender at once with only one click in the context menu !
    WAY EASIER THAN USING THUNDERBIRD WITH COMPLICATED SETTINGS.
    This is not a solution to our problem but a hint towards Mozilla developers

  • Which method has a better performance ?

    Hello !
    I'm using entity framework , and I have several cases where I should run a query than return some parent items , and after I display these parents and the related children  in one report.
    I want to know which of these methods have the better performance : ( or is there any other better method ??? )
    Method1: (the childs collection are loaded later , using lazy loading)
    Dim lista as IQueryable(Of MyObj) = (From t In context.MyObjs Where(..condition..) select t).Tolist
    Method2:
    Dim lista as IQueryable(Of MyObj) = (From t In context.MyObjs Where(..condition..) _
    .Include(Function(t2) t2.Childs1) _
    .Include(Function(t2) t2.Childs2) _
    .Include(Function(t2) t2.Childs2.Child22) _
    .Include(Function(t2) t2.Childs1.Childs11) _
    .Include(Function(t2) t2.Childs1.Childs12) _
    Select t).ToList
    Method3:
    Dim lista as IQueryable(Of MyObj)
    Dim lst= (From t2 In context.MyObjs Where(..condition..) Select New with _
    { .Parent=t2
    .ch1=t2.Childs1 _
    .ch2=t2.Childs2 _
    .ch21=t2.Childs2.Child21) _
    .ch11=t2.Childs1.Childs11) _
    .ch12= t2.Childs1.Childs12 _
    ).ToList
    lista=lst.Select(Function(t2) t2.parent)
    I noticed that the first method cause the report to open very slow. Also I read somewhere that Include() cause repeat of parent items?
    But anyway I want a professional opinion in general for the three methods.
    Thank you !

    Hello,
    As far as I know, the Entity Framework offers two ways to load related data after the fact. The first is called lazy loading and, with the appropriate settings, it happens automatically. In your case, your first method uses the last loading, while the second
    and third are the same actually, both of them are Eager Loading. (In VB, if you could check use code as “DbContext.Database.Log = Sub(val) Diagnostics.Trace.WriteLine(val)” to see the actually generated sql statement, you could see the third and second query
    would generate a join syntax). Since you mentions, the lazy loading way is low performance, you could use either the second or third one.
    >>Also I read somewhere that Include() cause repeat of parent items?
    For this, nor sure if you worry it would firstly use lazy loading and then use eager loading, however, in my test, I do not see this behavior, the Entity Framework seems to be smart enough to use one mode to load data at the same time. Or you could disable
    its lazy loading when using eager loading:
    context.ContextOptions.LazyLoadingEnabled = false
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

Maybe you are looking for