Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FEILKODE:
- Error(10,19): PLS-00103: Encountered the symbol "INTO" when expecting one of the following: constant exception <an identifier> <a double-quoted delimited-identifier> table long double ref char time timestamp interval date binary national character nchar
- Error(11,1): PLS-00103: Encountered the symbol "LV_CHALLENGETYPE_TXT"
- Error(23,8): PLS-00103: Encountered the symbol "LV_ACCEPTANCEDATE_DATE" when expecting one of the following: into <a SQL statement>
- Error(24,1): PLS-00103: Encountered the symbol "AND" when expecting one of the following: . ( , % from
- /*
- ACCEPT_CHALLENGE_sp. Given a member email and a challenge identifier, insert a
- row into the CR_ACCEPTANCE table. The procedure will have to look up the member
- identifier that corresponds to the member indicated. If no value is provided
- for the acceptance date, use today’s date. The procedure should also insert a
- value of ‘active’ for the acceptance status. If the challenge is of type
- ‘immediate’, then the carbon amount for the challenge should be inserted into
- the acceptance carbon credit column. The procedure should check that there
- doesn't already exist another acceptance for this challenge that is active for
- the same member. (A member can't accept the same challenge twice at the same
- time.) If this is the case, the procedure should display an appropriate
- message.
- */
- create or replace procedure ACCEPT_CHALLENGE_sp (
- p_memberEmail IN VARCHAR2,
- p_challengeID IN INTEGER,
- p_acceptanceDate IN DATE
- ) AS
- lv_memberEmail_txt CR_MEMBER.MEMBER_EMAIL;
- lv_challengeID_num CR.CHALLENGE.CHALLENGE_ID;
- lv_acceptanceDate_dat CR_ACCEPTANCE.ACCEPTANCE_DATE;
- lv_carbonAmt_num CR_CHALLENGE.CHALLENGE_CARBON_CREDIT;
- lv_challengeType_txt CR_CHALLENGE.CHALLENGE_TYPE;
- ex_alreadyaccepted_error EXCEPTION;
- BEGIN
- SELECT MEMBER_EMAIL, ACCEPTANCE_STATUS
- INTO lv_memberEmail_txt, lv_acceptanceStatus_txt
- FROM CR_MEMBER, CR_ACCEPTANCE
- WHERE MEMBER_EMAIL = p_memberEmail;
- IF p_memberEMAIL = lv_memberEmail_txt
- AND p_challengeID = lv_challengeID_num
- THEN
- INSERT lv_acceptanceDate_date INTO CR_ACCEPTANCE.ACCEPTANCE_DATE
- AND INSERT ('ACTIVE') INTO CR_ACCEPTANCE.ACCEPTANCE_STATUS
- AND lv_challengeType = ('immediate')
- THEN INSERT lv_challengeamt_num INTO CR_CHALLENGE_CARBON_CREDIT;
- ELSIF
- p_memberEMAIL = lv_memberEmail_txt
- AND p_challengeID = lv_challengeID_num,
- AND P_acceptancedate =< 0 OR NULL,
- INSERT SYSTIMESTAMP INTO CR_ACCEPTANCE.ACCEPTANDE_DATE,
- AND INSERT ('ACTIVE') INTO CR_ACCEPTANCE.ACCEPTANCE_STATUS,
- AND lv_challengeType = ('immediate'),
- THEN INSERT lv_challengeamt_num INTO CR_CHALLENGE_CARBON_CREDIT;
- ELSE
- p_memberEMAIL = lv_memberEmail_txt
- AND p_challengeID = lv_challengeID_num
- AND P_acceptancedate =< 0
- THEN INSERT DATE := SYSTIMESTAMP + 1 INTO CR_ACCEPTANCE.ACCEPTANDE_DATE;
- AND INSERT ('ACTIVE') INTO CR_ACCEPTANCE.ACCEPTANCE_STATUS
- AND lv_challengeType = ('immediate')
- THEN INSERT lv_challengeamt_num INTO CR_CHALLENGE_CARBON_CREDIT;
- AND CR_ACCEPTANCE.ACCEPTANCE_DATE = lv_acceptanceDate_date
- THEN RAISE ex_alreadyaccepted_error;
- EXCEPTION
- When ex_alreadyaccepted_error
- THEN DBMS_OUTPUT.PUT_LINE ('You have already accepted this challenge');
- ROLLBACK;
- END ACCEPT_CHALLENGE_sp;
- /
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement