Unknown stored procedure being called during update query - sql-update

I've got SQL Server 2012 with a table having a field layout like this:
(UID bigint, Email varchar(64), Password varchar(64))
When I run a query like this:
Update *tablename*
Set [Password]="some_new_value"
Where [UID]=1;
I get this error"
Msg 208, Level 16, State 1, Procedure UserModify, Line 16 Invalid
object name 'updated'.
Normally, I'd have no problems fixing this, but I'm not calling a stored procedure, and there's no stored procedure in my database called UserModify. So I'm at a complete loss as to what's going on here. Anybody got any ideas?

Related

After updating table id via csv file when trying to add new field getting - duplicate key value violates unique constraint

Problem.
After successful data migration from csv files to django /Postgres application .
When I try to add a new record via the application interface getting - duplicate key value violates unique constraint.(Since i had id's in my csv files -i use them as keys )
Basically the app try to generate id's that already migrated.
After each attempt ID increments by one so if I have 160 record I have to get this error 160 times and then when I try 160 times the time 161 record saves ok.
Any ideas how to solve it?
PostgreSQL doesn't have an actual AUTO_INCREMENT column, at least not in the way that MySQL does. Instead it has a special SERIAL. This creates a four-byte INT column and attaches a trigger to it. Behind the scenes, if PostgreSQL sees that there is no value in that ID column, it checks the value of a sequence created when that column was created.
You can see this by:
SELECT
TABLE_NAME, COLUMN_NAME, COLUMN_DEFAULT
FROM
INFORMATION_SCHEMA.COLUMNS
WHERE
TABLE_NAME='<your-table>' AND COLUMN_NAME = '<your-id-column>';
You should see something like:
table_name | column_name | column_default
--------------+---------------------------+-------------------------------------
<your-table> | <your-id-column> | nextval('<table-name>_<your-id-column>_seq'::regclass)
(1 row)
To resolve your particular issue, you're going to need to reset the value of the sequence (named <table-name>_<your-id-column>_seq) to reflect the current index.
ALTER SEQUENCE your_name_your_id_column_seq RESTART WITH 161;
Credit where credit is due.
Sequence syntax is here.
Finding the name is here.

Informix: Modify from CLOB to LVARCHAR

I have a table
CREATE TABLE TEST
(
test_column CLOB
)
I want to change the datatype of test_column to LVARCHAR. How can I achieve this? I tried several things until now:
alter table test modify test_column LVARCHAR(2500)
This works, but the content of test_column gets converted from 'test' to '01000000d9c8b7a61400000017000000ae000000fb391956000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000'.
alter table test add tmp_column LVARCHAR(2500);
update test set tmp_column = DBMS_LOB.SUBSTR(test_column,2500,1);
This does not work and I get the following exception:
[Error Code: -674, SQL State: IX000] Method (substr) not found.
Do you have any further ideas?
Using a 12.10.xC5DE instance to do some tests.
From what i could find in the manuals, there isn't a cast from CLOB to other data types.
CLOB data type
No casts exist for CLOB data. Therefore, the database server cannot convert data of the CLOB type to any other data type, except by using these encryption and decryption functions to return a BLOB. Within SQL, you are limited to the equality ( = ) comparison operation for CLOB data. To perform additional operations, you must use one of the application programming interfaces from within your client application.
The encryption/decryption functions mentioned still return CLOB type objects, so they do not do what you want.
Despite the manual saying that there is no cast for CLOB, there is a registered cast in the SYSCASTS table. Using dbaccess , i tried an explicit cast on some test data and got return values similar to the ones you are seeing. The text in the CLOB column is 'teste 01', terminated with a line break.
CREATE TABLE myclob
(
id SERIAL NOT NULL
, doc CLOB
);
INSERT INTO myclob ( id , doc ) VALUES ( 0, FILETOCLOB('file1.txt', 'client'));
SELECT
id
, doc
, doc::LVARCHAR AS conversion
FROM
myclob;
id 1
doc
teste 01
conversion 01000000d9c8b7a6080000000800000007000000a6cdc0550000000001000000000
0000000000000000000000000000000000000000000000000000000000000000000
0000000000
So, there is a cast from CLOB, but it does not seem to be useful for what you want.
So back to the SQL Packages Extension . You need to register this datablade on the database. The files required are located in the $INFORMIXDIR/extend and you want the excompat.* module. Using the admin API, you can register the module by executing the following:
EXECUTE FUNCTION sysbldprepare('excompat.*', 'create');
If the return value is 0 (zero) then the module should now be registered.
SELECT
id
, DBMS_LOB_SUBSTR(doc, DBMS_LOB_GETLENGTH(doc) - 1, 1) as conversion
FROM
myclob;
id 1
conversion teste 01
Another way would be to register your own cast from CLOB to LVARCHAR, but you would have to code an UDR to implement it.
P.S:
Subtracting 1 from the CLOB length to remove the line break.

APEX: Item is blank when trying to prepopulate with value

My Scenario:
I have a report on page 1 which has a link to page 2. This link passes an ID to page 2 (V2_ID gets set with V1_ID).
I then have two items called V2_ID and V2_NAME on page 2, as well as a PL/SQL process on page 2 which executes after the header loads which
select name into :V2_NAME from table where id = :V_ID;
The V2_ID shows the value, but the V2_NAME is always blank.
How can I pre-populate this variable. This is a very simple example as my use case is much more complicated, but the concept is the same. I can't use automatic row fetch because each item comes from a different table (it is a horrible database design, but I have to work with it).
Cheers
If on page 2 you have a PL/SQL process at the process point='On Load - After Header' and the procedure looks something like this:
Begin
select name into :V2_NAME from table where id =:V2_ID;
end;
and no condition on it then it should work.
Check that :V2_NAME does not have Source Type= Always NULL;
Correct me if Im wrong, from what ive understood, only one value is passed from page 1 to page 2 which is V1_ID to V2_ID,right?then on page 2, you have a process that will execute after the header loads and that is
SELECT name
INTO :V2_NAME
FROM TABLE
WHERE id = :V_ID
Is the :V_ID a typo?It should be :V2_ID,if its not maybe its the cause as to why :V2_NAME doesnt give you a value.
Instead of having a process after header, why dont you just put the query in the item SOURCE, choose type: QUERY, used: ALWAYS, REPLACE ANY EXISTING VALUES ON SESSION STATE.
then in the query box, put
SELECT name
FROM TABLE
WHERE id = :V2_ID

updating DATETIME causes sqlite error on BB10

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'

Validation to detect text in numeric field

I'm trying to prevent users crashing the create new product apex page. On the create page i have a text field:product_name and a numeric field: product_quantity.
Currently when they enter text in the product_quantity field and click 'Save' they get the following error:
Error processing validation.
ORA-01722: invalid number
I have investigated the error however i thought in Apex, if you selected a numeric field, it would detect whether the user entered text or numeric characters?
Is there a method to display a validation message if the user has entered text, it shouts, otherwise it enables the user to save the new entry?
UPDATE
I know why its happening but dont know how to solve it.
I recreated my page and it worked. I then added two pieces of validation in my page processing and when i then try it i get the error in my intial post. If i disable them it works again. The validation use NOT EXISTS to find whether the entered value already exists in the table before they add it.
If only the validation kicks in after looking whether a numerical value has been entered. I stopped the validation looking at an associated item, and turned off the 'when button pressed' but still no joy.
select 1 from MY_TABLE where column_name = :P6_TEXT_FIELD
Is there a way to run the text box validation (checking whether its text entered) before the validation i have created in the page processing?
That's the thing with validations: they all get executed and do not short-circuit. You can actually clearly see this happening when you debug the page.
In the case of a number field, you'd see it does not pass the number validation. But this does not stop validation. So your second validation will be run which uses the submitted value, but would obviously fail when you entered text for instance.
There are some work-arounds for that.
For example, you could change your NOT-EXISTS validation to a PLSQL function returning an error message and execute something like this (example):
DECLARE
v_test_nbr NUMBER;
v_check_exists NUMBER;
BEGIN
BEGIN
v_test_nbr := to_number(:P6_TEXT_FIELD);
EXCEPTION
WHEN OTHERS THEN
-- or catch 1722 (invalid number) and 6502 (char to number conversion error)
v_test_nbr := NULL;
END;
IF v_test_nbr IS NOT NULL
THEN
-- if v_test_nbr is not null then the field should be numerically valid
-- if it isn't then this code would be skipped and this validation
-- will not throw an error.
-- However, the previous validation will still fail when text is entered,
-- so this shouldn't matter.
BEGIN
SELECT 1
INTO v_check_exists
FROM my_table
WHERE column_name = :P6_TEXT_FIELD;
EXCEPTION
WHEN no_data_found THEN
v_check_exists := 0;
END;
IF v_check_exists = 1
THEN
RETURN 'A record with this key already exists';
END IF;
END IF;
RETURN NULL;
END;
HOWEVER - in this case, where you want to check for duplicate entries a better option may exist if you are at least on version 4.1. If your table has the correct constraints defined, then you would have a unique key defined on the field you are performing the not-exists on. This means that if you would not have this validation on the field, you would get an ora-00001 DUP_VAL_ON_INDEX error.
You could then use the error processing provided by apex to catch this error, and produce a user-friendly message.
You can find an example of how to use and implement this on the blog of Patrick Wolf of the apex development team:
apex-4-1-error-handling-improvements-part-1/
apex-4-1-error-handling-improvements-part-2/