Inserting SQL query in a DokuWiki page causing to disconnect on save - dokuwiki

When trying to insert a code block into a DokuWiki page I get an error while trying to preview or save. It says the server has disconnected. I have narrowed it down to the '%' in the query. I was wondering why this is happening and what can I do about it. Is there a specific way I should incapsolate the code or a plugin that can help this issue?
<code>
SELECT * FROM schema.table WHERE Allowed in(
SELECT Priv_ID FROM schema.table WHERE priv_name LIKE
'doc%temp_member_%CUA293'
)
</code>

Related

Nxlog im_dbi is not working

I am able to insert data into PostgreSQL using nxlog(om_dbi).
But I am not able to select data(or fetch data) from PostgreSQL using nxlog. I tried many options nothing is working.
And in nxlog document also for IM_DBI module description has only "FIXME" mentioned.
Document Link: http://nxlog.org/documentation/nxlog-community-edition-reference-manual-v20928#im_dbi
Please help me to solve this.
Logs:
<Input dbiin>
Module im_dbi
SavePos TRUE
SQL SELECT * FROM NEW_TABLE
Driver pgsql
Option host 127.0.0.1
Option username chitta
Option password ''
Option dbname db
</Input>
2014-10-16 14:29:17 WARNING nxlog-ce received a termination request signal, exiting...
2014-10-16 14:29:18 INFO nxlog-ce-2.8.1248 started
2014-10-16 14:29:18 ERROR im_dbi failed to execute SQL statement. ERROR: column "id" does not exist;LINE 1: SELECT * FROM NEW_TABLE WHERE id = 1;
Note:
the module will automatically prepends a "WHERE id > %d" clause.
Not an answer, but here's some help.
The most important directive is missing: SQL Select ID as id,
DateOccured as EventTime, data from logtable
Source: https://www.mail-archive.com/nxlog-ce-users#lists.sourceforge.net/msg00225.html
I'm currently in the same boat. My assumption is that your data is not formatted in a way that nxlog can interpret. Troubleshooting and will get back to you if I can find a resolution.
Also digging through the source code for the im_dbi module.
https://github.com/lamby/pkg-nxlog-ce/blob/master/src/modules/input/dbi/im_dbi.c
The answer by SoMuchToGrok is valid.
Actually the question already has this: "ERROR: column "id" does not exist".
The table must have an id column or you must use SELECT x as id so that the result set has id in it

PostgreSql command to see the table data

I am new in PostgreSql. I import the database on my linux machine. I am able to see the list of tables using \d command (GSM_test_db-# \d default_msg_details) its displaying the table list but I want to see the table data.
Any Command that shows table Data also Please tell me.
I already used select query GSM_test_db-# SELECT * FROM default_msg_details but its not displaying anything and its not giving any error.
Please tell me if any command or why this select its not displaying anything.
Because you need to terminate your statement with a ;
Try SELECT * FROM "default_msg_details";
Beside adding ";" at the end of your query, you also need add the quotes("") to your tabel's name as well.
Firstly, you need to disable pagination but retain the output:
\pset pager off
Then, use the below query:
SELECT * FROM "default_msg_details";

Why wont this sql server CE command work?

I have the command:
INSERT INTO tbl_media
(DateAdded) VALUES (GetDate())
SELECT CAST(##Identity AS int)
It works fine against a standard sql db but not against a CE db I get the following error:
SQL Execution Error.
Executed SQL statement...
Error Source: SQL Server Compact ADO.NET Data Provider
Error Message: There was an error parsing the query. [Token line number = 2, Token line offset = 31, Token in error = )]
Shame the error isn't more useful anyone know what could be going on?
Cheers
UPDATE::::::
After much messing around with visual studio editor (rubbish) I downloaded dataport and read the MSDN. It seems there are 2 problems...
1) SELECT CAST(##Identity AS int) is not valid sql
SELECT ##Identity is
2) SqlCe server does not like it when I put these two commands together:
INSERT INTO tbl_media
(DateAdded) VALUES (getdate())
SELECT ##Identity
If I do the insert and select at different times then it works. So how do I get round this? I cant do it at different times I need to know the ID of the objects as I create them!!!
UPDATE 2:
According to the very helpful Erik E you cant do 2 statements at the same time. So the following parses as correct but wont work:
INSERT INTO tbl_media
(DateAdded) VALUES (getdate());
SELECT ##Identity;
So what I really want to know is how do I guarantee that identities wont get mixed up when adding records?
I.e. what if someone creates a record while someone is getting the identity for one they have just inserted?
You have an extra ) I dont know if that will fix your error but look at VALUES you have
VALUES(GETDATE())) '<-- one ) extra.
Change it to this:
INSERT INTO tbl_media(DateAdded)
VALUES (GetDate())
SELECT CAST(##Identity AS int)
You can only run a single SQL statement per ExecuteNonQuery call. So you must spilt in 2 calls.

PostgreSQL and pgadmin3.exe

I am trying to start playing with postgres and found a very strange thing, I created a table using pgadminIII named testtable and added couple of column then I wrote following query in query editor
SELECT * from testtable;
it responded no table found with such name, then after that I tried
select * from "testtable"
with quotes(later one) it worked, then I dropped the table and created the table using script editor, with same name making it sure no quotes are around the name, then both query started working, I can't understand stand what that exactly mean, even if I write "teablename" in create table statement quotes shouldn't become the part of the table name.
Also, how can I make sure while using pgAdmin graphical user interface that all object get created without quote (of course if above problem because of that)?
Update: Environment Info
OS => Windows Server 2008 x64, Postgres => 9.0.3-2 x64, pgAdmin => >
Version 1.12.2 (March 22, 2011, rev:>
REL-1_12_2)
Did you use the new table dialog the first time? You shouldn't use quotes in the dialog as pgAdmin will insert all necessary quotes.
Edit
I discovered something today what is a little weird and might explain what happened to you.
When you do not quote a table name the table name it is converted to lowercase. So if you do
CREATE TABLE TestTable ( ... );
Your table will be called testtable
What happens when you start to query the table is this:
SELECT * FROM TestTable; -- succeeds looks for testtable
SELECT * FROM testtable; -- succeeds
SELECT * FROM "TestTable"; -- fails because case doesn't match
Now if you had done:
CREATE TABLE "TestTable" ( ... );
Your table would actually be called TestTable with the case preserved and the result is
SELECT * FROM TestTable; -- fails looks for testtable
SELECT * FROM testtable; -- fails
SELECT * FROM "TestTable"; -- succeeds

SQL: OPENQUERY Not returning all rows

i have the following which queries a linked server i have to talk to.
SELECT
*
FROM
OPENQUERY(DWH_LINK, 'SELECT * FROM TABLEA ')
It will typically return most of the data but some rows are missing?
The linkeds server is coming from an oracle client
Is this a problem anyone has encountered w/ openquery?
I had exactly the same problem.
The root cause is that you've set up your linked server using ODBC instead of OLE DB.
Here's how I fixed it:
Delete the linked server from SQL Server
Right click on the "Linked Servers" folder and select "New Linked Server..."
Linked Server: enter anything..this will be the name of your new linked server
Provider: Select "Oracle Provider for OLE DB"
Product Name: enter "Oracle" (without the double quotes)
Data Source: enter the alias from your TNSNAMES.ORA file. In my case, it was "ABC.WORLD" (without the double quotes)
Provider String: leave it blank
Location: leave it blank
Catalog: leave it blank
Now go to the "Security" tab, and click the last radio button that says "Be made using this security context:" and enter the username & password for your connection
That should be it!
This seems to be related to the underlying provider capabilities and others have also run into this and similar size/row limitations. One possible work-around would be to implement an iterative/looping query with some filtering built in to pull back a certain amount of rows. With oracle, I think this might be using the rownum (not very familiar with oracle).
So something like
--Not tested sql, just winging it syntax-wise
SELECT * FROM OPENQUERY(DWH_LINK, 'SELECT * FROM TABLEA where rownum between 0 AND 500')
SELECT * FROM OPENQUERY(DWH_LINK, 'SELECT * FROM TABLEA where rownum between 500 AND 1000')
SELECT * FROM OPENQUERY(DWH_LINK, 'SELECT * FROM TABLEA where rownum ...')
BOL:
link
This is subject to the capabilities of the OLE DB provider. Although the query may return multiple result sets, OPENQUERY returns only the first one.
I had this same problem using the Oracle 10 instant client and ODBC. I used this client as I am connecting to an Oracle 10gR2 database. I opened a ticket with Microsoft support and they suggested using the Oracle 11 instant client. Surprise! Uninstalling the 10g instant client, installing the 11g instant client and rebooting resolved the issue.
Ken
I had exact same problem with an SQL 2014 getting data from SQL 2000 through OPENQUERY. Because ODBC compatibility problem, I had to keep generic OLE DB for ODBC driver. Moreover, the problem was only with SQL non-admin account.
So finally, the solution I found was to add SET ROWCOUNT 0:
SELECT * FROM OPENQUERY(DWH_LINK, 'SET ROWCOUNT 0 SELECT * FROM TABLEA ')
It seems the rowcount might been change somewhere through the SQL procedure (or for this user session), so setting it to 0 force it to return "all rows".