BookmarkSubscribeRSS Feed
NDS
Calcite | Level 5 NDS
Calcite | Level 5

Hi,

I am trying to access a SQLite database using pipes as follows:

filename QUERY pipe 'sqlite3 home/data/MyDB.db3 "select field1 from table1"';
  options linesize = max;

    data mySet;
      infile QUERY delimiter = '|' missover dsd lrecl = 32767;
      input
         field1
      ;         
    run;

I have simplified the query, but the original runs fine from SQLite studio.

However when I run this, I get a single row in my data table with SQL ERROR in it.

If anyone can shed any light on this I'd appreciate it.

Many thanks

Nick

3 REPLIES 3
jwsquillace
SAS Employee

Run your command in a bare DOS window instead of the IDE.

If it runs in the DOS window, we'll need to investiage PIPE further.

NDS
Calcite | Level 5 NDS
Calcite | Level 5

Hi,

Sorry - took some time to get back to this. I have tried what you suggested and I have a couple of issues:

1. A simple SQL command runs fine from the prompt (i.e. Select * from MYTABLE) - and the same simple query runs fine from in SAS using pipes.

2. When I try to select from a view (from the prompt or SAS) I get an error that the column name can't be found (i.e. Select * from [myView]) this squery works fine in the IDE

It must be interpreting the query that defines the view correctly as it is looking for the right column.

Is there some issue selecting from views using sqlite3?

One possible issue is that the original .db3 file was created in a windows environment and I have copied it over to a unix environment. I tried dos2unix but that seemed to corrupt the file....

Any ideas?


LinusH
Tourmaline | Level 20

Since it seems it's not SAS that is the issue, you might find answers in a different forum. The average SAS user have no experience with SQLite...;-)

Data never sleeps

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1901 views
  • 0 likes
  • 3 in conversation