Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help!basic SQL insert script with user prompt

Status
Not open for further replies.

Guinea

Technical User
Jun 25, 2001
26
US
Greetings:

I am just learning SQL and have been given an assignment to create a script to prompt a user for values and then enter the values into a table. I am familiar with the variable @ and @@ for queries but cannot seem to get it work for the insert function. My script is below with the spoolat the bottom. Any ideas would be greatly appreciated.!

Thanks

spool c:\oracle\Ora81\BIN\SQL_SCRIPTS\InsertScript1projectSpool;

Accept v_vol_first Prompt 'What is the volunteers first name? '
Accept v_vol_mi Prompt'Middle Initial? '
Accept v_vol_last Prompt 'Last? '
Accept v_vol_home_phone prompt 'Home phone number? '
Accept v_vol_FAX Prompt 'Home FAX number? '
Accept v_vol_work_phone Prompt'Work phone? '
Accept v_vol_work_FAX Prompt'Work FAX? '
Accept v_vol_Email Prompt 'Email address? '
Accept v_vol_comments Prompt 'Enter comments about this volunteer '

set echo on;

insert into volunteer(vol_id,first,mi, last,user_id,
home_phone,home_fax,work_phone,work_fax,email_address, comments)
values(vol_id_seq.NEXTVAL, '@@v_vol_first', '@@v_vol_mi','@@v_vol_last', USER_ID_SEQ.NEXTVAL ,
'@@v_vol_home_phone','@@v_vol_FAX','@@v_vol_work_phone',
'@@v_vol_work_FAX','@@v_vol_email','@@v_vol_comments');

set echo off;
spool off;
/

From spool:
SQL> insert into volunteer(vol_id,first,mi, last,user_id,
2 home_phone,home_fax,work_phone,work_fax,email_address, comments)
3 values(vol_id_seq.NEXTVAL, '@@v_vol_first', '@@v_vol_mi','@@v_vol_last', USER_ID_SEQ.NEXTVAL ,
4 '@@v_vol_home_phone','@@v_vol_FAX','@@v_vol_work_phone',
5 '@@v_vol_work_FAX','@@v_vol_email','@@v_vol_comments');
insert into volunteer(vol_id,first,mi, last,user_id,
*
ERROR at line 1:
ORA-01401: inserted value too large for column

I have tried using single @ ,no ' ', inserting the vol_id first and then trying to update using a vol_id_seq.CURRVAL.
 
You've used @(at) symbol that means 'run' instead of &(ampersand), meaning 'define'
 
DOH!! I swear I am dislexic at times. Thanks for pointing out my mistake!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top