Splunk Search

DB Query

rahul2gupta
Path Finder

Hi All,

Can someone advice what is wrong with this  following query.

|dbquery wmsewprd "select * from sys_code_type where rec_type='C'" when I run this ,I get an error.

rahul2gupta_0-1597901305598.png

 

But when I use wmsew.sys_code_type instead of sys_code_type I get the exact output.Can any help me this.Our requirement is to work |dbquery wmsewprd "select * from sys_code_type where rec_type='C'" .

wmsewprd -- External Database.

Regards,

Rahul

0 Karma

richgalloway
SplunkTrust
SplunkTrust

I don't understand why, when you know the syntax that works, you insist on using syntax that does not work.
If you need to use a different name later in your query then you use rename wmsew.* as *.

---
If this reply helps you, Karma would be appreciated.
0 Karma

rahul2gupta
Path Finder

Hi @richgalloway ,

Could you please elaborate more about this: 

If you need to use a different name later in your query then you use rename wmsew.* as *.

Regards,

Rahul

Tags (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

You said this query fails

|dbquery wmsewprd "select * from sys_code_type where rec_type='C'

and this one does not

|dbquery wmsewprd "select * from wmsew.sys_code_type where rec_type='C'

So I presume you wish to refer to the sys_code_type field by that name.  You can do that, but first you must comply with the database's name rules and include the table name in the query.  After that, if necessary, you can use rename to strip out the table name from fields.

|dbquery wmsewprd "select * from wmsew.sys_code_type where rec_type='C'
| rename wmsew.* as *

 

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Aligning Observability Costs with Business Value: Practical Strategies

 Join us for an engaging Tech Talk on Aligning Observability Costs with Business Value: Practical ...

Mastering Data Pipelines: Unlocking Value with Splunk

 In today's AI-driven world, organizations must balance the challenges of managing the explosion of data with ...

Splunk Up Your Game: Why It's Time to Embrace Python 3.9+ and OpenSSL 3.0

Did you know that for Splunk Enterprise 9.4, Python 3.9 is the default interpreter? This shift is not just a ...