Oracledb_session query problem

#1

ok I know this is probably a dumb question, but I'm attempting to do a simple query of the v$database table and it appears it is failing because of the '$' character. I just do not know how to escape this character because the \ does not work. I'm very new to inspec and not sure if it is some issue with how I'm connecting that is causing this issue since the oracledb_session reference does not appear to treat this v$database with any special requirements.

example.rb:
sql = oracledb_session(as_os_user: 'oracle', as_db_role: 'sysdba', service: 'myservice', sqlplus_bin: '/u01/app/oracle/product/12.1.0/dbhome_1/bin/sqlplus')

describe sql.query("SELECT name from v$database;").row(0).column('name') do
its('value') { should cmp 'ORCL' }
end

output:
Could not execute the sql query
SQL*Plus: Release 12.1.0.2.0 Production on Mon Mar 18 18:23:18 2019

Copyright (c) 1982, 2014, Oracle. All rights reserved.

I've read and consent to the terms in IS user agreem't.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning and Unified Auditing options

SQL> SQL>

SQL>

SQL>

SELECT name from v
                 *

ERROR at line 1:


ORA-00942: table or view does not exist

SQL>

Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning and Unified Auditing options

Profile: InSpec Profile (my_nginx)
Version: 0.1.0
Target: local://

File /tmp
:heavy_check_mark: should be directory
SQL Column
× value should cmp == "ORCL"

 expected: "ORCL"
      got: ""

 (compared using `cmp` matcher)

Test Summary: 1 successful, 1 failure, 0 skipped

0 Likes

#3

it would appear that when using oracledb_session with the as_os_user you need to provide 4 backslashes before the $. so v\\\\$database works

0 Likes