-1

Just started doing some PL/SQL and I need some help creating a procedure I was assigned to practice:

Create a procedure that has two inputs - firstname and surname. The procedure should DBMS output the following 3 lines:

firstname surname (lowercase) 
FIRSTNAME SURNAME (uppercase) Firstname 
Surname (Initial uppercase)

The following PL/SQL functions can be used to assist:

UPPER( VARCHAR2 ), LOWER(VARCHAR2), INITCAP( VARCHAR2 )

I've tried this so far:

CREATE OR REPLACE PROCEDURE LabFourProc (firstname IN VARCHAR2, surname IN VARCHAR2)
IS
BEGIN
  DBMS_OUTPUT.PUT_LINE(firstname, surnmame);
END LabFourProc;
/
4

3 回答 3

1

伙计,我也是新手。试试这个,如果这有帮助

CREATE OR REPLACE PROCEDURE LabFourProc (firstname IN VARCHAR2, surname IN VARCHAR2)
IS
BEGIN
DBMS_OUTPUT.ENABLE (1000000); 
DBMS_OUTPUT.PUT_LINE('Input Parameters:'|| firstname ||CHR(9)|| surname ||CHR(10)||
'Upper Name:' || upper(firstname)||CHR(9)||upper(surname)||CHR(10)||
'Lower Name:' || lower(firstname)||CHR(9)||lower(surname)||CHR(10)||
'First Leter Cap Name:' || initcap(firstname)||CHR(9)||initcap(surname));
END;
/
于 2013-04-12T00:29:25.547 回答
0

您可以使用CONCAT()函数或||运算符来连接字符串。例如:

-- outputs "firstname surname"
DBMS_OUTPUT.PUT_LINE(firstname || ' ' || surnmame);
于 2013-04-11T11:36:26.983 回答
0
CREATE OR REPLACE PROCEDURE
p1(fn varchar2, sn varchar2)
is
BEGIN
DBMS_OUTPUT.PUT_LINE(lower(fn)||' '||lower(sn)||','||upper(fn)||' '||upper(sn)||','||initcap(fn)||' '||initcap(sn));
END;

执行

EXEC P1('ANYA','ROMANOVA');
于 2018-03-09T15:51:52.597 回答