a query

Hi, forms 6i,

I have these tables

1 - items (item_id, item_eng_name).

2 - units (unit_code, unit_name).

I use this code in a trigger after query

select i.item_eng_name , u.unit_name
into :SOD.item_eng_name , :SOD.sale_unit_name
from items i , units u 
where item_id = :SOD.item_id 
and u.unit_code = :SOD.sale_unit_code ; 

the result is correct, but I think that it should not be written like that, because

There is no join condition between two tables? I'm wrong or I can write this way?

Assuming item_id and unit_code are primary keys your code would do what you expect it to do: he will go get the item_eng_name and unit_name from 2 different tables. If item_id and unit_code is the primary key, you will get a record in each table. Join 2 tables together, you get a product of carthesian. Now, as said IF the 2 columns have the primary key, you would get 1 card for each table, and the carthesian product will return also 1 sheet.

If for some reason one of your tables does not contain the key you are looking for a no_data_found will be triggered:

$[CHE_TEST@glados_impl] create table items(item_id number, item_eng_name varchar2(20));

Table created.

$[CHE_TEST@glados_impl] create table units(unit_code number, unit_name varchar2(20));

Table created.

$[CHE_TEST@glados_impl] insert into items(item_id, item_eng_name) values (1, 'item1');

1 row created.

$[CHE_TEST@glados_impl] insert into units(unit_code, unit_name)values (1, 'unit1');

1 row created.

$[CHE_TEST@glados_impl] commit;

Commit complete.

$[CHE_TEST@glados_impl] declare
  2  vItemEngName items.item_eng_name%type;
  3  vUnitName units.unit_name%type;
  4  begin
  5  select item_eng_name, unit_name
  6  into vItemEngName, vUnitName
  7  from items i, units u
  8  where item_id = 1
  9  and unit_code = 1;
 10  end;
 11  /

PL/SQL procedure successfully completed.

$[CHE_TEST@glados_impl] ed
Wrote file c:\temp\afiedt.sql

  1  declare
  2  vItemEngName items.item_eng_name%type;
  3  vUnitName units.unit_name%type;
  4  begin
  5  select item_eng_name, unit_name
  6  into vItemEngName, vUnitName
  7  from items i, units u
  8  where item_id = 1 -- record exists
  9  and unit_code = 2; --record does not exist
 10* end;
$[CHE_TEST@glados_impl] r
  1  declare
  2  vItemEngName items.item_eng_name%type;
  3  vUnitName units.unit_name%type;
  4  begin
  5  select item_eng_name, unit_name
  6  into vItemEngName, vUnitName
  7  from items i, units u
  8  where item_id = 1 -- record exists
  9  and unit_code = 2; --record does not exist
 10* end;
declare
*
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at line 5

So you either find two keys or you find neither. If this is what you want, then your code is logically correct. However; This does not mean that you should do as it (always code as if the person who will maintain your code is a maniacal killer who knows where you live); It definitely takes time to get those head around to get why your code looks at the way in which it seems.

The equivalent logic which is (for me) is more logical at first sight is the following code:

$[CHE_TEST@glados_impl] r
  1  declare
  2    vItemEngName items.item_eng_name%type;
  3    vUnitName units.unit_name%type;
  4  begin
  5    select item_eng_name
  6    into vItemEngName
  7    from items i, units u
  8    where item_id = 1;
  9    --
 10    select unit_name
 11    into vUnitName
 12    from units
 13    where unit_code = 1;
 14  exception
 15    when no_data_found or too_many_rows then
 16      vItemEngName := null;
 17      -- when the first statement fails, vUnitName and vItemEngNAme will be null;
 18      -- when the second statement fails vUnitName will be null,
 19      -- we need to set vItemName to null
 20      raise; -- in your original code there is no exception handler
 21             -- so we'll reraise the exception here as well
 22             -- to get the very same behaviour
 23* end;

PL/SQL procedure successfully completed.

So, as I said: your original code is correct? If it is supposed to do the same as my code so it's okay. But this does not mean to do it like that because at least, in my opinion, my code is much clearer to understand on the first look.

see you soon

Tags: Oracle Development

Similar Questions

  • Why should I uncheck responder OCSP query servers to confirm the current validity of certificates to access the site Web of Yahoo?

    If I check the servers of responder ocsp query I get the error message sec_error_ocsp_old_response. If I uncheck that box yahoo charge very well

    Hello, can check you that your system clock is set to correct date, time, and time zone? -> time.is

  • When you type a query in the bar always double the third letter, for example, research, if I want to write a 'youtube' written "youutube" what to do, help

    When you type a query in the bar always double the third letter, for example, research, if I want to write a 'youtube' written "youutube" what to do, help

    Hello chilli.willi, try Firefox Safe Mode to see if the problem goes away. Firefox Safe mode is a troubleshooting mode that temporarily disables hardware acceleration, restores some settings and disables add-ons (extensions and themes).

    If Firefox is open, you can restart Firefox Safe mode in the Help menu:

    • Click the menu button

      click Help

      then select restart with disabled modules.

    When the Firefox Safe Mode window appears, select "start mode safe."

    If the problem is not present in Firefox Safe Mode, your problem is probably caused by an extension, theme or hardware acceleration. Please follow the steps described in the section Troubleshooting extensions, themes and problems of hardware acceleration to resolve common Firefox problems to find the cause.

    To exit safe mode of Firefox, simply close Firefox and wait a few seconds before you open Firefox for normal use again.

    When find you what is causing your problems, please let us know. This might help others with the same problem.

  • How can I get a query in the search field to open in a new tab or a new window, and the current window?

    How can I get a query in the search field to open in a new tab or a new window, and the current window?

    If you are looking through the search bar in the Navigation toolbar, this preference can be changed to research it open in a tab.

    Type of topic: config in the address bar and press ENTER. Then answer "I'll be careful." Type this pref in the search at the top.

    Browser.Search.openintab = double click to switch to true

  • When, on my home page, I click on the link "transparent popup" in the query "did you mean: transparent popup", NO RESULTS appear in this new tab; How to solve?

    I had trouble due, apparently, to a file named popuptransparent [dot] xul, which I have 3 cases on my computer (Win XP/Firefox last v.). Using my window of AVG home page, I get "popuptransparent" (try to fix) and the results appear OK. But then when I click to a new tab, on the "transparent popup" link in the query "did you mean: transparent popup", NO RESULTS appear in this new tab. In addition, when I reload then the Panel of AVG which sought to 'popuptransparent' in the first place, it, too, shows now no results. Or a panel shows Google now no results. They show the quantity of results, but just white screens for the results themselves.

    Links https://support.mozilla.org/en-US/questions/948804?esab=a & as = aaq and https://support.mozilla.org/en-US/questions/952141?esab=a & as = aaq brings me. I re-installed Firefox v. 20.0.1 nothing works. How to fix?

    Should I remove it from my computer all 3 of these instances of xul [dot]?

    Regarding the problem of searching, you can check the extension "Disconnect"? I think it could affect the Google sites and third parties who use Google. You can disable or try its button Options here:

    Firefox orange (or the Tools menu) button > addons > Extensions category

    While you're there, you can disable all extensions essential and unrecognized. When in doubt, turn off.

    After restarting Firefox, did you notice a difference?

    Could you explain in more detail the next part?

    Should I remove it from my computer all 3 of these instances of xul [dot]?

    Is this something that came in a security sweep? What question do you think they are originally? They are located in a folder extensions?

  • I need to stop a download of the query, I thought a stand-alone application but turns require a higher level (FCPX) as a 'parent' and I do not who have, or want to buy.

    I need to stop a download of the query, that I thought a stand-alone application but turns require a higher level (FCPX) as a 'parent' and I do not have that, or I want to buy it.

    Motion IS a stand-alone application. It is mainly designed to make effects for Final Cut Pro X, but it is not necessary to have with FCPX nor is it necessary to have FCPX to create projects for other purposes. When you open the query, simply select project of work outside the FCPX motion. You can save regular projects of Motion anywhere on your system.

  • How to activate the query suggestions

    How the query suggestions can be enabled in the Firefox address bar?

    You're welcome... good to know you got it working.

  • Satellite A30: Can not find the COM ports when trying to query the modem

    Hello.
    I have satellite A30 and I reinstall windows xp at home, but I can't find any com port whenever I try to query the modem the display hardware confilct, but in Device Manager no sign of error/confilct, I did everything what I can.
    Add the port,
    Add more then 1 port
    disable the printer port
    change the printer port
    Reinstall derver modem,
    In short, I've done everything I can. its always show (! yellow) mark.if I add the port and if I remove the port and there is no sign of error.
    If someone help me to solve this problem a little,
    regared.
    MGK.

    Post edited by: mghouskhan

    The modem uses a virtual com port. It s not a real port.
    I wonder why it usually happens after the installation of the new operating system, you must install drivers Toshiba together in the right order
    Installing the chipset utility is important

    The modem driver should do the work and you n t need to activate com ports
    Please choose the right side of the page of the Toshiba driver modem driver after installing the OS correctly. I think that's the key

  • find on a query page breaks

    When you search on a page by using the function FIND of Firefox, it ignores the query on the results page if it is in a link. Example: using Google, Yahoo, Bing, etc, I search for "airplane" (without the quotes). On the results page, I am looking for aircraft. The Firefox FIND function ignores the word "aircraft" if it's in a link. He finds it if it is plain text. I used the safe mode, deleted the cache - not good. Updated 3 addons in need. Check the list of embarrassing addons - none of my friends are on it. I have reset to the default values - no good. Then I copied localstore.rdf and prefs.js to a different location and renamed those in the profile. When I restarted Firefox the problem disappeared, but then where my addons (that's all I noticed;) I've always had my favorites). Then I changed the 2 files their original name. My favorites were back but was the problem. With the help of 3.6.17

    No problem here as long as I can see the text to highlight all find them also all occurrences.

    Make sure that sensitive has not activated (Ctrl + F or Edition > Search)

  • Bezier Motion 5.0.7 masks appear in the timeline panel, but in the column of layers only. This started happening yesterday. The query projects previously do not have this problem. I can't change if masks appear in the timeline panel.

    Motion 5.0.7 memory 8 GB, processor 2.93 GHz intel Core i7, ATI Radeon HD 5750 1024 MB graphics

    Bezier masks do not appear in the timeline, preventing me from editing. The masks appear in the column of layers only. The problem just started yesterday. The query projects previously do not seem to be performed.

    In the upper right corner of the canvas, there is a view menu. Check if the 'lines' are checked in the section view overlays.

  • My safari has locked up with a request for verification of the property query.  What can be done to fix this?

    My safari has locked up with a request for verification of the property query.  What can be done to fix this?

    This is the shit that came.

    Force Quit Safari (cmd-option-esc) then restart Safari by holding down the SHIFT key.

    Sorry, wrong forum... question thought it was an OS X. In any case don't give them any info.

  • 383 receving error while querying the data search

    Hello

    We have a script (vbs) that runs in Diadem and asks a Datafinder (Server edition). After the addition of a code of error handling, we encountered the following error:

    Error description: an error occurred while searching. The query can contain at least one invalid property.        Number: 383 Source: false.*

    * Now, according to the message above, we can extract that there is a property or a value of the property (of the application) makes / hurt, but see the next line from this message please.

    Once we took the trap for this error, we connect and save queries (in files TDQ) which were used at the present time that the error occurred. When load us the files of this query, no error is caused. We currently have to solve this problem, but we don't find the root cause yet. No guidance, the tip or help will be greatly appreciated.

    Hi manny,.

    This looks like a problem of type of property data for me.  In rare cases save a condition of tiara in a *.tdq file can cause this condition to change the data type of the property.  You can try to reduce the number of assignments to one and determine what state is the culprit?  Then ask yourself which operator you use in this condition - if it is "=" or "<>" then it supports any type of data.  If it's any other condition, then he could run against a string data type.  In addition, you may have a datetime property that is not optimized in the DataFinder, who could be considered an invalid property.

    Brad Turpin

    Tiara Product Support Engineer

    National Instruments

  • "Estincomplet" DataFinder Advanced Query result is equal to true after 200 files

    I have a VBS that runs a query that has been used for a while, but has reached its limits this week.  Limit is reached is to 200 files, after the "estincomplet" flag is set and do not know how to increase the setting of the maximum value.  I tried the "MaxNoSearchResults" setting, but not had any luck.  I have attached the VBS a subset, I've been using, any input would be appreciated.

    Thank you

    Potentially

    Navigator.Display.CurrDataFinder.ResultsList.Settings.MaxCount = 1000

    is what you are looking for.

  • How to query a Subvi dynamically loaded to its input terminals names?

    Hello

    I have an application where I use dynamically load the Subvi and I need a way to query the Subvi for its names of input terminals.  I'll use several different Subvi now and in the future and will not experience the terminals.

    Any help would be greatly appreciated.

    Thank you in advance!

  • Newport ESP300 GPIB communication stops after query

    Hello

    I'm trying to control a Newport ESP300 via GPIB controller with labview and I encountered a problem that I saw in the forums.  I can tell the controller to move to different positions, to wait, to change speeds, etc., without error.  However, when I ask the device, it stops all communications with Labview.

    Example of

    1 MB //axis 1 on

    1pa2 //move axis 1 absolute in position 2

    wait for stop 1WS

    1AP?     absolute position of query

    2 response //ESP300

    1pa3 //NOTHING ARRIVES

    1MF NOTHING HAPPENS

    GPIB READ.vi a mode = 2 (to end the LF character) to terminate the operation of reading as specified by newport, but the communication stops everytime I interrogate the device.

    I tried to do what this last newport mentions, without effect.  FTP://download.Newport.com/MotionControl/archive/motion%20Controllers/ESP300/software/ESP300%20GPIB%...

    I should mention that I couldn't disable autopolling (the box is grayed out).  Although I don't think that's the problem.  I also tried to replace the GPIB READ.vi with code on VISAS, but this has no effect.

    Sending of the same series of commands through NOR-MAX does not show this strange behavior.  I tried to ask about it in Newport, but they were not able to help.  Anyone has any advice on how to reliably read/write by GPIB with the ESP300 controller?

    Thank you.

    I found the problem.  It turns out that when you use the GPIB READ.vi, I had put the number of bytes to a value that was too small.  Thus, reading finished early, leaving the rest of the message in the buffer.  I don't know exactly why it resulted in a 'freeze' of communications, but he did.  Increase the number of bytes to 255 has solved the problem.

  • Increase the maximum number of query results

    Hello

    I need to increase the maximum search results, when I'm looking for data with data-> ValueMaxCount

    I'd like to 2000

    I tried tho change it with the help of the property page and the example given.

    The result looks like this:

    Define DataFinder = Navigator.ConnectDataFinder (Navigator.Display.CurrDataFinder.Name)
    Set IndexedFileProperties = DataFinder.GetIndexedProperties (eSearchFile)
    Set IndexedProperty = IndexedFileProperties ("fileName")
    Define ValueList = IndexedProperty.GetValueList
    DataFinder.ValueMaxCount = 2000
    Define ValueList = IndexedProperty.GetValueList

    But the quantity of serach result remains at 200

    I am referring to the wrong object or do I need to increase it to a certain point?

    Concerning

    Janick

    Hi Janick,

    your script increases the number of values that are returned if you ask for all values that are indexed to a specific property (in the BROWSER QueryForm you will receive this list by clicking the... button to the right of the line a condition).

    To increase the maximum number of search results, you would use the MaxCount property for the elements of results.

    DataFinder.Results.MaxCount = 2000' in the search without the GUI

    or

    Navigator.Display.CurrDataFinder.ResultsList.Elements.MaxCount ' in the search with the BROWSER GUI

    What version of DIAdem do you use? 2015 tiara, it is also possible to determine the maximum number of search results in the search method:

    DataFinder.SearchElements (Query, 2000)

    I hope this helps.

    Good day

    Eva

Maybe you are looking for