Question on the PL/SQL and substitution of variables

Good evening

I just started studying the PL/SQL (currently at page 13 of the book), I typed the following example from the book:
declare
  v_student_id          number          := &sv_student_id;
  v_first_name          varchar2(35);
  v_last_name           varchar2(35);

begin
  select first_name,
         last_name,
    into v_first_name,
         v_last_name
    from student
   where student_id = v_student_id;


  dbms_output.put_line('Student name : ' || v_first_name || ' ' v_last_name);

  exception
    when no_data_found then
      dbms_output.put_line('There is no such student');
end;
/
that gets me the following error:
SP2-0552: Bind variable "SV_STUDENT_ID" not declared.
I thought that SQL * more would invite me for a value to be substituted for SV_STUDENT_ID but it does not, that caused the error. Why has no SQL * more invite me for the value of SV_STUDENT_ID and what is the correct way to do it than the code above?

Thank you for your help,

John.

As a result, DDL for STUDENT table:
CREATE TABLE STUDENT
 (STUDENT_ID NUMBER(8,0)
 ,SALUTATION VARCHAR2(5)
 ,FIRST_NAME VARCHAR2(25)
 ,LAST_NAME VARCHAR2(25)
 ,STREET_ADDRESS VARCHAR2(50)
 ,ZIP VARCHAR2(5)
 ,PHONE VARCHAR2(15)
 ,EMPLOYER VARCHAR2(50)
 ,REGISTRATION_DATE DATE
 ,CREATED_BY VARCHAR2(30)
 ,CREATED_DATE DATE
 ,MODIFIED_BY VARCHAR2(30)
 ,MODIFIED_DATE DATE
 )
/

You had a few syntax errors (lines 7 and 12), but after their attachment, your code worked for me:

SQL> ed
Wrote file afiedt.buf

  1  declare
  2    v_student_id          number          := &sv_student_id;
  3    v_first_name          varchar2(35);
  4    v_last_name           varchar2(35);
  5  begin
  6    select first_name,
  7           last_name
  8      into v_first_name,
  9           v_last_name
 10      from student
 11     where student_id = v_student_id;
 12    dbms_output.put_line('Student name : ' || v_first_name || ' ' || v_last_n
ame);
 13    exception
 14      when no_data_found then
 15        dbms_output.put_line('There is no such student');
 16* end;
SQL> /
Enter value for sv_student_id: 1
old   2:   v_student_id          number          := &sv_student_id;
new   2:   v_student_id          number          := 1;

PL/SQL procedure successfully completed.

Did you happen to define set off?

SQL> show define
define "&" (hex 26)

SQL> set define off
SQL> /
SP2-0552: Bind variable "SV_STUDENT_ID" not declared.
SQL> set define on
SQL> /
Enter value for sv_student_id: 1
old   2:   v_student_id          number          := &sv_student_id;
new   2:   v_student_id          number          := 1;

PL/SQL procedure successfully completed.

Published by: Andy Klock on August 11, 2010 18:13 (sorry, line 7 means there was an error not 9...)

Tags: Database

Similar Questions

  • question on the layer effects and filters - Jews Becker

    Hello

    I have a question about the layer effects and filters

    first is there a way to layer effects in flash (as in photoshop 'coup' "outter glow" etc...)

    so it is a kind of plug-ins to special effects - perhaps with particles or pretty effects that I can buy

    Thank you very much!

    (as you may have guessed I'm very new at this and appreciate all the advice I can get!)

    -Jews Becker

    You won't find anything exactly like filters in Photoshop for use in Flash. There are filters in Flash. They are available at the bottom of the Properties window for an object MovieClip or button on the stage. Alternatively, you can apply and animate a filter in Actionscript. There is a good third-party developer, http://www.greensock.com, where you can find a few effects tools very useful. Most are free.

  • Basic questions about the PL/SQL web services and data source names

    Hello

    I've successfully generated a web service for a procedure from PL/SQL packaged JDeveloper 11.1.1.3.0).

    The following code was generated in the base class for web services:
     __dataSource = (javax.sql.DataSource) __initCtx.lookup("java:comp/env/jdbc/dbconnectionDS");
    However in the weblogic server, the data source name is jdbc/Gisele for deployment fails in a first time.

    What is the recommended procedure to solve this problem? The obvious solution is to manually change the source - that's what I did and it worked fine. However if I re - generate the web service I won't lose my change. Is there a better way to do it?

    Another question - in the web.xml file that is generated, there is a resource-ref to the data source. I was hoping that change the data source name it would help, but it didn't work. What is - it used to in this context?

    Thank you
    Luis

    I forgot to add, so in case some time later and you want to update the connection to your service details, all you have to do is to add the following entry in your weblogic.xml:
    .

    JDBC/ref_name_from_web. XML
    JDBC/new_jndi_name

    .
    And in this way, you will not have to change any code level to point your web service to another connection.

    Vishal-

  • Not able to post a question on the Forum SQL

    Hello

    I'm trying to post a question on the SQL forum, tried 2 times, but it does not appear.

    I am able to see my question on my Inbox, but this issue does not appear in the SQL forum.

    This is the link to my thread: transpose columns in lines

    Please help me,

    Kind regards

    Jitendra

    Indeed, it is a loophole.

    If you go to SQL and then click on the 'Content' link, you will see that need you the space of PL/SQL and if you post a discussion there, it will appear in the list of threads space the SQL and PL/SQL.

    ---

    Ping moniquevdb-Oracle and Oracle-hocinebelatreche to ask that they please untangle this loophole (or someone who can ping).  I can confirm that, following steps of Jitendra, people are still able to create threads in the old list of SQL thread when they should go to list of PL/SQL threads.

    Essentially, this means that the messages of the people will be lost to most of the community.

    I don't always put the purpose of actually having a separate SQL space, as it doesn't really seem to offer much to the what it was associated with the PL/SQL space.

  • FPGA reference questions between the station development and execution? 63195 error code

    I will do my best to describe the problem, I was see.  Note, I tried a few other messages that kind of touch on my problems, but they never seem to have a definitive solution.

    Background-

    I have 3 screws:

    VI 1) opens / runs the bitfile FPGA reference and stores the reference to a global file so that I can call the reference of other screws I need to do this as opposed to the opening of a new reference because I use the FPGA for digital communications and it adds about 100 ms to to open a new reference whenever I need to read/write in the target FPGA to host (100 ms are long in the) digital world!).  Some people use Shift Registers.  I finally called my whole army FPGA screws of TestStand to run a test automated, so it was easier to break up of my functions for open/close/read/write.

    VI 2) called the global reference of the file for FPGA, then going to a read/write node to change the settings of the target, then passes the reference out of the node back to the global reference of the file read/writable

    VI 3) calls close reference FPGA and the function is passed the global reference of the file.

    Question-

    I understand not why this method works fine when I run either of TestStand with station options defined for the development (not running) mode or when I open VI which calls these 3 screws individually in sequential order but IS NOT working when I try to run these screws individually (Run VI 1 - open-> write Ref to the global reference of the file-> Run VI 2 - read global file reference-> playback control function / writing-> error-63195) or when I have run in the same sequence TestStand but together with station for execution options.  Maybe I need to change the TestStand sequence to load all the modules at startup?

    Why the reference becomes lost when global failover between development and execution and why labview cannot drop keep the reference stored?  Is there a work around?

    Finally found a solution.  I do not understand why it is necessary during the reading of the FPGA and not what writing (in fact I do not understand why it worked at all) but I ended up changing the properties of the step in my TestStand sequence for the step calling my DTL_READ.vi to be properties-> Run Options-> Unload Option-> "Unload after executing the step.  That seemed to do the trick to get my test TestStand sequence to work in runtime.

    I still don't understand why this was not required when you run the same sequence in the design environment and why it is not when I call my DTL_WRITE.vi.

    The DTL_READ.vi and the DTL_WRITE.vi pass the parameter labveiw global.vi 'Reference FPGA VI"of a node in read/write.  I don't know if the root of the problem is in my host TestStand and LabView FPGA VI...

    Thanks for all suggestions from you guys!  I'm happy I work but I am still confused by the solution.

  • Questions after the BIOS updates and driver - place 11 pro

    Hi all

    I am owner of a place of reference dell 11 7140 model 10 64-bit windows running and about 5 days ago I installed the latest drivers and the latest version of the BIOS using the automatic detection of the dell support page www.dell.com/.../drivers printer driver

    Since then, I met the two following questions:

    1: the automatic detection of the dell driver no longer works

    2: the system does not detect when a headset is connected, the audio always comes out the speakers Tablet - I reinstalled the latest drivers, but made no difference

    I wonder if anyone else has experienced those problems and what measures have you taken to solve problems.

    Thank you

    I managed to solve the problem with the audio: it was caused by an incorrect realtek driver installatiion, for some reason any 'Realtek Audio Manager' was not loaded when you start and that's why the system doesn't detect the status of the audio input jack.

    Always have the question of the automatic recognition of the driver, but at least I have a tablet of new work!

  • Accept the user SQL and run batch

    Hi all

    I want to invite the user to enter their SQL and run it during the execution of a batch file.

    Results (after the running .bat file):

    Press any key to enter your sql

    -will be here sql user input

    You SQL statement has been executed successfully.

    Try:

    SET /P DB = [promptDBname]

    SET /P USER = [promptuserName]

    SET /P PWD = [promptPass]

    SET /P sqlText = [promptSQL]

    sqlText %Echo% > script.sql

    sqlplus %USER%/%PWD%@%DB% @script.sql

    Perversion!

    ----

    Ramin Hashimzade

  • Question about the memory consumed and active

    I have esx4.1 on three dl585 running. I have about 100 active vm running, and I have a small question.

    My vm is all 2008 r2 datacenter and I gave them 1 cpu and 4 GB of ram. When I recover a single virtual machine and look at the summary page, I see the bones of memory consumed host 4075 mb and the active guest memory 81 MB operating system. My question is can I reduce the host cunsumed memory to 2 GB without noticing a difference within the virtual machine?

    It looks like you can.   To be absolutely sure that you'd need monitor assets long enough to have a good idea of what the average is and what are the tops.

  • How to remove the extension AM and substitution of the server

    Hello

    Can someone tell me please how to remove the possibility of existing substitution and expansion of the AM of the server.

    Concerning
    Swati

    Swati,

    You can remove the substitution using the API jdr_utils.deletedocument ('').
    The path will be as "oracle/apps/ap/xx/customizations/0/server /...» »

    Kind regards
    GYAN

    Published by: Gyan on June 3, 2011 19:28

  • Using of the dynamic SQL and the cursor in a procedure

    Here is the procedure:
    create or replace
    Procedure type_paiement_total
    is
    
        cursor xbtable is select table_name from user_tables where table_name like 'XB%';
        n_table user_tables.table_name%type;
        req     varchar2(256);
        journal varchar2(2);
        mois varchar2(2);
        an varchar2(2);
      begin
        for n_table in xbtable
        loop
          execute immediate 'insert into xx_jk_xb (
          clie_code,journal, periode,origine, xb_ecri,xb_libe  ,dos_code,xb_debi,xb_cred,xb_term
    )
    select c.code,  
    substr(:1,3,2),
    substr(:1,7,2)||substr(:1,5,2)||,
    :1,  
    xb.ecri,  
    xb.libe,  
    d.code,
    xb.debi,
    xb.cred,
    xb.terme
    from                      
    '||n_table.table_name ||' xb,
    dossier d,                      
    client c                    
    where xb.cmpt=''4111''                    
    and xb.doss  =d.code                    
    and c.code   =d.clie
    and c.role=''1''' using n_table.table_name;
          execute immediate 'insert into xx_jk_logxb (recnum,xb_ref,trsf) values (seq_logmreg.nextval,:1,''OK'')' using n_table.table_name;
          commit;
          fetch xbtable into n_table;
        end loop;
      end;
    What he does (or what I intend to do)
    take the datas of a whole bunch of pictures and put them in the "XX_JK_XB" table and make a log of the tables covered in xx_jk_logxb give just the source table and the status (OK).
    Now when I run the procedure I get a "missing expression" th ' immediate «insert into xx_jk...»» »

    I just can't tell what is the problem here.

    clues?

    Seems to me that you are wrong assuming that the binding can be done by name and no position when you use immediate enforcement.

    Example:

    SQL> create table foo_tab( c1 varchar2(10), n1 number );
    
    Table created.
    
    SQL>
    SQL> begin
      2          for i in 1..10
      3          loop
      4                  execute immediate 'insert into foo_tab values( to_char(:1), :1 )' using i;
      5          end loop;
      6          commit;
      7  end;
      8  /
    begin
    *
    ERROR at line 1:
    ORA-01008: not all variables bound
    ORA-06512: at line 4
    
    SQL>
    SQL>
    SQL> begin
      2          for i in 1..10
      3          loop
      4                  execute immediate 'insert into foo_tab values( to_char(:1), :1 )' using i,i;
      5          end loop;
      6          commit;
      7  end;
      8  /
    
    PL/SQL procedure successfully completed.
    
    SQL>
    

    As you can see, 1 PL/SQL block attempts to re - use bind variable: 1 new - and only link once.

    Fact does not work like that - you must link it again. Binding is done by bind - 1 position = 1 to the help of var, 2nd = 2nd bind using var, etc.. Name of the connection variable used is irrelevant and not unique.

  • Question about the game database and the UNICODE character

    Hello

    I have to configure a database for an IBM product where is a requirement:
    "Databases must be created using the UNICODE database and National characters as UTF8 games, AL32UTF8 or AL16UTF16 or."

    My current database character is: WE8MSWIN1252. Change the current database character set is not an option, so I have to create a new db for this requirement.

    My question is:
    (1) how to ensure that "databases must be created using the UNICODE database"?

    (2) to take care of character, I'll use in the database creation script:

    "
    create the db1 database...
    ..
    CHARACTER SET US7ASCII
    NATIONAL CHARACTER SET AL16UTF16
    .."
    who will take care of him?

    create the db1 database...
    ..
    UTF8 CHARACTER
    NATIONAL CHARACTER SET AL16UTF16

  • A question about the Oracle SQL Developer Oracle instance connection

    Hi all

    I would be grateful if you could kindly give me a helping hand.

    Recently, I installed the Oracle 11 g on Linux (ubuntu 8.10) database. I not create startup scripts. So here's how I start the server: (my linux user name is "dariyoosh", but in order to start the server I have connection on the terminal shell as user 'oracle')
    dariyoosh@alborz:~$ su oracle
    Password: 
    oracle@alborz:/home/dariyoosh$ cd
    oracle@alborz:~$ ORACLE_SID=database01
    oracle@alborz:~$ . oraenv
    ORACLE_SID = [database01] ? 
    The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 is /u01/app/oracle
    oracle@alborz:~$ sqlplus '/as sysdba'
    ...
    SQL> STARTUP NOMOUNT
    ORACLE instance started.
    ...
    SQL> ALTER DATABASE MOUNT;
    ...
    SQL> ALTER DATABASE OPEN;
    
    Database altered.
    Then I can work without any problems with my database and everything works pretty well. Today, I decided to install Oracle SQL Developer IDE as it makes it easier to modify the SQL code. My problem is that after reading the tutorial Oracle online, that I am still able to connect to my database. Firstly according to the method that I wrote, I have set up the Oracle instance. But then when I run Oracle SQL Developer I don't know what to choose for the user name and password? because since SQL * Plus shell as you can see I always write: "sqlplus 'virtue sysdba' and it does not prompt me for any password, I can access the database directly." Any idea? What password? What user name? for Oracle SQL Developer?

    Thanks in advance.

    When you connect "/ as sysdba", you actually connect as the user named SYS from the privileges of your operating system. SYS is the owner of the database and a privileged user. You really want to use this username for the day to day operations, but only for what can do only SYS. If you need a different user name. Several Oracle databases have a user named SCOTT who has a number of tables for use tutorial. By default, the password for SCOTT's "Tiger." You may also have other demo users, such as "HR". I admit that I forgot what is the password of the HR, but it doesn't really matter because SYS can change with this command:

    ALTER USER hr IDENTIFIED BY whateveryouwant;
    

    This command:

    SELECT USERNAME FROM ALL_USERS;
    

    lists all the users in your database. Understand that many of these users are there as owners of objects such as stored procedures and tables for Application Express, or TYPEs for Oracle Locator, not for general use. When you are ready to create your own objects, ask SYS create a username for them with

    CREATE USER myusername IDENTIFIED BY mypassword;
    

    and grant that user the privileges as necessary. You'll want to read before you get too far - I think that the developer of the Application Guide is a good starting point.

  • Question about the Apple Watch and tattoos

    I think buy a Apple Watch very soon.

    I have a full sleeve (which is where I would like to wear the watch) and I wonder if it will cause problems with readings with the heart monitor since I want to use the Apple Watch for fitness training, mainly.

    I read on the page of the heart rate for the saying of Apple Watch:

    "Permanent or temporary changes to your skin, such as some tattoos, can also impact performance heart rate sensor. Ink, model and the saturation of some tattoos can block light from the sensor, making it difficult to get reliable readings. »

    There are other problems in addition to playback of heart rate on the Apple Watch for inked people that may know you?

    Thanks for your comments just to decide if this watch will really be for me before making this purchase, because I missed one for some time.

    If you are looking for, there was a very long discussion about this in the past, only shortly after the release of the Apple Watch. What I've read, it seems that the heart rate monitor is the only victim when it comes to the watch, since this is the only thing that requires the sensors to work through ink. Not all inks makes a difference, but most don't. The activity of exercise/app also uses the heart rate monitor to determine the rate for the year. You can take the time to go to the nearest Apple Store and try on the Apple Watch and see if the monitor works with your sleeve.

  • Question on the recovery CD and the Vista anytime upgrade

    Hello

    I bought a toshiba laptop now a year ago, it came pre-installed with vista home premium.
    I would like to do a complete cleaning my system as its useless been lately and isn't a fact since I bought.

    It came only with - a the product recovery disc and upgrade Express windows.
    But I'm worried because if I do a recovery of product I don't have the real vista disk it SHOULD have and will not have vista on my laptop or one of the files that toshiba put on it.

    What should I do?
    What a product recovery disc actually have on it and do? What is the Windows anytime upgrade disc?

    I have been informed by microsoft and I.T. technicians everywhere that i should have a vista installation disc in the same area so the fact it came pre-installed.

    Help, please

    > It came only with - a the product recovery disc and upgrade Express windows.

    As you say you have the product recovery disc.
    This Toshiba drive contains the image of Toshiba.
    The image is a package and it contains the operating system Windows, Toshiba drivers, tools, utility and software further.

    The use of the recovery CD will fix the laptop back to the factory settings.
    So just boot from the recovery CD and follow the instructions on the screen.

    Just for info:
    The recovery CD will format the whole HARD drive, but I see that a backup is not important to you.

    See you soon

  • Question about the account administrator and access

    I am logged in as administrator, but when I try to access certain programs or files that I am refused access as a limited user.

    Can anyone help?

    Jon

    Hello

    You can access files or programs by making a 'right-click' on the file/shortcut and 'left click' on 'run as administrator '. ».

    Then, the application will run wirh maximum rights and full access.

    Welcome them

Maybe you are looking for

  • NB100 - reboot problem

    Hello world. I bought a second hand NB100 off e - bay for my girlfriend and it works very well for a while. The laptop restarts unexpectedly. As the problem occurs when the laptop is moved, and it is progressively getting worse (more frequent), I thi

  • Drive DVD RW E no longer works.

    Drive DVD RW E no longer works. I'm running a gateway T-1412 with Windows Vista Home Premium Service Pack 2 DVD RW drive used to work fine, but now when I put music or a DVD in drive E that nothing happens. When I click on my computer and click on th

  • Drop-down menu are empty until the pointer is highlighted

    Original title: why are my empty drop-down lists until I put my pointer on the first word and then slide down. The words come at once? Why has my menu drop-down lists empty until I put my pointer on the first word and then slide down. The words come

  • Update Windows 10 app getwindows10

    I'm ok notify when ready to getwindows10 app for a week, but I don't get the download of the update

  • How to start a printer without going through the control panel?

    Anyone know how to pin printers at the BEGINNING instead of having to go through the app same control panel would be OK