刚开始做一些PL / SQL,我需要一些帮助来创建我被分配到练习的程序:
创建一个包含两个输入的过程 - firstname和surname。该 程序应该DBMS输出以下3行:
firstname surname (lowercase) FIRSTNAME SURNAME (uppercase) Firstname Surname (Initial uppercase)
以下PL / SQL函数可用于协助:
UPPER( VARCHAR2 ), LOWER(VARCHAR2), INITCAP( VARCHAR2 )
到目前为止我已经尝试过了:
CREATE OR REPLACE PROCEDURE LabFourProc (firstname IN VARCHAR2, surname IN VARCHAR2)
IS
BEGIN
DBMS_OUTPUT.PUT_LINE(firstname, surnmame);
END LabFourProc;
/
答案 0 :(得分: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;
/
答案 1 :(得分:0)
您可以使用CONCAT()
函数或||
运算符来连接字符串。例如:
-- outputs "firstname surname"
DBMS_OUTPUT.PUT_LINE(firstname || ' ' || surnmame);
答案 2 :(得分: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');