I created a Laravel API connecting to an Oracle Database my goal is to use it for an android app .
The Error message :
Error Code : 904 Error Message : ORA-00904: "EMAIL": invalid identifier Position : 49 Statement : select * from (select * from "USERS" where upper(email) = upper(:p0)) where rownum = 1 Bindings : [test#mail.com]
I installed the yajra oci8 extension to connect to the oracle database .
I checked th config/auth.php
I am using the laravel php artisan ui bootstrap --auth for the authentication
This is an Oracle error, it won't have anything to do with your client environment.
It means that there is no column named EMAIL (all caps) in the "USERS" table. Check the column list in that table (select * from all_tab_columns where table_name = 'USERS') and ensure you find a column named EMAIL. If you find one with mixed case, e.g. 'Email' that is a non-standard object name in Oracle and requires the use of double-quotes and exact case-matching. If that's the situation, you can fix it by changing your query to:
select * from (select * from "USERS" where upper("Email") = upper(:p0)) where rownum = 1
Related
Can anyone help me the below query is working fine in DB Browser but not work with the Room database. Here are the table and query:
Table Transaction:
id
amount
is_credit
Query:
SELECT *
FROM
(SELECT
id, amount,
SUM(CASE WHEN is_credit = 1 THEN amount ELSE -amount END) OVER (ORDER BY id) AS balance
FROM `Transaction`)
ORDER BY
id DESC;
I have tried this query with SimpleSQLiteQuery but I'm getting error :
E/SQLiteLog: (1) near "(": syntax error
If your version of SQLite is lower than 3.25.0 then you can't use window functions like SUM().
Instead you can do it with a correlated subquery:
SELECT t.id,
t.amount,
(SELECT SUM(CASE WHEN tt.is_credit = 1 THEN 1 ELSE -1 END * tt.amount) FROM `Transaction` tt WHERE tt.id <= t.id) AS balance
FROM `Transaction` t
ORDER BY t.id DESC;
Or a self join:
SELECT t.id,
t.amount,
SUM(CASE WHEN tt.is_credit = 1 THEN 1 ELSE -1 END * tt.amount) AS balance
FROM `Transaction` t INNER JOIN `Transaction` tt
ON tt.id <= t.id
GROUP BY t.id
ORDER BY t.id DESC;
See a simplified demo.
You are trying to use SQLite Windows functions i.e OVER the version of SQLite on Android Devices is typically some way behind. You'd need at least API 30 (Android R) for SQLite version 3.28.0 (when Windows functions were introduced). Obviously that would place limitations on the App's install base.
You may wish to see Version of SQLite used in Android?
In Android SQLite i got tabel like this
domainObjectId: String // like '9876543210'
name: String
description: String
I want to use FTS on this to search without worrying about diacritical marks, how ever i want to let user select also by typing part of object ID(ex. last 4 char)
I got select like
`SELECT * FROM tabel LEFT JOIN tabel_fts on tabel_fts.domainObjectId = tabel.domainObjectId WHERE tabel_fts MATCH '3210*' OR tabel.domainObjectId LIKE '%3210%'
But in return i get error
unable to use function MATCH in the requested context (code 1 SQLITE_ERROR);
Is this possible to add additional condition to select with MATCH?
Try to remove "MATCH" into separate "SELECT":
`SELECT * FROM tabel LEFT JOIN (select * from tabel_fts WHERE tabel_fts.domainObjectId MATCH '3210*') as tabel_fts WHERE tabel.domainObjectId LIKE '%3210%' OR table_fts.ID IS NOT NULL
By the way:
In your "WHERE tabel_fts" it seemed you've missed a column name
There is no "ON" condition in tables JOINm just "WHERE". That's OK? May be it would be better to use UNION?
My SQLLite query is not working properly. See below:
UUID i=UUID.randomUUID();
String Beregero ="INSERT INTO
contacts(id,uuid,name,phone,email,street,city,state,zip) " +
" VALUES(3,"+"'"+i.toString()+"'"+",'Patrice
Beregeron','978-555-1212','pBeregero#BostonBruins.com'," +
"'1 causeway street','Boston','Mass','01236');";
db.execSQL(Beregero);
I am receiving the following error in my log:
(table contacts has no column named uuid (code 1): , while
compiling: INSERT INTO contacts(id,uuid,name,phone,email,
street,city,state,zip) VALUES(3,'12ee5bbf-dabb-4d95-bfe7-6e6f14702add',
'Patrice Beregeron','978-555-1212','pBeregero#BostonBruins.com',
'1 causeway street','Boston','Mass','01236');)
#################################################################
The exception says it all, your table has no column name uuid created. So uninstall the app, then run it again. This error occurs only if the column is not generated.
The error message in you log clearly states the problem. The contacts table does not have a column uuid. You now could do the following:
Check if you have got right lower case vs. upper case. The column in question might be UUID instead of uuid (I don't know SQLite, but case matters in many database systems).
If the column really is not in the table yet, then add it (either by code or by hand). Read SQLite's documentation to learn how to that (I can't help you here because I don't know SQLite).
Uninstalling and re-installing the app would help only if the app would generate the database upon installing or during the first run. Since we don't know anything about the app, this might or might not be the case.
You have not added the column "uuid" in the create table "contacts" query like this :
String createTableContacts = "create table contacts ( ' uuid text ')";
I am trying to create a static list of timestamps so that i can join them agains another table to create chart data. So far I have a query in this format SELECT * FROM (VALUES('a'),('b'),('c'),('d')) AS tbl ,which is working in sqlitestudio but not in android 4.4. When I run the query in the phone I get the error
android.database.sqlite.SQLiteException: near "VALUES": syntax error (code 1): , while compiling: SELECT * ...
I have also tried wrapping the values term inside another select like this SELECT * FROM (SELECT * FROM (VALUES('a'),('b'),('c'),('d'))) AS tbl but I still get the same error.
The full query now looks like this
SELECT * FROM (select * from ( VALUES (1458111312025),
(1455667200000),
(1455753600000),
(1455840000000),
(1455926400000),
(1456012800000),
(1456099200000),
(1456185600000),
(1456272000000),
(1456358400000),
(1456444800000),
(1456531200000),
(1456617600000),
(1456704000000),
(1456790400000),
(1456876800000),
(1456963200000),
(1457049600000),
(1457136000000),
(1457222400000),
(1457308800000),
(1457395200000),
(1457481600000),
(1457568000000),
(1457654400000),
(1457740800000),
(1457827200000),
(1457913600000),
(1458000000000),
(1458086400000))) i LEFT JOIN (
SELECT (osysdate- (osysdate % 86400000) ) interval, SUM(field004) totalval FROM onlineactivities WHERE field003 !=300000 and osysdate> 1455605711999 GROUP BY interval )
onl ON i.'' = onl.interval;;
Note that this works in sqlitestudio with sqlite version 3.8.10 but not in android kitkat (not sure about the sqlite version in it) What could be the problem?
Also please check out this question which is what I am trying to do but with sqlite and this answer
The VALUES syntax is available since SQLite 3.8.3, which is not available in every Android version.
To be compatible with earlier SQLite versions, you have to use a compound query:
SELECT 1458111312025 UNION ALL
SELECT 1455667200000 UNION ALL
...
Alternatively, put all the values into a temporary table.
I have some data in a SQLite database and i want to provide basic search capabilities in a listview.
Here is an example of search query I want to be able to solve :
1) Example of sqlite data :
ad
bc
cd
d
da
ec
2) Input & wanted output :
a -> [ ad , da ]
d -> [ d , da , ad , cd ]
c -> [ cd, bc , ec ]
I already thought of a few things but nothing really ok :
Full Text Search : I cannot modify the input db file so I think I cannot use it
one sqlite query (name LIKE ?% OR name LIKE %?%) : not sorted. Perhaps another query I am not aware can be figured out
two differents queries (name LIKE ?% and then name LIKE %?%) : but how to implement it with a content provider ? CursorWrapper ? MergeCursor ? custom Loader ?
I have seen a lot of examples but nothing useful for my custom search.
Thanks for your help.
Edit : Query on d should give [ d , da , ad , cd ].
The custom sort order I want is : LIKE pattern% AND then LIKE %pattern% (for example socks should come before a pair of socks)
Here is some hack for your requirements:
SELECT DISTINCT t.name
FROM (select *, 1 as sec from items WHERE name LIKE 'd%'
union
select *, 2 as sec from items WHERE name LIKE '%d%') as t
ORDER BY t.sec ASC
The CursorLoader constructor's last parameter is sortOrder - add the name column as your sortOrder to sort the resulting set (note that leaving it blank, as SQLiteDatabase.query may lead to an unsorted order).