Having trouble with put_line function in block statement..

Am a student, and the request does not appear to be in my book anywhere... Nothing on put_line, or block statements that I can see..
Need to write a block which will bring back via put_line for department 110: the department_id (departments table), the department_name (departments table), and the city in which the department is located (which must be pulled from locations table... can be joined by department_id). I can write the select statement with join, just not sure how to turn it into a block with put_line function..
any advice appreciated.. Thanks.

Hi,
You need to format your code, so that it's easy to see what statements are in each section (DECLARE, BEGIN, etc.).
The compiler doesn't care about this, but it will help anyone who tries to read your code, including yourself.
Type {code} before and after formatted sections when posting messages on this site.
All statements, including each individual variable declaration) end with a semicolon.
If a query will return no more than one row, you can capture the results using an INTO-clause, right after the SELECT-clause. For every column in the SELECT-clause, there will be one variable in the INTO-clause.
Lists, including lists of table names in a query's FROM-clause, are delimited by commas.
In a query's FROM-clause, the real name of the table comes first, optionally followed by the alias you're using in the query.
I think this is what you're trying to do:
SET   SERVEROUTPUT  ON  SIZE 50000
Declare
    dep_id    NUMBER;
    Dep_string VarChar (100);
Begin
    select  d.department_id, d.department_name -- , l.city
      into  dep_id,          dep_string
      from  departments  d
         ,  locations    l
      where d.location_id = l.location_id
        and d.location_id = 110;
    DBMS_OUTPUT.PUT_LINE (Dep_string);
END;
/No one should ever have this many errors at one time. Write code in much smaller increments, and test after each one. For example, you know you'll be using dbms_output.put_line, so start with something like:
SET   SERVEROUTPUT  ON  SIZE 50000
BEGIN
    dbms_output.put_line ('Hello, world!');
END;You may have problems if you forget semicolons, or SET SERVEROUTPUT. Solve those before you go any further.
Once the program above is working, add a little (and I mean a little) to it.
For example, you know you'll be printing a varibale, not a literal, so change it to a variable:
SET   SERVEROUTPUT  ON  SIZE 50000
DECLARE
    dep_string  VARCHAR2 (100) := 'Hello, world!';
BEGIN
    dbms_output.put_line (dep_string);
END;And so on.
Edited by: Frank Kulash on Dec 15, 2008 12:36 PM

Similar Messages

  • Grapher having trouble with trig functions

    Well I thought that I could make some cool visuals for my math class by using grapher instead of just making charts and graphs in Excel on my pc, but no dice with that idea. I created all the different variables (and how they related to x, ie x^2*(5-x6)/x=m) and it was pretty cool how it would all come together and I could use those variables in other equations instead of writing it all out (stuff like y=4x^m-m/5). (Those are examples, not anything I used)
    Everything seemed fine until I tried to use a cosine function in one of the equations. It seemed really intuitive and recognized cos as cosine and not the variables c, o, and s multiplied, so I thought "great!" Then when I entered it the graph didn't appear anything like it should have. It gave me a Richter scale instead of a slightly curved line. I spent about half an hour trying to find my own error but then realized maybe there was something wrong with the program. I tried just plain old cos(x) and found that it was completely off. Instead of traveling from 0,1 to 180,-1 like it should have, it went from 0,1 to 3.1475,-1. This was way off so I tried a sine function and that did the same exact thing (having a period of roughly 6.295 instead of 360!). These functions were way off, and I'm using an intel macbook from my school (with 10.5), so I thought maybe someone changed the settings, so I tried them them on my aunts g4 macmini (10.4.11 I think) and it gave me the same problem!
    Anyway what's wrong with the trig functions for Grapher and how can I fix them?

    Emzz, I'm running 10.5.5 (Intel) and Grapher v2.0. My version of Grapher supports changing Trigonometric Mode, so the absence of this option seems to have nothing to do with Leopard.
    But let's do some Math now. As you surely know the cosine has (besides others) a root at 90 Degrees in the unit circle. Now let f : (angle in Degrees) -> (length of the corresponding arc of the unit circle) be a mapping. For 90 Degrees f yields 0.5*Pi. That means cosine has a root at 0.5*Pi in Radian unit.
    Now, if you swith Grapher's Trigonometric Mode from Degrees to Radian, cosine will no longer have a root at 90 but at approximately 1.57. Hope that explains a bit...
    By the way, Radian is the standard unit of angular measurement when it comes to trigonometric functions. For more details about Radian see [this article at Wikipedia|http://en.wikipedia.org/wiki/Radian] (click the link to be redirected).
    I suggest you close this topic because, as you already noted yourself, your initial question is answered.
    Good computing.
    floba
    (MN576)
    Message was edited by: floba

  • I am having trouble with a function in vb can anyone give me a suggestion?

    I am trying to calculate a cable bill of a residential customer and a business customer, when the customer checks the list box of the channels and the connections I need it to add it up. I have edited the code. Does my logic make sense?
    for residential customers it is 4.50 processing,30 basic service and 5 per channel
    so is the logic processing+basicservice *premium
    Public Class Main
    Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
    If Data_Validated_ok() = False Then Exit Sub
    Dim premiumChannels As Integer = lstPremium.SelectedIndex
    Dim Connections As Integer = lstConnections.SelectedIndex
    Dim totalDue As Decimal
    If radResidential.Checked Then
    totalDue = CalcResidentialTotalDue(premiumChannels, Connections)
    lblTotal.Text = totalDue.ToString("C2")
    Else
    totalDue = CalcBusinesssTotalDue(premiumChannels, Connections)
    lblTotal.Text = totalDue.ToString("C2")
    End If
    End Sub
    ' make a function to calculate residential customers
    Private Function CalcResidentialTotalDue(ByVal premiumChannels As Decimal, ByVal connections As Decimal
    ) As Decimal
    Const ResidentialProcessing As Decimal = 4.5D
    Const ResidentialBasic As Integer = 30
    Const ResidentialPremium As Integer = 5
    Return ResidentialProcessing + ResidentialBasic + ResidentialPremium * premiumChannels
    End Function
    ' make a function to calculate business customers
    Private Function CalcBusinesssTotalDue(ByVal premiumChannels As Decimal, ByVal connections As Decimal
    ) As Decimal
    Const BusinessProcessing As Decimal = CDec(16.5)
    Const BusinessBasic As Integer = 80
    Const BusinessPremiumchannels As Integer = 50
    Return BusinessProcessing + BusinessBasic + BusinessPremiumchannels * premiumChannels
    End Function
    here is  a pic of my listboxes
    [IMG]http://i57.tinypic.com/muepug.png[/IMG]
    http://i57.tinypic.com/muepug.png

    The statement below is wrong in both functions.  You are passing the variable "connections" in the function parameter list and not using the variable.  I thing in the statement below you need to change connections to something else.
    connections = Convert.ToDecimal(lstConnections.SelectedItem)
    Here are the two parameter lists
    1)    Private
    Function calcResidentialTotal(ByVal connections
    As Decimal,
    ByVal premium As
    Decimal)
    As Decimal
    2)   Private
    Function calcBusinessTotal(ByVal connections
    As Decimal,
    ByVal premium As
    Decimal)
    As Decimal
    jdweng

  • A trouble with "LIKE" in a select statement

    Hi!
    I'm having trouble with "LIKE" in a select statement...
    With Access I can make the following and everything works well:
    SELECT name, birthday
    FROM client
    WHERE birthday LIKE '*/02/*';
    but if try to do it in my application (it uses Access), it doesn't work - I just can't understand that!!!
    In my application the "month" is always the currently month taken from the "System". Look what I'm doing...
    String query1 = "SELECT name, birthday " +
              "FROM client " +
              "WHERE birthday " +
              "LIKE '*/" +
              pMonth +
              "/*' " +
              "ORDER BY birthday ASC ";
    ResultSet rs = statement1.executeQuery(consulta1);
    boolean moreRecords = rs.next();
    The variable "moreRecords" is always "false", the query returns nothing although the table "client" has records that attend the query.
    Please, anyone can help me?! It's a little bit urgent.
    Thanks,
    Katia.

    Hi Katia,
    I'll bet the problem lies with the characters you're using to escape the LIKE clause. You're using the ones that Access likes to see, but that's not necessarily what's built into the JDBC-ODBC driver class.
    You can find out what the correct escape wildcard characters are from the java.sql.DatabaseMetaData.getSearchStringEscape() method. It'll tell you what to use in the LIKE clause.
    I'm not 100% sure about your code. It doesn't use query1 anywhere. I'd do this:
    String query = "SELECT name, birthday FROM client WHERE birthday LIKE ? ORDER BY birthday ASC";
    PreparedStatement statement = connection.createStatement(query);
    String escape = connection.getMetaData().getSearchStringEscape();
    String test = escape + '/' + pMonth + '/' + escape;
    statement.setString(1, test);
    ResultSet rs = statement.executeQuery();
    while (rs.hasNext())
    // load your data into a data structure to pass back.
    rs.close();
    statement.close();Let me know if that works. - MOD

  • I am having trouble with plug-ins.  How do I cure this?  The last time I believe I had to update my operating system.  My current operating sytstem is MAX OSx , Version 10.6.8

    I am having trouble with plug-ins being blocked.  I have an I-Mac, 2.4 Ghz processor, 2 GB memory, and using Safari as my browser.  My operating system is MAC OSX Version 10.6.8

    Any particular plugin or all of them? If Adobe Flash Player, try un-installing and then re-installing.
    Adobe Flash Uninstaller
    Adobe Flash Player

  • Having trouble with the str()function

    I'm having trouble with the str() function. The first parameter is the value and I want to set the format but I keep getting an error. I do it like this. str(locals.array[8]-locals.array[9],"%$.6f"). I get a runtime error, so I tried to remove the "" but now the I get a syntax error.

    Hi,
    Can not see a problem with your statement.
    I have attached a TS2.0.1 example using you expression.
    Regards
    Ray Farmer
    Regards
    Ray Farmer
    Attachments:
    Sequence_File1.seq ‏20 KB

  • I am having trouble with app updates on my iOS 5 iPhone never getting beyond the "waiting" state.

    I am having trouble with app updates on my iOS 5 iPhone never getting beyond the "waiting" state. I have tried signing out/in of my account, rebooting and removing/re-installing the apps.  This started shortly after going to iOS 5 but I am not certain if that is related.  All updates that I try now are stuck in "waiting".  I also tried removing the apps and then installing via iTunes desktop sync with no improvement.  The only thing that I have not tried so far is a restore to a prior iPhone backup.  I have not been able to find anything to indciate what the updates on waiting on.  There is plenty of space on the iPhone (16gb available).  Any suggestions on what to try next? 

    Hello there, Missy.
    First thing I would recommend is to check your downloads queue to make sure there is not an interrupted download per the following Knowledge Base article:
    iTunes: How to resume interrupted iTunes Store downloads
    http://support.apple.com/kb/HT1725
    If your download was interrupted using your iPhone, iPad, or iPod touch
    1. From the Home screen, tap the iTunes app.
    2. For iPhone or iPod touch, tap More > Downloads. For iPad, tap Downloads.
    3. Enter your account name and password if prompted.
    4. Tap the blue download arrow to resume.
    If you can't complete the download on your iOS device, you can download it in iTunes on your Mac or PC and then sync it to your iOS device. You can also transfer purchases from your iPhone, iPad, or iPod to a computer.
    For Apps, you can also try tapping on the application icon to resume the download, as outline in this featured discussion:
    App updates won't download on my...: Apple Support Communities
    https://discussions.apple.com/thread/4111336
    Try tapping the App, so that it changes to Paused instead of Waiting, then tap it again to resume the install.
    Make sure you don't have any paused downloads in other apps either, like the App Store or iTunes Store.
    If that doesn't do it, try resetting or restoring the iPhone.
    via whatheck
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • I have a Lucid 2 LG.  I have been having trouble with insuffient storage.  I have a 8G phone and have spent hours with Tier 2 tech trying to move info from the internal storage to the SD card with no luck,  When I go to storage in the settings it states t

    I have a Lucid 2 LG.  I have been having trouble with insuffient storage.  I have a 8G phone and have spent hours with Tier 2 tech trying to move info from the internal storage to the SD card with no luck,  When I go to storage in the settings it states that over 4 gigs is for Misc?  System data takes up over 4 gigs.  No one can tell me what system data consist of.  So My question is does anyone know what system data is?  I am assuming I have a 8 gigphone but can only use 4 gigs???

    System data is the OS or operating system.  That is where the recovery stays separated from the rest of the storage so that it doesn't get corrupted.  It is not accessible and non-movable.

  • Having trouble with Tiscali/TalkTalk site when accessed with 'FireFox', can't 'reply' to emails or report 'spam', other functions seem ok

    Having trouble with Tiscali/TalkTalk site when accessed with 'FireFox',
    can't 'reply' to emails or report 'spam', other functions seem ok
    == This happened ==
    Every time Firefox opened
    == On/Off few months now all time

    Try deleting cookies and cache:
    1. Tools| Clear recent history
    2. Time range to clear: Everything
    3. If it isn't already selected, select '''Cookies''' and '''Cache'''
    4. '''Clear now'''
    <u>Check cookie exceptions</u>
    1. Tools | Options | Privacy Panel
    2. Set '''Firefox will: Use custom settings for history''' Insure Accept cookies for sites and accept third-party cookies is selected
    3. Click '''Exceptions'''. If the misbehaving site is in that list, select it and click '''Remove site'''
    Also see [[Updating Firefox]]

  • Having trouble with the video function..

    I just purchased the 60GB ipod photo. I'm transferring music files easily. However, I'm having trouble with the video function. I've loaded Itunes 6, reloaded the original setup disk, and have loaded the latest updates for the unit. I can download movies from the itunes store and save them to my library, but I cant seem to transfer the video files to the ipod. Ive reinstalled itunes and the update 6 with no success. After syncing the ipod it only shows the music files even after all that Ive tried. Additionally, there is no evidence of the video function on the main menu after the update attempts. Can someone tell me what I'm doing wrong? I'm eager to get past this problem so that I can start tranfering personal movies and video files.

    You Have an iPod Photo, You do NOT have a 5th Generation Video iPod. Get it? You need the 5G model to play video.
    If the salesman told you it was the 5G model he lied, was ignorant or both. If video is important or if thats what you thought you were getting you will need to return your 4G iPod photo for new iPod.
    Rotsa Ruck!

  • I'm having trouble with my sound up and sound down keys. They're doing other functions. This is only a new thing.

    I'm having trouble with my 'sound up' and 'sound down' keys. They're doing other functions. This is only a relatively new thing.

    You didn't mention what those "other functions" were.  That might help!
    First thing to check is System Preferences > Keyboard > Keyboard tab - make sure "Use all F1, F2, etc. keys as standard function keys" is un-checked.  Hopefully that still works in Mountain Lion.

  • I'm having trouble with the folder "Automatically add" function. She opens a folder "not added". My machine is a Vaio with Windows 7 home basic antivirus using Microsoft. Regards.

    I'm having trouble with the folder "Automatically add" function. She opens a folder "not added". My machine is a Vaio with Windows 7 home basic antivirus using Microsoft. Regards.

    Its a 64 bits.

  • I am having trouble with my JAVA Applet. It isn't functioning on SAFARI.    It seems to have stopped working and I used it on SAFARI last year. Any suggestions ?

    I am having trouble with my JAVA Applet. It isn't functioning on SAFARI.    It seems to have stopped working and I used it on SAFARI last year. Any suggestions?

    Post in the Safari forum area.

  • I'm having trouble with the repeat function on iTunes 11.

    I'm having trouble with the repeat function on iTunes 11.  The buttons are there but will not allow me to repeat an album when selected under artist from remote app on iPhone.  I have downloaded the update for the remote app but the repeat function now repeats all albums under that artist name.  Selecting the album directly under albums works but is not as easly to access.  Any thoughts?

    Sorry, downgrading is not supported.

  • I'm having trouble with something that redirects Google search results when I use Firefox on my PC. It's called the 'going on earth' virus. Do you have a fix that could rectify the vulnerability in your software?

    I'm having trouble with a virus or something which affects Google search results when I use Firefox on my PC ...
    When I search a topic gives me pages of links as normal, but when I click on a link, the page is hijacked to a site called 'www.goingonearth.com' ...
    I've done a separate search and found that other users are affected, but there doesn't seem to be a clear-cut solution ... (Norton, McAfee and Kaspersky don't seem to be able to detect/fix it).
    I'd like to continue using the Firefox/Google combination (nb: the hijack virus also affects IE but not Safari) - do you have a patch/fix that could rectify the vulnerability in your software?
    thanks

    ''' "... vulnerability in your software?" ''' <br />
    And it affects IE, too? Ya probably picked up some malware and you blame it on Firefox.
    Install, update, and run these programs in this order. They are listed in order of efficacy.<br />'''''(Not all programs detect the same Malware, so you may need to run them all to solve your problem.)''''' <br />These programs are all free for personal use, but some have limited functionality in the "free mode" - but those are features you really don't need to find and remove the problem that you have.<br />
    ''Note: If your Malware infection is bad enough and you are mis-directed to URL's other than what is posted, you may have to use a different PC to download these programs and use a USB stick to transfer them to the afflicted PC.''
    Malwarebytes' Anti-Malware - [http://www.malwarebytes.org/mbam.php] <br />
    SuperAntispyware - [http://www.superantispyware.com/] <br />
    AdAware - [http://www.lavasoftusa.com/software/adaware/] <br />
    Spybot Search & Destroy - [http://www.safer-networking.org/en/index.html] <br />
    Windows Defender: Home Page - [http://www.microsoft.com/windows/products/winfamily/defender/default.mspx]<br />
    Also, if you have a search engine re-direct problem, see this:<br />
    http://deletemalware.blogspot.com/2010/02/remove-google-redirect-virus.html
    If these don't find it or can't clear it, post in one of these forums for specialized malware removal help: <br />
    [http://www.spywarewarrior.com/index.php] <br />
    [http://forum.aumha.org/] <br />
    [http://www.spywareinfoforum.com/] <br />
    [http://bleepingcomputer.com]

Maybe you are looking for

  • Auto Populate one Field Based on Another Field

    I am trying to populate the description field after the user has entered a value in the item number field and then tabs or otherwise exits the item number field. I'm sure this is in the documentation somewhere, but I'm in a big hurry. By the way, thi

  • Issues after installing latest Flash Player

    Hi, A little while ago I downloaded and installed the latest version of Flash Player 11.8.800. I have a Mac running OS X 10.6.8 and use Safari 5.0.5 as my browser. Since installing I have been having two main problems. The first is that I won't be ab

  • Can't view page in Dreamweaver

    There is one page in Dreamweaver that doesn't show the web page (design), only the html shows up. I have it clicked on "split", but still nothing shows. How can I fix this? Thanks

  • Having trouble opening pages

    when i try to open Pages document (or even Pages itself), all I'm getting is this window with spiriling blue lines.

  • XControl doesn't update listbox contents

    I'm finally diving into XControls and after much frustration am finally getting some results. I must be making this harder than it is. Anyway, I'm trying to update a listbox in the control. When the string list comes from something like a static arra