I have following value:
proc.procSetDebugMode(true);
etl_utils.procSetDebugMode(true);
_analysis.procRunAnalysis(360, <ID_PRCSS_EXCTN>, to_date('<BUSINESS_DATE>', 'YYYY-MM-DD'), '<CONFIG_TYPE>', <G_ROW_COUNT>);
which I need to insert into a specific clob column but unfortunately didn't succeed.
Any tips? The problem seems trivial but still I am unable to resolve it.
insert into JOB
select
1595,
clob(analysis.procSetDebugMode(true); etl_utils.procSetDebugMode(true);analysis.procRunAnalysis(360,<ID_PRCSS_EXCTN>,to_date('<BUSINESS_DATE>','YYYY-MM-DD'), '<CONFIG_TYPE>', <G_ROW_COUNT>);),
INPUT_PARAMS,
UPDATE_STAMP,
UPDAE_USER_LOGIN,
WARNING_TIME,
MAX_EXCTN_TIME,
IS_AWAITING_JOB from JOB where ID = 1585;
Related
I'm trying to run a PostgreSQL query which is:
insert into client (email, name) values ('johndoe#email.com', 'johnDoe');
insert into client_settings (client_id, data) values (currval('client_id_seq'), 0);
insert into client_verify (client_id, dataFields) values (currval('client_id_seq'), json_build_object('data1', ['a1', 'a2'], 'data2', ['b1', 'b2']) );
But I'm getting an error stating SQL Error [42601]: syntax error at or near "[".
The last json object(i.e., the dataFields) when inserted into the DB it should look like:
{"data1": ["a1", "a2"], "data2": ["b1", "b2"]}
Not sure what I am doing wrong. Is there something that I'm missing or a different way to do that?
After good research I found documentation to put 'Array' in front of those like:
json_build_object('data1', Array['a1', 'a2'], 'data2', Array['b1', 'b2'])
Is this what you need :
insert into client_verify (client_id, dataFields)
values (currval('client_id_seq'), json_build_object('data1', 'a1, a2', 'data2', 'b1, b2') );
Please try this:
insert into client_verify (client_id, dataFields)
values (currval('client_id_seq')
, json_build_object('data1', '["a1", "a2"]', 'data2', '["b1", "b2"]'));
Here you can check how you need to add your string:
https://www.freeformatter.com/json-escape.html#ad-output
The UNESCAPE is the option you need
Here is a demo :
DEMO
INSERT INTO TBLONE (
broad,tt,CUR,
STARTDATE,ENDDATE,OPERATION,
TYPE,ENT,NAMEENT,SUB,FLAG1,FLAG2,ANALYST,STATUS,
FILE,SUBID,COMMENTS )
SELECT convert(char(13),broad),
convert(numeric(7,2),tt),
convert(char(3),CUR),
#CUR_DATE,
ENDDATE,
'first',
convert(char(4),TYPE),
convert(char(7),ENT),
convert(varchar(40),NAMEENT),
convert(char(8),SUB),
'Y',
'Y',
convert(varchar(255),ANALYST),
convert(char(5),STATUS),
convert(numeric(7,0),FILE),
convert(varchar(5),SBID),
convert( varchar(255),COMMENTS)
from #TMP_TBLPONE where LE=convert(char(7) ,#LEE)
I matched all the datatypes still the error is coming
"Implicit conversion from datatype 'INT' to 'CHAR' is not allowed. Use the CONVERT function to run this query."
Please guide.
Well you have this one right here:
convert(numeric(7,0),FILE),
what is the data type for the "FILE" column in your table?
I think you getting a string words for FILE column. did it try the
convert(char(255),FILE),
This is my first db trigger. It compiles with warnings and therefore doesn't work. I've re-read the Oracle docs and searched online but can't work out where I'm going wrong. Any help with my trigger below would gratefully received.
CREATE OR REPLACE TRIGGER oa_mhd_update AFTER
INSERT ON men_mhd FOR EACH row WHEN (new.mhd_tktc LIKE 'OA_A_%'
OR new.mhd_tktc LIKE 'OA_T_%'
OR new.mhd_tktc LIKE 'OA_M_%')
DECLARE seq_var NVARCHAR2 (20);
BEGIN
SELECT (MAX (seq) + 1) into seq_var FROM oa_mhd_data;
INSERT
INTO oa_mhd_data
(
mhd_code,
seq,
mhd_mst1,
mhd_mst2,
mhd_cred,
mhd_cret,
mhd_tsks,
mhd_msgs,
mhd_tktc,
mhd_tref,
mhd_actn,
mhd_eref,
mhd_subj,
mhd_udf1,
mhd_udf2,
mhd_udf3,
mhd_udf4,
mhd_udf5,
mhd_udf6,
mhd_udf7,
mhd_udf8,
mhd_udf9,
mhd_udfa,
mhd_udfb,
mhd_udfc,
mhd_udfd,
mhd_udfe,
mhd_udff,
mhd_udfg,
mhd_udfh,
mhd_udfi,
mhd_udfj,
mhd_udfk,
mhd_updd,
mhd_begd,
mhd_begt,
mhd_endd,
mhd_endt,
mhd_mrcc,
mhd_mhdc,
mhd_mscc,
mhd_pprc,
mhd_ppss,
mhd_inst
)
VALUES
(
:new.mhd_code
seq_var,
:new.mhd_mst1,
:new.mhd_mst2,
:new.mhd_cred,
:new.mhd_cret,
:new.mhd_tsks,
:new.mhd_msgs,
:new.mhd_tktc,
:new.mhd_tref,
:new.mhd_actn,
:new.mhd_eref,
:new.mhd_subj,
:new.mhd_udf1,
:new.mhd_udf2,
:new.mhd_udf3,
:new.mhd_udf4,
:new.mhd_udf5,
:new.mhd_udf6,
:new.mhd_udf7,
:new.mhd_udf8,
:new.mhd_udf9,
:new.mhd_udfa,
:new.mhd_udfb,
:new.mhd_udfc,
:new.mhd_udfd,
:new.mhd_udfe,
:new.mhd_udff,
:new.mhd_udfg,
:new.mhd_udfh,
:new.mhd_udfi,
:new.mhd_udfj,
:new.mhd_udfk,
:new.mhd_updd,
:new.mhd_begd,
:new.mhd_begt,
:new.mhd_endd,
:new.mhd_endt,
:new.mhd_mrcc,
:new.mhd_mhdc,
:new.mhd_mscc,
:new.mhd_pprc,
:new.mhd_ppss,
:new.mhd_inst
)
END;
/
You're missing a comma between the first two elements of the values clause, and a semi-colon at the end of the insert statement:
VALUES
(
:new.mhd_code
seq_var,
:new.mhd_mst1,
...
:new.mhd_ppss,
:new.mhd_inst
)
... should be:
VALUES
(
:new.mhd_code,
seq_var,
:new.mhd_mst1,
...
:new.mhd_ppss,
:new.mhd_inst
);
Odd that you can't see the error though.
Incidentally, the max(seq) + 1 from ... pattern isn't reliable in a multi-user environment. It would be more normal (and safer) to use a proper sequence to generate that value.
Hi there are two syntactical errors
First please add a comma between two values you are inserting
VALUES
(
:new.mhd_,
seq_var,
:new.mhd_mst1,...
and second please add a semi colon at he end of insert statement
...
:new.mhd_pprc,
:new.mhd_ppss,
:new.mhd_inst
);
Hope this will solve your problem
I am attempting to insert data into a table in my database. I am using an Oracle Apache Derby DB. I have the following code-
Insert into P2K_DBA.ODS_CNTRL
(ODS_LOAD_ID, ODS_STATUS, USR_WWID, USR_FIRST_NM,
USR_LAST_NM, USR_DISPLAY_NM, USR_NT_ID,TOT_AMT,
TOT_RCD_CNT, TOT_QTY, LAST_UPD_DT, ODS_ADJ_TYP,
ODS_ADJ_DESC, APRV_WWID, APRV_FIRST_NM,APRV_LAST_NM,
APRV_DISPLAY_NM, APRV_NT_ID, APRV_DT
)
values
(6,'avail','64300339', 'Travis',
'Taylor', 'TT', '3339', 33,
15, 40, '7/10/2012', 'test',
'test', '64300337', 'Travis',
'Taylor', 'TT', '3339', '2/06/2013');
I ran this SQL command and received the following error-
"Error code -1, SQL state 21000: Scalar subquery is only allowed to return a single row.
Line 1, column 1"
I have ran this code successfully a few days ago. On top of that I have tried to manually enter in data in this table (using NetBeans) and have it auto generate the code, which resulted in the same error.
What is causing this error and how can I solve/bypass it?
One way in which you could run into this would be to do something like
CREATE FUNCTION F(...) ...
F((SELECT COL FROM T))
But you could instead write
... (SELECT F(COL) FROM T) provided the new context permits a subquery, that is.
I'm using SQLAlchemy 0.5.8, and seeing this error:
ProgrammingError: (ProgrammingError) can't adapt 'INSERT INTO enumeration_value (id,
key_id, code, name, notes) VALUES (%(id)s, %(key_id)s, %(code)s, %(name)s, %(notes)s)'
{'key_id': 'aac6fc29-4ccd-4fe4-9118-cfbbd04449fe', 'notes': '', 'code': (u'Barnet',),
'id': 'd0540c97-882e-4a5b-bf14-b3ebcfeea051', 'name': (u'Barnet',)}
But a direct SQL insert with the values from the error seems to work just fine:
=> INSERT INTO enumeration_value (id, key_id, code, name, notes)
VALUES ('d0540c97-882e-4a5b-bf14-b3ebcfeea051', 'aac6fc29-4ccd-4fe4-9118-cfbbd04449fe',
'Barnet', 'Barnet', '');
INSERT 0 1
If the direct SQL works OK, how can I start to debug this?
Incidentally, the line that's throwing the error doesn't seem to have an INSERT statement in it at all, so I am a bit confused:
File "----barnet.py", line 117, in load_file
instance = model.Session.query(model.EnumerationValue).filter_by(key=key_barnet_level_2, code=level_2).all()
Do SQLAlchemy filter statements generate INSERT commands, or does this just happen to be the last line before things start to go wrong?
Figured it out - the problem was actually a syntax error a few lines higher up, with a rogue comma:
key_from = code,
Sorry if I wasted anyone's time. Please close the question.