SQL*Plus: how to query using strings - sqlplus

I'm trying to execute the next command in SQL*Plus:
DELETE FROM SOLUTION WHERE NAME LIKE 'Autotest %';
It doesn't anything. I guess the problem is in the apostrophe characters but the next query works:
SELECT ID FROM SOLUTION WHERE NAME LIKE 'Autotest %';
So I have no idea of what's happening.

Did you close your connection and commit the changes in SQL Developer? Consider using = instead of LIKE for queries.

When I execute the command it gets stuck and the only thing I can do is cancel the operation with Ctrl + C
This clearly indicates that your session is blocked. You could check it using:
SELECT *
FROM v$session s
WHERE blocking_session IS NOT NULL;
After DELETE you should commit transaction(first check your setting show autocommit). More SET AUTOCOMMIT

Related

Issue in pexpect when text wraps within session

I am working on a pexpect script that is running populating an output file name and then a prompt for the file's parameters.
The program that the script runs asks for Device: then Parameters: always on the same line.... so if the file path-name that is entered for Device is long, sometimes the Parameters prompt wraps to the next line.
My code looks like..
child.expect_exact('Device:')
child.sendline('/umcfiles/ftp_dir/ftp_peoplesoft/discount/AES_DISCOUNT_15010.TXT')
child.expect_exact('Parameters:')
This times out.. and here is what is in child.before
' /umcfiles/ftp_dir/ftp_peoplesoft/discount/AES_DISCOUNT_15010.TXT Param\r\neters: "RWSN" => '
so the expect fails... (a child.expect('Parameters:') also fails)
How can I ignore the \r\n if it is there, because depending on the length of the path/filename I am using it may not be there at all, or be in a different position.
Thanks!
Actually... I found a way to calculate how much is left on the given line, and dynamically set my expect to how much of the Parameter prompt should be visible... seems to be working
#look for end of line and fix how much of 'Parameters:' we look for in pexpect
dlen = 80-len('Device: /umcfiles/ftp_dir/ftp_peoplesoft/discount/AES_DISCOUNT_15010.TXT')
pstr='Parameters:'
if dlen > len(pstr):
dlen=len(pstr)
else:
dlen=dlen-3 #remove the /r/n
child.expect(pstr[0:dlen])

Informix select first 250000 then the last 250000 records in a table

I work on a CFML script to backup some data in a CSV file from Informix database. The problem is the table has many records 286906 and my scripts timeouts (even I set it not to), the best I could successfully was 260000 with:
SELECT FIRST 260000
APE1, APE2, CALLE, CODPOSTAL, DNI, FCADU, FENACI, LOCALIDAD, NOMBRE, NSS, PROV, TELEFONO
FROM
mytable WHERE FCADU IS NOT NULL AND FENACI IS NOT NULL
is there any way to select the rest of 260000 and then the rest?
I tried with:
SELECT SKIP 260000 FIRST 520000
APE1, APE2, CALLE, CODPOSTAL, DNI, FCADU, FENACI, LOCALIDAD, NOMBRE, NSS, PROV, TELEFONO
FROM
mytable WHERE FCADU IS NOT NULL AND FENACI IS NOT NULL
but I get Error Executing Database Query. A syntax error has occurred.
You can use the Unload statement for creating a file from database:
UNLOAD TO 'mytable.txt' SELECT * FROM mytable;
Maybe that this not works in CFML environment. So you can create a stored procedure which unloads your data.
See unload statement in stored procedure
Is it your script timing out or your database connection? From your question it sou ds to me like its not the coldfusion template that is timing out but the cfquery connection to the database. There is a timeout attribute for the cfquery tag. However apparently it is not reliable a better option is to configure the timout in the advanced section of the datasource within the coldfusion administrator.
Charlie Arehart blogged about this feature here:
http://www.carehart.org/blog/client/index.cfm/2010/7/14/hidden_gem_in_cf9_admin_querytimeout

Is it possible to forge post or get request inside casper,run

I have created a webscraping script in casperJs.
What I want is I need to insert the result which i get from the scraping in sql server database.
I am planning to do it by posting the result on server where it inserts in db.
I have tried the below code to test if it can be done inside casper.run
casper.run(function () {
var finalResult = this.evaluate(somefunction, Obj);
this.open('http://www.testserver.com/post.php?q=test').then(function() {
this.echo('GOT it.');
});
It doesnot make the request nor does it echo GOT It.
I am not sure if this is a neat way to do it. I would rather suggest using SpookyJS and SQL server library for NodeJS.
It can be achieved by 2 ways as below:
1) By using the this.open outside .run
2) By running the casper via php script and insert the results in db from there.

What is the correct syntax to use when trying to create a Data Source View to a linked server?

I have tried several statements but this one at least returns data.. but I get the error message: Deferred prepare could not be prepared. Incorrect syntax near')'. Incorrect syntax near the keyword 'DECLARE'. The following statement executed when creating namedquery:
SELECT[vwStatistics].*
FROM
(
***THIS IS MY QUERY***
DECLARE #SQL1 VARCHAR(500)
SET #SQL1 = 'SELECT *
FROM OPENQUERY(PORTAL, ''SELECT DeviceID, Date, Count
FROM printer_stats.Statistics
GROUP BY DeviceID'')'
EXEC (#SQL1)
***END OF MY QUERY***
)
AS[vwStatistics] (Microsoft.AnalysisServices.Controls)
I am new to linked servers and to SSAS. This is our company's first Cube from a linked server. My query does run in Management Studio and creates a SSRS report but it is slow.
Any suggestions would be helpful. Not much info on syntax for this situation on web. I have been looking for any such situation and have not found much help other than trying changes on server. EX: Make sure openrowset is on and reinstall OWC component.. I do not have that capability.
This is what we found to work:
SELECT DeviceID, CAST(statsdt AS CHAR) AS sdt, Count FROM OPENQUERY (
PORTAL, 'select * from (select DeviceID,CAST( Date AS CHAR) statsdt, Count from printer_stats.Statistics) as pstats')

Help with Nagios check_postgres.pl custom query

I have a postgres function that returns two columns
result, data
(int), (text)
If I run this command from postgres it returns the proper values and if I run it from the linux command line like this:
/usr/local/nagios/libexec/check_postgres.pl -H $HOSTADDRESS$ -u postgres -db monitordb --action=custom_query --critical=1 --query="SELECT * from ops_get_status();"
It also return the proper values - at least it seems to and I don't get any errors.
But when I insert it in the commands.cfg and watch this through the Nagios frontend
it return (null).
The log file doesn't contain any detailed information for debugging this. So, what can I do to get to the bottom of this issue - any help greatly appreciated
result
I just had this same problem. Removing the semi-colon from the end of the query got it working.
Mail archives reference here:
https://mail.endcrypt.com/pipermail/check_postgres/2011-February/000726.html
Shot in the dark, but try enclosing the query in single quotes. The * might be somehow getting expanded.
A bit late, but I also got a similar error with a custom query, but it turns out you need to return a column called 'result' and it must be an integer.
For example:
check_postgres.pl --action=connection --db=db-name --host=x.x.x.x --dbuser=db-user --action=custom_query --critical=10 --warning=5 --query="SELECT count(id) as result from your-table"

Resources