Error : PLS-00103: Encountered the symbol "END" when expecting one of the following - plsql

I wrote the following Package and Package body:
create or replace package discounts
is
g_id number := 7839;
discount_rate number := 0.0;
procedure display_price(p_price number);
end;
/
create or replace package body discounts
is
procedure display_price(p_price number)
is
begin
dbms_output.put_line('Discount rate 1:'||discount_rate);
dbms_output.put_line('Discounted '||to_char(p_price * nvl(discount_rate,0)));
dbms_output.put_line('Discount rate 2:'||discount_rate);
end;
begin
dbms_output.put_line('Discount rate 3:'||discount_rate);
discount_rate := 0.10;
dbms_output.put_line('Discount rate 4:'||discount_rate);
end;
/
It is written that "The value of discount_rate is set to 0.10 when the package is invoked for the first time in a session". I am not getting this point exactly that's why I checked the value each time of discount rate. I typed the following to invoke:
SQL> execute discounts.display_price(1000);
Discount rate 3:0
Discount rate 4:.1
Discount rate 1:.1
Discounted 100
Discount rate 2:.1
Then again I invoked the variable:
begin
dbms_output.put_line('Discount rate :'||discounts.discount_rate);
end;
SQL> /
Discount rate :.1
Then I typed "exit" to close the SQL *PLUS. Again I opened SQL *PLUS and typed the same code:
begin
dbms_output.put_line('Discount rate :'||discounts.discount_rate);
end;
I thought it will not initialize the variable but I got the error:
ERROR at line 3:
ORA-06550: line 3, column 1:
PLS-00103: Encountered the symbol "END" when expecting one of the following:
:= . ( % ;
The symbol ";" was substituted for "END" to continue.
What is the mistake ? I am new to PL/SQL preparing for certification exam.

Sorry, I could not reproduce the error you showed:
C:\>sqlplus user/password
SQL*Plus: Release 11.2.0.2.0 Production on Sat Mar 23 11:31:19 2013
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
SQL> set serveroutput on
SQL> execute discounts.display_price(1000);
Discount rate 3:0
Discount rate 4:.1
Discount rate 1:.1
Discounted 100
Discount rate 2:.1
PL/SQL procedure successfully completed.
SQL> begin
2 dbms_output.put_line('Discount rate :'||discounts.discount_rate);
3 end;
4 /
Discount rate :.1
PL/SQL procedure successfully completed.
SQL> exit
Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
C:\>sqlplus user/password
SQL*Plus: Release 11.2.0.2.0 Production on Sat Mar 23 11:31:50 2013
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
SQL> set serveroutput on
SQL> begin
2 dbms_output.put_line('Discount rate :'||discounts.discount_rate);
3 end;
4 /
Discount rate 3:0
Discount rate 4:.1
Discount rate :.1
PL/SQL procedure successfully completed.
SQL>

Related

Why Oracle weblogic server logs does not show DBMS_OUTPUT.PUT_LINE outputs?

I have included some DBMS_OUTPUT.PUT_LINE inside my PLSQL package procedure. I wanted print these output in weblogic application server logs. But it does not show my DBMS_OUTPUT in weblogic server log. Currently, I use Log4j for server logging. Is there any extra configuration needed for this ? Thanks
Did you SET SERVEROUTPUT ON? Without it, DBMS_OUTPUT.PUT_LINE won't display anything.
This is what you have:
SQL> begin
2 dbms_output.put_line('Hello, this is me!');
3 end;
4 /
PL/SQL procedure successfully completed.
When output is enabled:
SQL> set serveroutput on
SQL> begin
2 dbms_output.put_line('Hello, this is me!');
3 end;
4 /
Hello, this is me!
PL/SQL procedure successfully completed.
SQL>

EXECUTE statement failed because its WITH RESULT SETS clause specified 1 result set

I'm trying to run a simple R code in SQL Server 2016:
EXEC sp_execute_external_script
#language =N'R',
#script=N'OutputDataSet<-InputDataSet',
#input_data_1 =N'SELECT 1 AS hello'
WITH RESULT SETS (([hello] int not null));
GO
I have followed this link to configure: https://tomaztsql.wordpress.com/2016/07/26/enabling-sp_execute_external_script-to-run-r-scripts-in-sql-server-2016/
I'm getting error:
Msg 39023, Level 16, State 1, Procedure sp_execute_external_script,
Line 1 [Batch Start Line 0]
'sp_execute_external_script' is disabled on this instance of SQL
Server. Use sp_configure 'external scripts enabled' to enable it.
Msg 11536, Level 16, State 1, Line 1
EXECUTE statement failed because its WITH RESULT SETS clause specified 1
result set(s), but the statement only sent 0 result set(s) at run time.
when I checked with :
EXECUTE sp_configure;
GO
The result shows like this:
name minimum maximum config_value run_value
external scripts enabled 0 1 1 0
Why the run value is still 0 (note-I have SQL Server Launchpad restarted)? What is the resolution for this?
Issue resolved. need to restart SQL Server services. Which will restart everything. And its working fine.

Not able to connect to Oracle user

I have installed Oracle 11g version - Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production.
I have created a user called K_demo. But I am not able to connect to the user using sqlplus. Getting below error.
SQL*Plus: Release 11.2.0.1.0 Production on Sun Apr 16 10:35:08 2017
Copyright (c) 1982, 2010, Oracle. All rights reserved.
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified
Enter user-name:**
Although I am able to connect from sys using conn
SQL> conn K_DEMO/"pass#123"#ORCL
Connected.
SQL> show user;
USER is "K_DEMO"
SQL>
what could be the reason?

Why the expdp can't see this table? It's there?

Does anyone know why this is happening? I can select the table but
can't export it.
C:\>sqlplus myschema/myschema
SQL*Plus: Release 12.1.0.2.0 Production on Mon Aug 1 14:43:45 2016
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Last Successful login time: Mon Aug 01 2016 14:42:51 -04:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics, and Real Application Testing opt
ions
SQL> select * from product;
ID NAME
---------- --------------------
1 sample_product_name
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64
bit Production
With the Partitioning, OLAP, Advanced Analytics, and Real Application Testing opt
ions
C:\>expdp myschema/myschema#oradev tables=product directory=DATA_PUMP_DIR dumpfi
le=expdp_myschema.dmp logfile=expdp_myschema.log
Export: Release 12.1.0.2.0 - Production on Mon Aug 1 14:44:16 2016
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit
Production
With the Partitioning, OLAP, Advanced Analytics, and Real Application Testing opt
ions
WARNING: Oracle Data Pump operations are not typically needed when connected to
the root or seed of a container database.
Starting "MYSCHEMA"."SYS_EXPORT_TABLE_01": myschema/********#oradev tables=prod
uct directory=DATA_PUMP_DIR dumpfile=expdp_myschema.dmp logfile=expdp_myschema.l
og
Estimate in progress using BLOCKS method...
Total estimation using BLOCKS method: 0 KB
Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
**ORA-39166: Object MYSCHEMA.PRODUCT was not found** or could not be exported or imp
orted.
ORA-31655: no data or metadata objects selected for job
Job "MYSCHEMA"."SYS_EXPORT_TABLE_01" completed with 2 error(s) at Mon Aug 1 14:4
4:18 2016 elapsed 0 00:00:01
Add parameter CONTENT=ALL at the end of your expdp command line,like this:
expdp myschema/myschema#oradev tables=product directory=DATA_PUMP_DIR dumpfi le=expdp_myschema.dmp logfile=expdp_myschema.log CONTENT=ALL
and execute it.

FAST LOAD - FDL4818 FastLoad Terminated Error

I have created Below fast load scripts which is loading data from flat file to teradata table.
fastload << EOF >> ${BASE_DIR}/Test_Load_Fastload_log
SESSIONS 4;
.logon ${TDPID}/${TD_LOGON}
SET RECORD VARTEXT " ";
Define
WSID (VARCHAR(10)),
Server_Name (VARCHAR(30)),
Technology (VARCHAR(50)),
Env (VARCHAR(10))
File=$BASE_DIR/workstation_source.dat;
BEGIN LOADING WORK_DB.WS_test
ERRORFILES WORK_DB.WS_test_Err1,WORK_DB.WS_test_Err2
;
INSERT INTO WORK_DB.WS_test VALUES
(:WSID,
:Server_Name,
:Technology,
:Env );
END LOADING;
This is loading data successfully in table but giving return code as 0.
But after that fast load is being teminated with FDL4818 FastLoad Terminated Error.
Below is the log.
06:37:08 Logging off all sessions
* 06:37:09 Total processor time used = '0.1 Seconds'
. Start : Thu Jun 6 06:37:04 2013
. End : Thu Jun 6 06:37:09 2013
. Highest return code encountered = '0'.
*** 06:37:09 FDL4818 FastLoad Terminated
Try including a .QUIT; or a .LOGOFF; command at the end of your script.
EDIT
The FDL4818 FastLoad Terminated message is a normal part of the completion message for a FastLoad job that has completed outside the Loading Phase. FastLoad jobs completing within the Loading Phase will display FDL4818 FastLoad Paused instead.
This completion message will not affect the return code that is returned to the operating system or parent process.
This a message not an error.
You should check the following part of the message to check if there was an error or not:
* Highest return code encountered = *
If the value is 0, as in your case, the job is completed successfully without any ERROR.
If value is other than 0, e.g 8 or 12, there is some error.

Resources