Trying to retrieve only orders not payed for an e-commerce website.
SELECT * FROM orders_list
WHERE status CONTAINS (type IN ['payed'])
AND status *not* CONTAINS (type IN ['payed'])
or
SELECT * FROM orders_list
WHERE status CONTAINS (type IN ['payed'])
AND status CONTAINS (type *not* IN ['payed'])
How I can do this query?
Thanks
You can use
SELECT * FROM orders_list
WHERE status CONTAINSALL (type NOT IN ['payed'])
Hope it helps.
UPDATE
I tried with this structure
Try this:
SELECT * FROM orders_list
WHERE 'payed' NOT IN status
or
SELECT * FROM orders_list
WHERE status <> 'payed'
Let me know
Hope it helps
Related
I am new for using DBeaver. Can I see Oracle SQL Developer Procedure's Details in Dbeaver?
like this
enter image description here
Use the data dictionary.
You can get details of the object using:
SELECT *
FROM ALL_OBJECTS
WHERE object_name = 'PROCEDURE_NAME';
You can get further details on the procedure using:
SELECT *
FROM ALL_PROCEDURES
WHERE object_name = 'PROCEDURE_NAME';
You can get even more details on the compilation settings using:
SELECT *
FROM all_plsql_object_settings
WHERE name = 'PROCEDURE_NAME'
You can combine it all into one query:
SELECT o.owner,
o.object_name,
o.subobject_name,
o.object_id,
o.data_object_id,
o.object_type,
o.created,
o.last_ddl_time,
o.timestamp,
o.status,
o.temporary,
o.generated,
o.secondary,
o.namespace,
o.edition_name,
s.nls_length_semantics,
s.plsql_ccflags,
s.plsql_code_type,
s.plsql_debug,
s.plsql_optimize_level,
s.plsql_warnings
FROM all_objects o
LEFT OUTER JOIN all_plsql_object_settings s
ON (o.owner = s.owner AND o.object_name = s.name AND o.object_type = s.type)
WHERE o.object_name = 'PROCEDURE_NAME';
fiddle
I have a mySql sp I need to convert to postgres function. The SP can pull different data sets depending on the parametes put in. this is the mysql code:
IF upper(type) = 'PROJ'then
if upper(number) = 'ALL' then
SELECT * FROM CLMAppViews.vw_project_profile order by `Project Title`;
else
SELECT * FROM CLMAppViews.vw_project_profile where `Project Number` = number order by `Project Title`;
end if ;
else
if upper(number) = 'ALL' then
SELECT * from CLMAppViews.vw_proposal_profile order by title;
else
SELECT * from CLMAppViews.vw_proposal_profile where `Opportunity ID / Proposal ID` = number order by title;
end if ;
end if;
can anyone suggest how I may be able to replicate this in Postgres? The problem I'm running into is that the result set can have different data types depending on the path taken in the code.
Please can anyone help to solve the problem of the PostgreSQL query? It's expected to return the result in the image but it returns nothing:
Query:
SET foo.date_1 = '2021-01-04';
select interface_name, max(time_stamp) as date, message,api_request from central
where application = 'OMS to DW'
and time_stamp like ''''||'%' || current_setting('foo.date_1')||'%'||''''
and message not like 'succe%'
group by interface_name,message,api_request
Expecting:
Thank you all for trying to help. The problem now it's solved, the correct code should be:
SET foo.date_1 = '2021-01-04';
select interface_name, max(time_stamp) as date, message,api_request from central
where application = 'OMS to DW'
and time_stamp like '%' || current_setting('foo.date_1')||'%'
and message not like 'succe%'
group by interface_name,message,api_request
I've tried to write a query using mapper of mabatisbut can't make it so far
This is my code
String SQL_SELECTPAGE = "select b.writer, b.title, b.topicdate, b.lecturekey, b.tcontent" +
"from (select rownum rn, a.* from (select * from topics WHERE LECTUREKEY = #{lid}" +
"order by topicdate desc) a) b" +
"where rn between #{c.start} and #{c.end}";
#Select(SQL_SELECTPAGE)
List<Topics> selectPage(#Param("lid") String lid, #Param("c") PaginationCriteria c);
PaginationCriteria has start and end attribute.
Below is HTTP Status 500 error message. I think parameter couldn't pass
... WHERE LECTUREKEY = ?order by topicdate desc) a) bwhere rn between ? and ? > ### Cause: java.sql.SQLSyntaxErrorException: ORA-00936:
I'd be glad if someone can help me
Thank you
You can't use a JDBC bind parameter for the row number clause. In MyBatis, anything specified with #{...} is a bind parameter. Anything you specify as ${...} is, basically, string substitution which should work here.
So rewrite your where clause like this where rn between ${c.start} and ${c.end}
I've got a query:
SELECT < column names >
INTO <#temp_table>
FROM < table >
WHERE < stuff >
It runs fine in dbVisualizer. However, running it in Oracle SQL Developer gives me the error "The executeQuery method must return a result set."
What is happening here, and how can I fix it in SQL Developer?
EDIT: In response to Tanner, I get the errors when I try the following things (tell me if something I try is invalid. I'm new to SQL):
This:
select * into #temp_table from status
produces this:
The executeQuery method must return a result set.
This:
select * into #temp_table from status;
select * from #temp_table;
produces this:
Invalid object name '#temp_table'.
And this:
select *
from(
select * into #temp_table from status)
produces this:
Incorrect syntax near the keyword 'into'.
I'm lost, ladies and gentledudes.
If you have a query like:
SELECT *
INTO #TEMP
FROM TABLE_A
That is simply creating and inserting data into a temp table.
What you need to do is return that temp table, so after you have run that code you need to do this:
SELECT *
FROM #TEMP