LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-30-2023, 07:02 PM   #1
psaradha86
LQ Newbie
 
Registered: Aug 2023
Posts: 3

Rep: Reputation: 0
PostgreSQL ISQL (unixodbc) create/drop table error


While using ISQL in linux for POSTGRES, I am able to make a connection to the database and execute select/update/insert/delete statements on tables.

But I am unable to execute create/drop/grant statements. I am getting error as below,

1.CREATE

SQL> create table shop (item1 integer);
[S1000]ERROR: syntax error at or near "create" at character 29;
Error while executing the query
[ISQL]ERROR: Could not SQLExecute
SQL> create table shop (item1 int);
[S1000]ERROR: syntax error at or near "create" at character 29;
Error while executing the query
[ISQL]ERROR: Could not SQLExecute
2.DROP

SQL> drop table persons2;
[S1000]ERROR: syntax error at or near "drop" at character 29;
Error while executing the query
[ISQL]ERROR: Could not SQLExecute
3.SELECT

SQL> select * from persons2;

| personid | pname
+------------+----------------------------------------------------------
------------+
| 1 | test1
| 2 | test2
| 3 | test3
| 4 | test4
SQLRowCount returns 4
4 rows fetched
Grant does not work as well. Is this a permission issue? Please find my permissions below

SQL> SELECT rolname, rolsuper, rolcreaterole FROM pg_roles WHERE rolname
= 'me';
+-----------+---------+--------------+
| rolname | rolsuper| rolcreaterole|
+-----------+---------+--------------+
| me | 1 | 0 |
+-----------+---------+--------------+
Also I am unable to find any documents for ISQL to check how to find the roles, permissions of a user etc.

I am able to execute all the above statements using PSQL in linux though.

psqltest=# create table shop(item1 int);

CREATE TABLE
 
Old 08-30-2023, 10:39 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,872
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
Does it work with the native tool `psql`?
https://www.postgresql.org/docs/current/app-psql.html

Edit: now I see it does work. What's the point in using a middleware?

Last edited by NevemTeve; 08-30-2023 at 10:44 PM.
 
Old 08-30-2023, 11:30 PM   #3
psaradha86
LQ Newbie
 
Registered: Aug 2023
Posts: 3

Original Poster
Rep: Reputation: 0
I am using RM/COBOL InstantSql to access postgreSql. InstantSQL is an interface that allows access to ODBC drivers using a COBOL-like set of statements
 
Old 08-31-2023, 01:00 AM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,872
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
> I am using RM/COBOL InstantSql to access postgreSql.

In the first post you used isql from unixODBC. Maybe they aren't the same. Anyways, I tried unixODBC-2.3.7 with Oracle-10.2 on Aix, it sort of worked:
Code:
$ isql user pwd dsn
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> create table foobar (col1 varchar2(64));
SQLRowCount returns -1
SQL> insert into foobar values ('Val1');
SQLRowCount returns 1
SQL> select * from foobar;
+-----------------------------------------------------------------+
| COL1                                                            |
+-----------------------------------------------------------------+
| Val1                                                            |
+-----------------------------------------------------------------+
SQLRowCount returns -1
1 rows fetched
SQL> drop table foobar;
SQLRowCount returns -1
Mind you, `commit` didn't work.
 
Old 09-12-2023, 07:52 PM   #5
psaradha86
LQ Newbie
 
Registered: Aug 2023
Posts: 3

Original Poster
Rep: Reputation: 0
The issue occured when I connect to isql using my userid and password.
$isql dbname userid (with password it does not let me connect at all thought it is the correct password)
SQL> create table test4 (id int);
[ISQL]ERROR: Could not SQLExecute
SQL> quit


But when I connect to just with the dbname I could create table,
$ isql dbname
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> create table test4 (id int);
SQLRowCount returns 0
 
Old 09-13-2023, 12:35 AM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,363

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
If you are using isql, maybe this page will help https://manpages.ubuntu.com/manpages...n1/isql.1.html. ?

It sounds to me as if you haven't setup the ini file correctly/at all.
It may also be that your 'username' hasn't been given enough rights to create etc.
Ask your DBA.
 
Old 09-13-2023, 02:01 AM   #7
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,872
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
@OP please clearly state what platform(s) and software(s) are you using, e.g.:

"I am using Power64 platform, IBM AIX 6.1 OS, Oracle Instant Client 12.1.0.2.0, client program is sqlplus."


Also please explain why you want to use isql instead of the native command line tool.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
isql -v NetSuite produces just the error of [ISQL]ERROR: Could not SQLConnect subra Linux - Server 5 04-17-2019 12:33 AM
[SOLVED] Postgres 9.4 + unixODBC on Centos 6.5 problem connecting localhost postgres instance with ODBC isql rylan76 Linux - Server 1 07-22-2015 05:39 AM
unixODBC - isql cant open lib Mon5tar Linux - Server 3 07-30-2014 06:34 AM
Error with Isql / unixODBC / MySQL freddylocks Red Hat 0 07-02-2006 11:06 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration