Oracle : Error in Declare - sql

I am trying to execute the following query in PL/SQL developer:
DECLARE
P_FILENAME VARCHAR2(200):= 'file1.csv';
P_DIRECTORY VARCHAR2(200):= 'ORA_DIR';
P_IGNORE_HEADERLINES NUMBER := 1;
BEGIN
Load_file( P_FILENAME => P_FILENAME, P_DIRECTORY => P_DIRECTORY, P_IGNORE_HEADERLINES => P_IGNORE_HEADERLINES );
END
I get the error :
ORA-06550: line 9, column 0:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
; <an identifier> <a double-quoted delimited-identifier>
The symbol ";" was substituted for "end-of-file" to continue.
Where am I going wrong here.

you are missing a semi colon on the end statement:
DECLARE
P_FILENAME VARCHAR2(200):= 'file1.csv';
P_DIRECTORY VARCHAR2(200):= 'ORA_DIR';
P_IGNORE_HEADERLINES NUMBER := 1;
BEGIN
Load_file( P_FILENAME => P_FILENAME, P_DIRECTORY => P_DIRECTORY,
P_IGNORE_HEADERLINES => P_IGNORE_HEADERLINES );
END;
/

Related

SS2K5ALLPLATFORM Return error at Oracle Database 19c

I am trying to move ms sql to oracle(migration). But I have error. I use SQL server Management 18 and Oracle Database 19c. I already connected to each other. This is my SS2K5ALLPLATFORM package;
create or replace PACKAGE SS2K5ALLPLATFORM AS
FUNCTION StageCapture(projectId NUMBER, pluginClassIn VARCHAR2, projExists BOOLEAN:=FALSE, p_scratchModel BOOLEAN := FALSE) RETURN VARCHAR2;
FUNCTION amINewid(myc clob) return number; -- public function as called from sql
Function getPrecision(typein varchar2 , precisionin number, scalein number) return number; -- public function as called from sql
Function getnewscale(typein varchar2 , precisionin number, scalein number) return number; -- public function as called from sql
FUNCTION printUDTDef(basename VARCHAR2, p NUMBER, s NUMBER,m NUMBER ) RETURN VARCHAR2; --public function used from sql
FUNCTION GetStatus(iid INTEGER) RETURN VARCHAR2; END;
And this area give me error;
DECLARE
PROJECTID NUMBER;
PLUGINCLASSIN VARCHAR2(200);
PROJEXISTS BOOLEAN;
P_SCRATCHMODEL BOOLEAN;
v_Return VARCHAR2(200);
BEGIN
PROJECTID := NULL;
PLUGINCLASSIN := NULL;
PROJEXISTS := NULL;
P_SCRATCHMODEL := NULL;
v_Return := SS2K5ALLPLATFORM.STAGECAPTURE(
PROJECTID => PROJECTID,
PLUGINCLASSIN => PLUGINCLASSIN,
PROJEXISTS => PROJEXISTS,
P_SCRATCHMODEL => P_SCRATCHMODEL
);
/* Legacy output:
DBMS_OUTPUT.PUT_LINE('v_Return = ' || v_Return);
*/
:v_Return := v_Return;
--rollback;
END;
And my error log is below.
Connecting to the database SqltoOracle.
ORA-06510: PL/SQL: işlenmemiş kullanıcı-tanımlı istisna
ORA-06512: konum "MIGRATIONS.SS2K5ALLPLATFORM", satır 3313
ORA-01403: hiç veri bulunmadı
ORA-06512: konum "MIGRATIONS.SS2K5ALLPLATFORM", satır 3280
ORA-06512: konum satır 13
Capture:LogInfo Failed: [StageCapture Failed: [ORA-01403: hiç veri bulunmadı
ORA-06512: konum "MIGRATIONS.SS2K5ALLPLATFORM", satır 3280
] nSvrId: ] insert exception: ORA-04098: tetikleyici 'MIGRATIONS.STAGE_MIGRLOG_ID_TRG'
geçersiz ve yeniden doğrulamada başarısız oldu
ORA-01403: hiç veri bulunmadı
ORA-06512: konum "MIGRATIONS.SS2K5ALLPLATFORM", satır 93
ORA-06512: konum "MIGRATIONS.SS2K5ALLPLATFORM", satır 3280
Process exited.
Disconnecting from the database SqltoOracle.
Thank you your attention.
Various errors have been reported.
ORA-06510 means that there's user-defined exception in that code; it was raised, but it was never handled.
ORA-01403 is also here, and it means NO_DATA_FOUND. Maybe SS2K5ALLPLATFORM.STAGECAPTURE (which is called in that piece of code) raises that exception, but you didn't handle it. Something like this:
begin
raise no_data_found;
-- this is missing:
exception
when no_data_found then null;
end;

PLS 00103 error: Encountered the Symbol: IS, end-of -file

The below query when executed is giving errors: PLS 00103. Can you please help me find out the erros here. I have tried other combinations like ELSIF, but all give errors.
CREATE OR REPLACE
FUNCTION fnExpirationDateCondition
(
ExpirDateStr IN VARCHAR2,
OptionDateStr IN VARCHAR2 ) // Error 1 here
RETURN INTEGER ExpirDate DATE; // Error 2 here
OptionDate TIMESTAMP;
IS
BEGIN
ExpirDate :=TO_DATE(ExpirDateStr,'YYYY-MM-DD');
OptionDate :=TO_TIMESTAMP(OptionDateStr, 'YYYY-MM-DD HH24:MI:SS.FF');
IF(ExpirDate > OptionDate) THEN
RETURN 1;
ELSE
IF(ExpirDate < OptionDate) THEN // Error 3 here
RETURN -1;
ELSE
RETURN 0;
END IF;
END IF;
END;
Errors:
1.) Encountered the symbol "ExpirDate" when expecting one of the following:
2.) Encountered the Symbol "IS" when expecting one of the following:
3.) Encountered the symbol "end-of-file" when expecting one of the following:
I have also tried replacing ExpirDate :=TO_DATE(ExpirDateStr,'YYYY-MM-DD') with TO_DATE(ExpirDateStr,'YYYY-MM-DD') INTO ExpirDate. it doesn't seemed to work.
Any suggestions will be really helpful.
The issue is that you've got your variable declarations happening before the IS that marks the start of the function's declaration section.
Try this, instead:
create or replace function fnexpirationdatecondition
(expirdatestr in varchar2,
optiondatestr in varchar2)
return integer
is
expirdate date;
optiondate timestamp;
begin
expirdate := to_date(expirdatestr,'YYYY-MM-DD');
optiondate := to_timestamp(optiondatestr, 'YYYY-MM-DD HH24:MI:SS.FF');
if(expirdate > optiondate) then
return 1;
elsif(expirdate < optiondate) then
return -1;
else
return 0;
end if;
end fnexpirationdatecondition;
/
Or, alternatively, you could just have a single return statement (recommended), and just use a case statement to handle the if-elsif-else logic:
create or replace function fnexpirationdatecondition
(expirdatestr in varchar2,
optiondatestr in varchar2)
return integer
is
expirdate date;
optiondate timestamp;
begin
expirdate := to_date(expirdatestr,'YYYY-MM-DD');
optiondate := to_timestamp(optiondatestr, 'YYYY-MM-DD HH24:MI:SS.FF');
return case when (expirdate > optiondate) then 1
when (expirdate < optiondate) then -1
else 0
end;
end fnexpirationdatecondition;
/

Encountered the symbol "DECLARE" and Encountered the symbol "end-of-file"

I'm following a tutorial from Oracle, and in the last step I'm trying to execute a SQL script where I get the errors from DECLARE and end-of-file. Any idea where I went wrong? The following is the script:
create or replace
PROCEDURE ENQUEUE_TEXT(
payload IN VARCHAR2 )
AS
enqueue_options DBMS_AQ.enqueue_options_t;
message_properties DBMS_AQ.message_properties_t;
message_handle RAW (16);
user_prop_array SYS.aq$_jms_userproparray;
AGENT SYS.aq$_agent;
header SYS.aq$_jms_header;
MESSAGE SYS.aq$_jms_message;
BEGIN
AGENT := SYS.aq$_agent ('', NULL, 0);
AGENT.protocol := 0;
user_prop_array := SYS.aq$_jms_userproparray ();
header := SYS.aq$_jms_header (AGENT, '', 'aq1', '', '', '', user_prop_array);
MESSAGE := SYS.aq$_jms_message.construct (0);
MESSAGE.set_text (payload);
MESSAGE.set_userid ('Userid_if_reqd');
MESSAGE.set_string_property ('JMS_OracleDeliveryMode', 2);
--(header, length(message_text), message_text, null);
DBMS_AQ.enqueue (queue_name => 'userQueue', enqueue_options => enqueue_options,
message_properties => message_properties, payload => MESSAGE, msgid => message_handle );
COMMIT;
END ENQUEUE_TEXT;
DECLARE
PAYLOAD varchar2(200);
BEGIN
PAYLOAD := 'Hello from AQ !';
ENQUEUE_TEXT(PAYLOAD => PAYLOAD);
END;
You have to put a / after the proc creation.
....
message_properties => message_properties, payload => MESSAGE, msgid => message_handle );
COMMIT;
END ENQUEUE_TEXT;
/
--COMMIT;
--/
DECLARE
PAYLOAD varchar2(200);
BEGIN
PAYLOAD := 'Hello from AQ !';
ENQUEUE_TEXT(PAYLOAD => PAYLOAD);
END;
And maybe a COMMIT; is missing.

IBQuery insert - Column unknown / Unsupported feature

Im trying to insert a row into a firebird database (embedded), but geting an exception when calling:
datamodule1.IBQuery1.prepare
Project xyz.exe raised exception class EIBInterBaseError with message
'Dynamic SQL Error SQL error code = -206 Column unknown INDEX_ At
line, column 25'.
with datamodule1.IBQuery1 do
begin
close;
With SQL do
begin
clear;
Add( 'INSERT INTO MST_EVENTS (eventindex, state_, event_, param_, date_, time_, devID_, gateway_)' );
Add( 'VALUES (:eventindex, :state_, :event_, :param_, :date_, :time_, :devid_, :gateway_') );
end;
//
GeneratorField.Field := 'Nr_';
GeneratorField.Generator := 'GEN_MST_EVENTS_ID';
//
Params[0].AsInteger := FMst.EventRecordIndex;
Params[1].AsSmallInt := FMst.EventRecordState;
Params[2].AsString := eventToStr(FMst.EventRecordEvent);
Params[3].AsSmallInt := 0;
Params[4].AsDate := FMst.EventRecordDate;
Params[5].AsTime := FMst.EventRecordTime;
Params[6].AsLongWord := FMst.EventRecordDevID;
Params[7].AsString := FMst.EventRecordIP;
//
if ( prepared = false ) then
prepare; //Throws an exception here (SOLVED)
execSQL; //Now getting exception here
end;
I have the following components tied together:
IBDatabase
IBTransaction
DataSource
IBQuery
Above problem solved - Edit >>
Ok, i have changed
Add( 'INSERT INTO MST_EVENTS (eventindex, state_, event_, param_, date_, time_, devID_, gateway_)' );
to
Add( 'INSERT INTO MST_EVENTS ("eventindex", "state_", "event_", "param_", "date_", "time_", "devID_", "gateway_")' );
... (so im using quotation marks) and now it finds the fields, but get another exception at line:
IBQuery1.execSQL:
Exception class EIBClientError with message 'Unsupported feature'
My fields are:
Nr_ : INTEGER
eventindex : INTEGER
state_ : SMALLINT
event_ : VARCHAR(50)
param_ : SMALLINT
date_ : DATE
time_ : TIME
devID_ : BIGINT
gateway_ : VARCHAR(50)
Firebird version is 2.5 embedded 32bit
I took out all the string and date/time parameters, yet i get the exception.
Using IBExpert and the same client/server .dll i can insert the row flawlessly (using all the values).
The solution was changing line
Params[6].AsLongWord := FMst.EventRecordDevID;
to
Params[6].AsLargeInt := FMst.EventRecordDevID;
But please how to auto-increment the field 'Nr_'?
with datamodule1.IBQuery1 do
begin
close;
With SQL do
begin
clear;
Add( 'INSERT INTO MST_EVENTS (eventindex, state_, event_, param_, date_, time_, devID_, gateway_)' );
Add( 'VALUES (:eventindex, :state_, :event_, :param_, :date_, :time_, :devid_, :gateway_') );
end;
//
GeneratorField.Field := 'Nr_';
GeneratorField.Generator := 'GEN_MST_EVENTS_ID';
//
Params[0].AsInteger := FMst.EventRecordIndex;
Params[1].AsSmallInt := FMst.EventRecordState;
Params[2].AsString := eventToStr(FMst.EventRecordEvent);
Params[3].AsSmallInt := 0;
Params[4].AsDate := FMst.EventRecordDate;
Params[5].AsTime := FMst.EventRecordTime;
Params[6].AsLargeInt := FMst.EventRecordDevID;
Params[7].AsString := FMst.EventRecordIP;
//
if ( prepared = false ) then
prepare; //Throws an exception here (SOLVED)
execSQL; //Now getting exception here
end;
I made the generator in flamerobin.
But getting exception (at calling 'execSQL'):
EDIT >>
I set up a generator and a BEFORE INSERT trigger in IBExpert:
And now its ok.

Error: illegal Expression

I have this code:
tInteger :
begin
if(jinfo<maxinfo) then
begin
jinfo:=jinfo+1;
lokasi[jinfo]:=ScanStr;
WRITE(ResFile,jinfo:4);
end;
WRITE(ResFile,' ');
WRITE(ResFile,inum);
end;`
BEGIN
ScanStr:='';
REPEAT
ScanStr:=ScanStr+cc;
ReadChar;
UNTIL NOT (cc in ['a'..'z','A'..'Z','0'..'9','_']);
{Test KeyWord}
TampStr:=UpperCase(ScanStr);
i:=1; j:=JmlKeyWord; {index pencarian keyword dalam tabel}
REPEAT
k:=(i+j) DIV 2;
IF TampStr<=KeyWord[k] THEN j:=k-1;
IF TampStr>=KeyWord[k] THEN i:=k+1;
UNTIL i>j;
IF i-j>1 THEN
BEGIN k:=k+ORD(tKurungTutup); Token := KeyToken; END
ELSE
BEGIN Token := tIdentifier;
ScanStr:=COPY(ScanStr,1,10); END;
end;
But the script gives me this error:
error:illegal expression
error:ordinal expression expected
fatal: Syntax Error,: Expected but identifier SCANSTR found
I don't understand this error message. I'm sure this script was right.
The "script" (which isn't a script - it's code) is wrong.
You're inside a case statement:
tInteger :
begin
if(jinfo<maxinfo) then
begin
jinfo:=jinfo+1;
lokasi[jinfo]:=ScanStr;
WRITE(ResFile,jinfo:4);
end;
WRITE(ResFile,' ');
WRITE(ResFile,inum);
end;
The only thing valid after that is either another case branch, an optional else clause, or a final end.
case TheThing of
ThingA:
begin
// Code here
end;
ThingB:
begin
// Code here
end;
else
// Else code here
end;
You have another full begin..end block, which is invalid syntax.
BEGIN
ScanStr:='';
REPEAT
ScanStr:=ScanStr+cc;
ReadChar;
UNTIL NOT (cc in ['a'..'z','A'..'Z','0'..'9','_']);
{Test KeyWord}
TampStr:=UpperCase(ScanStr);
i:=1; j:=JmlKeyWord; {index pencarian keyword dalam tabel}
REPEAT
k:=(i+j) DIV 2;
IF TampStr<=KeyWord[k] THEN j:=k-1;
IF TampStr>=KeyWord[k] THEN i:=k+1;
UNTIL i>j;
IF i-j>1 THEN
BEGIN k:=k+ORD(tKurungTutup); Token := KeyToken; END
ELSE
BEGIN Token := tIdentifier;
ScanStr:=COPY(ScanStr,1,10); END;
end;