updating DATETIME causes sqlite error on BB10 - c++

I created my table with this query
CREATE TABLE SETTINGS(NAME VARCHAR(1050), VALUE VARCHAR(1550),CREATE_DATE_TIME DATETIME,UPDATE_DATE_TIME DATETIME, PRIMARY KEY(NAME))
Then I inserted data like this
INSERT INTO SETTINGS(NAME, VALUE ,CREATE_DATE_TIME ,UPDATE_DATE_TIME) VALUES('CellIDKey','Android#MoblLe.NAv',DATETIME('NOW'), DATETIME('NOW'))
At this point it works fine. Now if I want to run an update query like this,
UPDATE SETTINGS SET VALUE='Android#AfriG1s.MoblLe.NAv' CREATE_DATE_TIME=DATETIME('NOW') WHERE NAME='CellIDKey'
It shows the following error on console
QSqlError::type= "QSqlError::ConnectionError" , QSqlError::number= -1 , databaseText= "No query" , driverText= "Unable to fetch row"
But if I run this update query like this,
UPDATE SETTINGS SET VALUE='Android#AfriG1s.MoblLe.NAv' WHERE NAME='CellIDKey'
Now it works fine. I don't know what is wrong with the DATETIME('NOW') statement on update query.

This is not valid SQL:
UPDATE SETTINGS SET VALUE='Android#AfriG1s.MoblLe.NAv' CREATE_DATE_TIME=DATETIME('NOW') WHERE NAME='CellIDKey'
-- ---------------------------------------------------^ Missing comma!
The individual assignments in a SET need to be separated by commas like this:
UPDATE SETTINGS
SET VALUE='Android#AfriG1s.MoblLe.NAv', -- This comma is needed
CREATE_DATE_TIME=DATETIME('NOW')
WHERE NAME='CellIDKey'

Related

Is there any way to get the displayed text in the "Select List" without using SQL? (Oracle APEX 21.1)

Anyone help me?
"Select List" (name: P2_SHOPS_LIST) that is created with the following SQL
SQL Statement: SELECT SHOP_NAME, GROUP_ID FROM T_ENTRY_SHOPS WHERE ID=:P2_LOV_ID;
It is necessary "GROUP_ID" because it is PK . But I need edit "SHOP_NAME" value and display to Text Field.
I think I can get the currently displayed SHOP_NAME by combining the above SQL with the selection row number, but is there any way to access this value with No SQL? Like
:P2_SHOPS_LIST.SHOP_NAME
(This gave me an error XD).
In the context of JavaScript, you can use the following
$('#P2_SHOPS_LIST option:selected').text()
This can be passed through to PL/SQL via a dynamic action, such as on change of your select list.
Or you could set your text item on change via a JS based action, using 'Set Value' and that code as the expression.

cx_oracle insert with select query not working

I am trying to insert in database(Oracle) in python with cx_oracle. I need to select from table and insert into another table.
insert_select_string = "INSERT INTO wf_measure_details(PARENT_JOB_ID, STAGE_JOB_ID, MEASURE_VALS, STEP_LEVEL, OOZIE_JOB_ID, CREATE_TIME_TS) \
select PARENT_JOB_ID, STAGE_JOB_ID, MEASURE_VALS, STEP_LEVEL, OOZIE_JOB_ID, CREATE_TIME_TS from wf_measure_details_stag where oozie_job_id = '{0}'.format(self.DAG_id)"
conn.executemany(insert_select_string)
conn.commit()
insert_count = conn.rowcount
But I am getting below error. I do not have select parameter of data as data is getting from select query.
Required argument 'parameters' (pos 2) not found
Please suggest how to solve this
As mentioned by Chris in the comments to your question, you want to use cursor.execute() instead of cursor.executemany(). You also want to use bind variables instead of interpolated parameters in order to improve performance and reduce security risks. Take a look at the documentation. In your case you would want something like this (untested):
cursor.execute("""
INSERT INTO wf_measure_details(PARENT_JOB_ID, STAGE_JOB_ID,
MEASURE_VALS, STEP_LEVEL, OOZIE_JOB_ID, CREATE_TIME_TS)
select PARENT_JOB_ID, STAGE_JOB_ID, MEASURE_VALS, STEP_LEVEL,
OOZIE_JOB_ID, CREATE_TIME_TS
from wf_measure_details_stag
where oozie_job_id = :id""",
id=self.DAG_id)

Interactive Grid (IG) ORA-01403 Error in Oracle APEX 5.1.2

How can I overcome this {Ajax call returned server error ORA-01403: no data found for} problem? Problem arises ,When I want to set Order_Status_Field value 2 in IG where query was Order_Status_Id=1.
My IG query was :
SELECT P.ORDER_ID, P.ORDER_STATUS_ID FROM ORDER_DETAILS P WHERE P.ORDER_STATUS_ID=1;
My Workspace Name: ZISHAN
User: ZISHANIIUC#GMAIL.COM
Pass: 123
Problem Page No: 3 (Order Report)
1. Before Updating Order Status:
2. After Updating Order Status:
I saw your are using standard "Interactive Grid - Automatic Row Processing (DML)" process, which is an AJAX approach. this apex behaviour is a call ajax using json format for data. so you have a filter on your sql query
SELECT T.ORDER_ID,
T.TABLE_ID,
T.TAKEN_BY,
T.ORDER_STATUS_ID,
T.TOTAL_COST
FROM ORDER_DETAILS T
WHERE T.ORDER_STATUS_ID=2
and you want to update your filter column (data has change) it's seem like apex do not find the prevouis data filter and return no_data_found (not really sure what happen ) but for solution : .
put your filter in interactive grid --> action button ---> filter
or
write your own custom process
When i tried do alter the process from the "Interactive Grid - Automatic Row Processing (DML)" that apex creats, for my own custom PL/SQL Code i needed to choose one of the columns from the query to be the primary key, and then i could use the pl/sql custom process as found here on this blog:
https://mikesmithers.wordpress.com/2019/07/23/customizing-dml-in-an-apex-interactive-grid/ without the no data found error.

APEX 5.0.1 - interactive report using aliases give blank edit forms

So I've been working on an application in Oracle Application Express 5, in which I have multiple interactive reports with an update form. I have noticed that when I use aliases in the SQL query of the report, the edit on the report stops working. When I want to edit a row, I just get the blank form for adding a new entry, even though I can see in the URL that the primary key has been sent.
Is this a known issue, and is there any way to make this work?
My column names are partly Croatian abbreviations, so leaving the original column names would be too messy.
Here's an example of my code which works:
select "SIFRA_A_P",
"SIFRA_P",
"NAZIV_P",
"CIJENA"
from "#OWNER#"."PJESMA"
Writing it like this
select "SIFRA_A_P" as "ALBUM",
"SIFRA_P" as "ID",
"NAZIV_P" as "TITLE",
"CIJENA" as "PRICE"
from "#OWNER#"."PJESMA"
makes it stop working properly.
Go on your page where you have the problematic report, go at Report Attributes and in the Link Column section now you have something like this
Name Value
Item 1:P3_SIFRA_A_P Value 1: #SIFRA_A_P#
Item 2:P3_SIFRA_P Value 2: #SIFRA_P#
Change the #SIFRA_A_P# to #ALBUM# and #SIFRA_P# to #ID# in the value column.
include rowid in your select statement.
select rowid,"SIFRA_A_P" as "ALBUM", "SIFRA_P" as "ID", "NAZIV_P" as "TITLE", "CIJENA" as "PRICE" from "#OWNER#"."PJESMA"

Trying to modify read-only DataSet field

I use C++ Builder 6.0
I use TADODataSet execute following SQL statement:
SELECT Id, SUM(Saldo) AS Saldo
FROM Table
GROUP BY Id
I use this DataSet only for reporting. No need update date back to database.
When I try to modify field "Saldo"
adospCard->Edit();
adospCard->FieldByName("Saldo")->AsFloat=0.0;
adospCard->Post();
I get error:
Field 'Saldo' cannot be modified.
I add this line
adospCard->FieldByName("Saldo")->ReadOnly=false;
and error no more occurred, but field 'Saldo' has not changed.
adospCard->Edit();
//adospCard->FieldByName("Saldo")->AsFloat=1536.5
adospCard->FieldByName("Saldo")->AsFloat=0.0;
//adospCard->FieldByName("Saldo")->AsFloat=0
adospCard->Post();
//adospCard->FieldByName("Saldo")->AsFloat=1536.5
Howe to change ‘Saldo’ field value?
Add a calculated field to your dataset.
Calculate the right value for Saldo
in this calculated field (you can
use Saldo as source for it if you
want to)
display this calculated field in your report in
stead of the Saldo field.
Edit:
For examples of how to add calculated fields, see for instance here, here and here.
--jeroen
As ldsandon said, you cannot modify the "Saldo" field as it is computed.
If you need to set the value to zero when Id is "something" you are better off doing it in your query. The best approach depends on the criteria for setting the value to zero.
Or, save the results of the original query in a temp table then modify that before returning the results to the report.
Finally, what reporting tool are you using? Can that do the "Saldo = 0" change when rendering the report?
Consider storing your result in a ClientDataset - if you can be assured the result isn't too large.
I don't use "TADODataSet" so the following may not apply :)...
When I do the same (or similar) using my DB of choice (i.e. Advantage Database Server) I would use the INTO clause, albeit, with a TSQLQuery component (with the RequestLive property enabled). For example:
SELECT Id, SUM(Saldo) AS Saldo INTO #TempTable FROM Table GROUP BY Id