Sponsored Content
Top Forums Programming Need sql query to string split and normalize data Post 302997317 by calredd on Thursday 11th of May 2017 08:42:12 AM
Old 05-11-2017
Quote:
Originally Posted by vgersh99
as a workaround for post-processing:
Code:
awk 'FNR==1{print;next}{n=split($2,a,",");for(i=1;i<=n;i++) if(a[i]) print $1,a[i]}' mySQLextactedFile

Thanks but need the solution in sql query. Its easy to implement using sed/awk.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How do I use SQL to query based off file data?

This is basically what I want to do: I have a file that contains single lines of IDs. I want to query the oracle database using these IDs to get a count of which ones match a certain condition. the basic idea is: cat myfile | while read id do $id in select count(PC.ptcpnt_id) from... (4 Replies)
Discussion started by: whoknows
4 Replies

2. Shell Programming and Scripting

how to use data in unix text file as input to an sql query from shell

Hi, I have data in my text file something like this. adams robert ahmed gibbs I want to use this data line by line as input to an sql query which i run by connecting to an oracle database from shell. If you have code for similar scenario , please ehlp. I want the output of the sql query... (7 Replies)
Discussion started by: rdhanek
7 Replies

3. Shell Programming and Scripting

How to use sql data file in unix csv file as input to an sql query from shell

Hi , I used the below script to get the sql data into csv file using unix scripting. I m getting the output into an output file but the output file is not displayed in a separe columns . #!/bin/ksh export FILE_PATH=/maav/home/xyz/abc/ rm $FILE_PATH/sample.csv sqlplus -s... (2 Replies)
Discussion started by: Nareshp
2 Replies

4. UNIX for Dummies Questions & Answers

Normalize Data and write to a flat file

All, Can anyone please help me with the below scenario. I have a Flat file of the below format. ID|Name|Level|Type|Zip|MAD|Risk|Band|Salesl|Dealer|CID|AType|CValue|LV|HV|DCode|TR|DU|NStartDate|UserRole|WFlag|EOption|PName|NActivationDate|Os|Orig|Cus|OType|ORequired|DType 03|... (10 Replies)
Discussion started by: sp999
10 Replies

5. Shell Programming and Scripting

Run SQL thru shell script: how to get a new line when run sql query?

Hi, this's Pom. I'm quite a new one for shell script but I have to do sql on shell script to query some information from database. I found a concern to get a new line...When I run my script, it retrieves all data as wondering but it's shown in one line :( What should I do? I'm not sure that... (2 Replies)
Discussion started by: Kapom
2 Replies

6. Shell Programming and Scripting

How to pass string into sql query?

Hi Gurus, I have a request which needs to pass string into sql. dummy code as below: sqlplus -s user/password@instance << EOF >>output.txt set echo off head off feed off pagesize 0 trimspool on linesize 1000 colsep , select emp_no, emp_name from emp where emp_no in ('a', 'b', 'c'); exit;... (4 Replies)
Discussion started by: ken6503
4 Replies

7. Shell Programming and Scripting

Shell scripting unable to send the sql query data in table in body of email

I have written a shell script that calls below sql file. It is not sending the query data in table in the body of email. spool table_update.html; SELECT * FROM PROCESS_LOG_STATS where process = 'ActivateSubscription'; spool off; exit; Please use code tags next time for your code and data.... (9 Replies)
Discussion started by: Sharanakumar
9 Replies

8. Web Development

Iplanet webserver retaining the URI query string data.

Current Situation: 1. Visit: https://xyz.com/2015/september?trackingparam=1234 2. The URL is missing the trailing / after the “september” directory 3. The URL is redirected and rewritten to: https://xyz.com/2015/september/ , dropping the query string data. Note:... (0 Replies)
Discussion started by: raghur77
0 Replies

9. Shell Programming and Scripting

Run sql query in shell script and output data save as delimited text

I want to run sql query in shell script and output data save as delimited text (delimited text would be comma) Code: SPOOL_FILE=/pgedw/dan.txt SQL=/pgedw/dan.sql sqlplus -s username/password@myhost:port/servicename <<EOF set head on set COLSEP , set linesize 32767 SET TRIMSPOOL ON SET... (8 Replies)
Discussion started by: Jaganjag
8 Replies

10. UNIX for Beginners Questions & Answers

Awk: split and gensub query

Hi All, Thanks for answering my previous question. Could you please explain the highlighted code? awk -v pos='9 27 39 54 59 64 71 78 83 103 108' 'BEGIN{split(pos,var)} {for (i in var) $0=gensub(/./,"|",var)} 1' test.txt | head I understood that the split function splits the pos string into... (2 Replies)
Discussion started by: mrcool4
2 Replies
Alzabo::SQLMaker(3pm)					User Contributed Perl Documentation				     Alzabo::SQLMaker(3pm)

NAME
Alzabo::SQLMaker - Alzabo base class for RDBMS drivers SYNOPSIS
use Alzabo::SQLMaker::MySQL; my $sql = Alzabo::SQLMaker::MySQL->new( driver => $driver_object ); # or better yet my $sql = $runtime_schema->sqlmaker; DESCRIPTION
This is the base class for all Alzabo::SQLMaker modules. To instantiate a driver call this class's "new" method. See "SUBCLASSING Alz- abo::SQLMaker" for information on how to make a driver for the RDBMS of your choice. METHODS
available Returns A list of names representing the available "Alzabo::SQLMaker" subclasses. Any one of these names would be appropriate as a parame- ter for the "Alzabo::SQLMaker->load()" method. load Load the specified subclass. This takes one parameter, the name of the RDBMS being used. Throws: "Alzabo::Exception::Eval" new This takes two parameters: * driver The driver object being used by the schema. * quote_identifiers A boolean value indicating whether or not identifiers should be quoted. This defaults to false. GENERATING SQL
This class can be used to generate SQL by calling methods that are the same as those used in SQL ("select()", "update()", etc.) in sequence, with the appropriate parameters. There are four entry point methods, "select()", "insert()", "update()", and "delete()". Attempting to call any other method without first calling one of these is an error. Entry Points These methods are called as class methods and return a new object. select ("Alzabo::Table" and/or "Alzabo::Column" objects) This begins a select. The columns to be selected are the column(s) passed in, and/or the columns of the table(s) passed in as arguments. Followed by: "from()" "** function" insert Followed by: "into()" update ("Alzabo::Table") Followed by: "set()" delete Followed by: "from()" Other Methods All of these methods return the object itself, making it possible to chain together method calls such as: Alzabo::SQLMaker->select($column)->from($table)->where($other_column, '>', 2); from ("Alzabo::Table" object, ...) The table(s) from which we are selecting data. Follows: "select()" "** function" "delete()" Followed by: "where()""> "order_by()" Throws: "Alzabo::Exception::SQL" where <see below> The first parameter to where must be an "Alzabo::Column" object or SQL function. The second is a comparison operator of some sort, given as a string. The third argument can be an "Alzabo::Column" object, a value (a number or string), or an "Alzabo::SQLMaker" object. The latter is treated as a subselect. Values given as parameters will be properly quoted and escaped. Some comparison operators allow additional parameters. The "BETWEEN" comparison operator requires a fourth argument. This must be either an "Alzabo::Column" object or a value. The "IN" and <NOT IN> operators allow any number of additional parameters, which may be "Alzabo::Column" objects, values, or "Alzabo::SQL- Maker" objects. Follows: "from()" Followed by: "and()" "or()" "order_by()" Throws: "Alzabo::Exception::SQL" and (same as "where") or (same as "where") These methods take the same parameters as the "where()""> method. Follows: "where()""> "and()" "or()" Followed by: "and()" "or()" "order_by()" Throws: "Alzabo::Exception::SQL" order_by ("Alzabo::Column" objects) Adds an "ORDER BY" clause to your SQL. Follows: "from()" "where()""> "and()" "or()" Followed by: "limit()" Throws: "Alzabo::Exception::SQL" limit ($max, optional $offset) Specifies a limit on the number of rows to be returned. The offset parameter is optional. Follows: "from()" "where()""> "and()" "or()" "order_by()" "Alzabo::Exception::SQL" into ("Alzabo::Table" object, optional "Alzabo::Column" objects) Used to specify what table an insert is into. If column objects are given then it is expected that values will only be given for that object. Otherwise, it assumed that all columns will be specified in the "values()" method. Follows: "insert()" Followed by: "values()" Throws: "Alzabo::Exception::SQL" values ("Alzabo::Column" object => $value, ...) This method expects to recive an structured like a hash where the keys are "Alzabo::Column" objects and the values are the value to be inserted into that column. Follows: "into()" Throws: "Alzabo::Exception::SQL" set ("Alzabo::Column" object => $value, ...) This method'a parameter are exactly like those given to the "values" method. Follows: "update()" Followed by: "where()""> Throws: "Alzabo::Exception::SQL" RETRIEVING SQL FROM THE OBJECT
sql This method can be called at any time, though obviously it will not return valid SQL unless called at a natural end point. In the future, an exception may be thrown if called when the SQL is not in a valid state. Returns the SQL generated so far as a string. bind Returns an array reference containing the parameters to be bound to the SQL statement. SUBCLASSING Alzabo::SQLMaker To create a subclass of "Alzabo::SQLMaker" for your particular RDBMS requires only that the virtual methods listed below be implemented. In addition, you may choose to override any of the other methods described in this documentation. For example, the MySQL subclass override the "_subselect()" method because MySQL cannot support sub-selects. Subclasses are also expected to offer for export various sets of functions matching SQL functions. See the "Alzabo::SQLMaker::MySQL" sub- class implementation for details. VIRTUAL METHODS
The following methods must be implemented by the subclass: limit See above for the definition of this method. get_limit This method may return "undef" even if the "limit()" method was called. Some RDBMS's have special SQL syntax for "LIMIT" clauses. For those that don't support this, the "Alzabo::Driver" module takes a "limit" parameter. The return value of this method can be passed in as that parameter. If the RDBMS does not support "LIMIT" clauses, the return value is an array reference containing two values, the maximum number of rows allowed and the row offset (the first row that should be used). If the RDBMS does support "LIMIT" clauses, then the return value is "undef". sqlmaker_id Returns the subclass's name. This should be something that can be passed to "Alzabo::SQLMaker->load()" as a parameter. AUTHOR
Dave Rolsky, <dave@urth.org> perl v5.8.8 2007-12-23 Alzabo::SQLMaker(3pm)
All times are GMT -4. The time now is 02:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy