user4601096
user4601096

Reputation:

USER INPUT SQL for name

SELECT PNAME,POSITION FROM PLAYER
WHERE Pname = 'Andrew Laken';

So basically im using sql developer and im trying to get a user input box to display to enter then name of the basketball player, have done this sort of thing on MySQL and MS Access but for the life of me cant get it work in SQL Developer. Any idea how? also one thing I don't know how to do on any software that uses SQL is error handling. If data correct display successful, if not error etc. If anyone could add that into the solution for this problem that would be Very helpful :D

Upvotes: 0

Views: 816

Answers (2)

sql_dummy
sql_dummy

Reputation: 745

    SELECT PNAME,POSITION FROM PLAYER WHERE Pname = &enter_name;

Upvotes: 0

user5683823
user5683823

Reputation:

Bind variables are indicated by a colon as the first character, like this:

SELECT (...)  -- your "SELECT" clause here
FROM (...)
WHERE Pname = :pname

Each interface (like SQL Developer) has its own method for passing in parameters. In SQL Developer in particular, if you enter this query in the Query Builder and try to execute it, a window will pop up asking you for the value you want to enter for :pname.

Error handling: There is no "developer" handling of errors in straight SQL in Oracle; if you want to handle specific (non-system) errors you will have to write your own procedures/functions/packages.

Upvotes: 2

Related Questions