Sponsored Content
Full Discussion: Spotting lowercase SQL code
Top Forums Shell Programming and Scripting Spotting lowercase SQL code Post 302610617 by figaro on Wednesday 21st of March 2012 01:16:38 PM
Old 03-21-2012
Spotting lowercase SQL code

We want to check where our programmers are using lowercase SQL reserved words, ie "select" instead of "SELECT".
Obviously, we should not raise a warning for code which is commented out with "//".
Suppose I have this input:
Code:
select * from mytable
SELECT * from mytable
// select * from mytable statement, but as a comment
select * from mytable statement outside the comment //

So the following code does not work, because it does not return the last line:
Code:
grep select myfile.cpp | grep -v "//"

How do I change the expression so that lines with lowercase "select" are returned and which are not preceded by "//"?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sql error code trapping

Hello #!bin/ksh sqlplus -s system/manager < |grep '^ORA' |uniq select * from kk; set echo on show spool on end; / EOF save test.sh sh test.sh results ORA-00942: table or view does not exist (3 Replies)
Discussion started by: xiamin
3 Replies

2. Shell Programming and Scripting

uppercase to lowercase

Greetings & Happy New Years To All! A client of mine FTP'ed their files up to the server and it all ended up being in UPPERCASE when it all should be in lowercase. Is there a builtin command or a script anyone knows of that will automagically convert all files to lowercase? Please advise asap... (4 Replies)
Discussion started by: webex
4 Replies

3. UNIX for Advanced & Expert Users

Return code from PL/SQL Code

Hi Guys, I was just wondering if anybody can help me with this problem. OK, how we can get a value back from PL/SQL Script (not stored procedure/function) See the below example: (for example aaa.sh) #!/bin/ksh VALUE=`sqlplus -s user/password@test_id <<EOF @xxx.sq EOF` echo $VALUE ... (7 Replies)
Discussion started by: Shaz
7 Replies

4. Shell Programming and Scripting

conditional writing of sql code

Hello again... I have a request from another department to list for them all the columns and tables we use in this certain database. I have spooled the oracle stored procedured into 1 file. I need a way to write out parts of that file. The criteria is to to start the block to be written when... (0 Replies)
Discussion started by: kburrows
0 Replies

5. Shell Programming and Scripting

SQL code into a variable.

Hi, Iam new to unix. Is there any way to get the sql code "ORA-01847" into a variable. sqlplus username/password@database name << EOF set heading off update TempTable set variable where condition; exit sql.sqlcode; commit; exit; EOF Output ERROR at line 1: ORA-01847: day of... (1 Reply)
Discussion started by: manneni prakash
1 Replies

6. Shell Programming and Scripting

html code in SQL query

Hi expert, I have a script which is connecting with sql internally, fetch same data, store it in a file and then from os I cat this file and sending it to mail (windows outlook). This is working fine, I just need to know wether we can add some html codes with the sql query like we can add... (0 Replies)
Discussion started by: mcagaurav
0 Replies

7. Shell Programming and Scripting

How to get the SQL CODE from a file?

Hi Guys :) need your help once again I have some files from which I have to fetch the SQL CODE which in anywhere in file. please help me input files : file1 : ERROR ON SECTION : 2060-GET-OTHER-DEP-INFO ERR MSG : ERROR IN FETCH MCURS SQL CD : 100 SUBS ID : 153687143 input... (5 Replies)
Discussion started by: atul9806
5 Replies

8. Shell Programming and Scripting

Uppercase to lowercase

Hello, I have a list of files in a directory whose names are all in uppercasse, including the file format for eg *.MP3 . I would like to convert these to the normal way we write it ie ABC.MP3 to be converted to Abc.mp3 . I know that this can be done manually by using a lot of "mv" or rename... (6 Replies)
Discussion started by: ajayram
6 Replies

9. Shell Programming and Scripting

Code needed to get sql queries

Hi i need code to get sql queries through a shell script for a text file input which contain the service ids iputfile I-H-2048-10GB-M I-H-4096-12GB-M I-H-2048-p1000-M the code should contain below queries among which service_id is replacable with value from input file. ... (4 Replies)
Discussion started by: surender reddy
4 Replies

10. What is on Your Mind?

Spotting Aggressive Clandestine BotNets

Spotting Aggressive Clandestine BotNets "Yesterday was making a typical “evening run” in cyberspace and noticed a strange pattern, zoomed in, and found a aggressive clandestine “indexing” botnet operating out of a dedicated hosting provider’s datacenter. The feature image in this post shows a... (0 Replies)
Discussion started by: Neo
0 Replies
SELECT 
INTO(7) SQL Commands SELECT INTO(7) NAME
SELECT INTO - define a new table from the results of a query SYNOPSIS
[ WITH [ RECURSIVE ] with_query [, ...] ] SELECT [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ] * | expression [ [ AS ] output_name ] [, ...] INTO [ TEMPORARY | TEMP ] [ TABLE ] new_table [ FROM from_item [, ...] ] [ WHERE condition ] [ GROUP BY expression [, ...] ] [ HAVING condition [, ...] ] [ WINDOW window_name AS ( window_definition ) [, ...] ] [ { UNION | INTERSECT | EXCEPT } [ ALL ] select ] [ ORDER BY expression [ ASC | DESC | USING operator ] [ NULLS { FIRST | LAST } ] [, ...] ] [ LIMIT { count | ALL } ] [ OFFSET start [ ROW | ROWS ] ] [ FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } ONLY ] [ FOR { UPDATE | SHARE } [ OF table_name [, ...] ] [ NOWAIT ] [...] ] DESCRIPTION
SELECT INTO creates a new table and fills it with data computed by a query. The data is not returned to the client, as it is with a normal SELECT. The new table's columns have the names and data types associated with the output columns of the SELECT. PARAMETERS
TEMPORARY or TEMP If specified, the table is created as a temporary table. Refer to CREATE TABLE [create_table(7)] for details. new_table The name (optionally schema-qualified) of the table to be created. All other parameters are described in detail under SELECT [select(7)]. NOTES
CREATE TABLE AS [create_table_as(7)] is functionally similar to SELECT INTO. CREATE TABLE AS is the recommended syntax, since this form of SELECT INTO is not available in ECPG or PL/pgSQL, because they interpret the INTO clause differently. Furthermore, CREATE TABLE AS offers a superset of the functionality provided by SELECT INTO. Prior to PostgreSQL 8.1, the table created by SELECT INTO included OIDs by default. In PostgreSQL 8.1, this is not the case -- to include OIDs in the new table, the default_with_oids configuration variable must be enabled. Alternatively, CREATE TABLE AS can be used with the WITH OIDS clause. EXAMPLES
Create a new table films_recent consisting of only recent entries from the table films: SELECT * INTO films_recent FROM films WHERE date_prod >= '2002-01-01'; COMPATIBILITY
The SQL standard uses SELECT INTO to represent selecting values into scalar variables of a host program, rather than creating a new table. This indeed is the usage found in ECPG (see in the documentation) and PL/pgSQL (see in the documentation). The PostgreSQL usage of SELECT INTO to represent table creation is historical. It is best to use CREATE TABLE AS for this purpose in new code. SEE ALSO
CREATE TABLE AS [create_table_as(7)] SQL - Language Statements 2010-05-14 SELECT INTO(7)
All times are GMT -4. The time now is 01:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy