Say I have a table with a unique positive integer field. I currently have rows with id's of [1, 2, 3, 4, 5, 8, 12, 35]. Is there a insert query that I could write that would assign the id field to the lowest unique positive integer (in this case 6)? It would have to do this atomically so there isn't the possibility of concurrent inserts wiping out each other or failing.
Hi
In bulk insertion only in the last record trigger is executing.
Example : if i bulk insert 10 records the trigger is running only for the 10th record. But I need trigger to run on all 10 records.
Please help me with an example
Hi,
This is a quick question. I have the following ruby code, which works fine.
def add_zeros number, zeros
number = number.to_s
zeros_to_add = zeros - number.length
zeros_to_add.times do
number = "0#{number}"
end
number
end
But if I replace
number = "0#{number}"
With
number.insert(0, "0")
Then I get TypeError: can't modify frozen string, does anyone know why this is?
I have a table with date fields of timestamp(6) fields .
create table test_time
(
t1 timestamp(6) format 'mm/dd/yyyy hh:mm:si' ,
);
I want to insert into this table with current date and time rounded.
i.e. say for example if the current date time is 08/07/2014 10:34:56 then the value in the table should be 08/07/2014 10:00:00 .
(or) if current data and time is 08/07/2014 10:54:56 then also the value should be
08/07/2014 10:34:56
I need to add a row to a MySQL database table but only if the row doesn't already exist. My database server just went down so I can't test this, but will this work as expected?
INSERT INTO `blocks` (`block_file`,`settings_group`)
VALUES ('announcements','announcement_settings')
WHERE NOT EXISTS (SELECT `block_file`,`settings_group`
FROM `blocks`
WHERE `block_file`='announcements' AND `settings_group`='announcement_settings')
It seems like sound logic. Is this a valid query or is there a better way of doing this?
So i have a SQL table setup as such
CREATE TABLE IF NOT EXISTS `points` (
`id` int(11) NOT NULL auto_increment,
`lat` float(10,6) NOT NULL,
`lng` float(10,6) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM;
And im inserting stuff like
INSERT INTO `points` (`lat`, `lng`) VALUES ('89.123456','-12.123456');
Gives me a row with lat and lng being 89.123459 and -12.123455
Whats up?
Using Ms SQL Server 2005 and Management Studio how do I insert a picture into an Image type field of a table?
Most importantly how do I verify if it is there?
i'm wondering why doesn't this work ?
it gives me the exception that the "File Format Is Not Valid"
richTextBoxPrintCtrl1.Rtf = richTextBoxPrintCtrl2.Rtf.Insert(richTextBoxPrintCtrl1.SelectionStart, myString);
I'm using a transaction to insert multiple rows in multiple tables. For these rows I would like to add these rows in order. Upon calling SaveChanges all the rows are inserted out of order.
When not using a transaction and saving changes after each insertion does keep order, but I really need a transaction for all entries.
Using Python I need to insert a newline character into a string every 64 characters. In Perl it's easy:
s/(.{64})/$1\n/
How could this be done using regular expressions in Python?
Is there a more pythonic way to do it?
I have to insert 2 forms in the same page:
1) Registration form
2) Login form
.
So if I use this in the views.py:
if request.method == 'POST':
form = registrationForm(request.POST)
if form.is_valid():
form.save()
return render_to_response('template.html', {
'form': form,
})
I will get error by submitting one of two forms.
How can I distinguish the 2 forms submitting in the views ?
Hello,
I have to insert float values into different SQL Servers. Each one can have different locales so in one it the representation could be "42,2" and at another one "42.2" or whatever. How should i construct the query so it works in any SQL Server?
Do i need to detect the locale of the server before constructing the query or what?
Thanks in advance mates.
Hi,
I want to ask if there is a way to insert variable inside another string which is part of another statement. For example:
function SomeFunction(field) {
var someVariable = document.getElementById('<%=' + field + '.ClientID %');
}
But I've got an error:
Error 6 'string' does not contain a definition for 'ClientID'
Thank you.
How is it possible to make a input field editable in javascript. I mean onFocus putting it in insert mode so that values can be overwritten. Any suggestions ???
I have a contenteditable div where I need to insert text at the caret position,
This can be done in IE by document.selection.createRange().text = "banana"
Is there a similar way of implementing this in Firefox/Chrome?
(I know a solution exists here , but it looks sorta clumsy)
Thank you!
What is the best way to insert an image programatically into the RichTextBox control in C# Winforms? If the method is using Clipboard then what is the optimized way to keep the Clipboard original data (i.e. the data state before placing my image on the Clipboard) available to be replaced after my temporary usage of Clipboard for inseting my image in Rich Text Box Control.
Let us say I have a table (everything is very much simplified):
create table OriginalData (
bla char(10) not null
)
And I would like to insert its data (set based!) into two tables which model inheritance
create table Statements (
Id int IDENTITY NOT NULL,
ProposalDateTime DATETIME null
)
create table Items (
StatementFk INT not null,
ItemName NVARCHAR(255) null,
primary key (StatementFk)
)
Statements is the parent table and Items is the child table. I have no problem doing this with one row which involves the use of IDENT_CURRENT but I have no idea how to do this set based (i.e. enter several rows into both tables).
Thanks.
Best wishes,
Christian
Im able to generate tables with all required columns and with datas in excel sheet. now i want to insert image that is present in my bin.how can i achieve this.
thanks in advance
I have two tables with the same column definitions. I need to move (not copy) a row from one table to another. Before I go off and use INSERT INTO/DELETE (in a transaction), is there a smarter way?
SQL Server 2005
I have a PostgreSQL backup made with PHPPgadmin using Export Copy (instead Copy SQL which is actually what I need).
File contains entries like this:
COPY tablename(id, field) FROM stdin;
...
How to convert this file to SQL format?
INSERT INTO tablename...
I want to use Pgadmin to to import this file using execute SQL command.
I want to write a python script that populates a database with some information. One of the columns in my table is a BLOB that I would like to save a file to for each entry.
How can I read the file (binary) and insert it into the DB using python? Likewise, how can I retrieve it and write that file back to some arbitrary location on the hard drive?
If I try this statement:
INSERT INTO TerminalEventChild (id,stringValue) VALUES
(64,'version123|');
MySQL fail with :
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''version123' at line 1
SQLState: 42000
ErrorCode: 1064
If I remove the | character, everything works fine. Any idea?