errer at line 1 ORA-01034 : ORACLE not available - sql

I have this error when I want to execute a query
select * from vehicule
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0

Related

No more data to read from socket after execute this sql

Why when I execute this SQL using SQL Developer it said
No more data to read from socket
but when I reconnect the connection then remove fetch next 5 rows only it executes perfectly?
It also happens when I execute this query on web application, it gives this error:
oci_execute(): ORA-03113: end-of-file on communication channel
Process ID: 4136
Session ID: 18
Serial number: 36957
SELECT PO_ID,
ENQ_ID,
TITLE,
SYS_BRKDWN_ID,
TECH_HAND_USR_ID,
PROJ_NO,
SUPPL_NO,
approver_usr_id,
VER
FROM S181
WHERE approver_usr_id ='EETEC'
and reject_date is null
AND po_hdr_biz.can_approve(po_id, enq_id, ver,'EETEC') = 1
AND EXISTS (
SELECT NULL
FROM po_approvals
WHERE po_approvals.po_id = s181.po_id
AND po_approvals.ver = s181.ver
AND po_approvals.init = 'EETEC'
AND po_approvals.init = s181.approver_usr_id
AND po_approvals.po_id IS NOT NULL
AND po_approvals.approve_date IS NULL
UNION
SELECT NULL
FROM po_approvals
WHERE po_approvals.enq_id = s181.enq_id
AND po_approvals.ver = s181.ver
AND po_approvals.init = 'EETEC'
AND po_approvals.init = s181.approver_usr_id
AND po_approvals.enq_id IS NOT NULL
FETCH NEXT 5 ROWS ONLY
);

Error 1064 you have error in Mysql bench syntax

Last two line show error .MY sqlwork bench show syntax error in last two line Limit 1
End
trying to run Database procedures.Error code Error 1064 you have error in Mysql bench syntax
CREATE PROCEDURE `xyz_Get`(
IN pPlaceId BIGINT,
IN pSwitchedCompanyId BIGINT,
IN pRequestedBy BIGINT
)
BEGIN
SELECT
`PlaceId`,
`CategoryCode`,
`CategoryName`,
`Description`,
`ParentCategoryId_FK`,
`ModuleId_FK`,
`LanguageId_FK`,
`CompanyId_FK`,
`OwnerCompanyId_FK`,
`IsDeleted`,
`IsArchived`,
`CreatedDate`,
`ModifiedDate`,
`CreatedBy_FK`,
`ModifiedBy_FK`
FROM `xyz_Place`
WHERE
`PlaceId` = pPlaceId AND
(
`CompanyId_FK` = pSwitchedCompanyId OR
`OwnerCompanyId_FK` = pSwitchedCompanyId
)
AND `IsDeleted` = 0
LIMIT 1;
END

index returns relation "search_name_0" does not exist in "Starting rank 2"

I have generated nominatim database before and never faced such an issue.
Please tell me which "setup.php" command generates the "search_name_0" and such tables?
Full error output is:
-bash-4.2$ ./utils/setup.php --index --threads 8 --osm2pgsql-cache 24000
nominatim version 2.5.1
Starting indexing rank (0 to 4) using 8 threads
Starting rank 0
Done 0 in 0 # 0.000000 per second - FINISHED
Starting rank 1
Done 0 in 0 # 0.000000 per second - FINISHED
Starting rank 2
index_placex: UPDATE failed: ERROR: relation "search_name_0" does not exist
LINE 1: DELETE from search_name_0 WHERE place_id = in_place_id
^
QUERY: DELETE from search_name_0 WHERE place_id = in_place_id
CONTEXT: PL/pgSQL function deletesearchname(integer,bigint) line 1260 at SQL statement
PL/pgSQL function placex_update() line 75 at assignment
index_placex: UPDATE failed: ERROR: relation "search_name_0" does not exist
LINE 1: DELETE from search_name_0 WHERE place_id = in_place_id
^
QUERY: DELETE from search_name_0 WHERE place_id = in_place_id
CONTEXT: PL/pgSQL function deletesearchname(integer,bigint) line 1260 at SQL statement
PL/pgSQL function placex_update() line 75 at assignment
index_placex: UPDATE failed: ERROR: relation "search_name_0" does not exist
LINE 1: DELETE from search_name_0 WHERE place_id = in_place_id
^
QUERY: DELETE from search_name_0 WHERE place_id = in_place_id
CONTEXT: PL/pgSQL function deletesearchname(integer,bigint) line 1260 at SQL statement
PL/pgSQL function placex_update() line 75 at assignment
index_placex: UPDATE failed: ERROR: relation "search_name_0" does not exist
LINE 1: DELETE from search_name_0 WHERE place_id = in_place_id
^
QUERY: DELETE from search_name_0 WHERE place_id = in_place_id
CONTEXT: PL/pgSQL function deletesearchname(integer,bigint) line 1260 at SQL statement
PL/pgSQL function placex_update() line 75 at assignment
ERROR: Error executing external command: /srv/Nominatim-2.5.1/nominatim/nominatim -i -d nominatim -P 5432 -t 8 -R 4
Error executing external command: /srv/Nominatim-2.5.1/nominatim/nominatim -i -d nominatim -P 5432 -t 8 -R 4
-bash-4.2$
It took some time to figure out but it happens when your "create-partition-tables" part of setup fails.
Restarting it will fail to re-create the tables. I had to manually remove all partition tables and then restarted the setup with "create-partition-tables" key to solve this!

`FOR UPDATE` breaks batch execution in HANA

HANA 102.05 fails to execute the following code:
CREATE TABLE ATABLE( f INT );
CREATE PROCEDURE TestProc()
AS
BEGIN
SELECT f FROM ATABLE
FOR UPDATE; -- Without FOR UPDATE it works
END;
SELECT 'Hello' FROM DUMMY;
complaining that:
SAP DBTech JDBC: [257]: sql syntax error: incorrect syntax near "SELECT": line 8 col 2 (at pos 124)
which points outside the proceudure, at SELECT 'Hello'. The procedure itself compiles without error. The entire script completes successfully if I remove the FOR UPDATE directive. What is wrong with the original?
Update
When I execute the same query from hdbsql.exe I get:
0 rows affected (overall time 26,076 msec; server time 6518 usec)
* 257: sql syntax error: line 5 col 9 (at pos 71) SQLSTATE: HY000
* 257: sql syntax error: incorrect syntax near "END": line 2 col 1 (at pos 32) SQLSTATE: HY000
'Hello'
"Hello"
1 row selected (overall time 4644 usec; server time 143 usec)

Oracle PLS-00103 error. How do you check for an existing record and do update or insert based on that condition?

I need to check if a record exists in the table or not from a SELECT statement. If the record exists, do an update otherwise create a record on the table. I'm trying to but i'm getting PLS-00103 error.
These are the errors that I'm getting when i run my code in DBVisaulzier:
18:00:09 [DECLARE - 0 row(s), 0.000 secs] [Error Code: 6550, SQL State: 65000] ORA-06550: line 2, column 12:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
:= . ( # % ; not null range default character
18:00:09 [BEGIN - 0 row(s), 0.000 secs] [Error Code: 6550, SQL State: 65000]
ORA-06550: line 2, column 97:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
;
18:00:09 [IF - 0 row(s), 0.000 secs] [Error Code: 900, SQL State: 42000] ORA-00900: invalid SQL statement
18:00:09 [ELSE - 0 row(s), 0.000 secs] [Error Code: 900, SQL State: 42000]
ORA-00900: invalid SQL statement
18:00:09 [END - 0 row(s), 0.000 secs] [Error Code: 900, SQL State: 42000] ORA-00900: invalid SQL statement
18:00:09 [END - 0 row(s), 0.000 secs] [Error Code: 900, SQL State: 42000] ORA-00900: invalid SQL statement
... 6 statement(s) executed, 0 row(s) affected, exec/fetch time: 0.000/0.000 sec [0 successful, 0 warnings, 6 errors]
The following is my code:
DECLARE a NUMBER;
BEGIN
SELECT 1
INTO a
FROM FREC_EMAIL t
WHERE t.FranchiseNo = '208254846'
AND t.ReportID = 1
AND t.id = 165;
IF a=1 THEN
UPDATE FREC_EMAIL
SET email = 'blah#foo.com'
WHERE FranchiseNo = '208254846'
AND ReportID = 1
AND ID = 165;
ELSE
INSERT INTO FREC_EMAIL
(FranchiseNo, Email, ReportID)
VALUES
('208254846', 'blah#foo.com', 1);
END IF;
END;
We should always use SQL whenever possible, and avoid using Pl/SQL unless it is strictly necessary. SQL statements perform faster, they usually require less typing and they are easier to get right.
Since 9i Oracle has provided MERGE, a single SQL statement which executes an "upsert" statement.
MERGE INTO frec_email t
USING (SELECT 'blah#foo.com' as email
, '208254846' as FranchiseNo
, 1 as ReportID
, 165 as ID
FROM dual ) s
ON (s.ID = t.ID)
WHEN MATCHED THEN
UPDATE SET t.email = s.email
WHEN NOT MATCHED THEN
INSERT (t.FranchiseNo, t.Email, t.ReportID)
VALUES (s.FranchiseNo, s.Email, s.ReportID)
/
In a pl/sql block, you can do this:
update table set column=....
where.....;
if SQL%ROWCOUNT = 0 THEN
insert......
END IF;
K
Use the MERGE command (also called upsert by some). Oracle's reference (with example) here.
On a side note, if you are new to Oracle, it is worth spending time getting to grips with the offical documentation. Although it might appear difficult where to start with it, Tom Kyte's Road Map is good place to get a list of must reads.
Good luck!
I usually use the following concept, which I think is more readable than merge::
BEGIN
UPDATE FREC_EMAIL
SET email = 'blah#foo.com'
WHERE FranchiseNo = '208254846'
AND ReportID = 1
AND ID = 165;
IF SQL%NOTFOUND THEN
INSERT INTO FREC_EMAIL
(FranchiseNo, Email, ReportID, ID)
VALUES
('208254846', 'blah#foo.com', 1, 165);
END IF;
END;