[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3836
  • Last Modified:

Help with SQL pseudo-code

Hi,
  Could someone help me put basic SQL pseudo code to perform the following steps?  Can be general. I just need to get the syntax and functional logic in place then I can finish the specifics later.
Thanks in Advance...

- Put counts in temp table
      - 1 for bulk
      - 1 for others
- Verify temp table counts against imported counts
- If not bulk
      - export to mm table
      - Run mm job to import from sql to mm
      - Loop thru temp table for each PP
            - Edit mm job
            - Run mm job
      - Run mm job to export from mm to sql
- If not bulk update IMB for all but pp8
-      Insert records from mm table to live table
            - 1 for bulk
            - 1 for others
- Update live table
            - 1 for bulk
            - 1 for others
- If not bulk create signoff table
0
tesla764
Asked:
tesla764
  • 3
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
as many of the "terms" are not clear to what they refer to, it's unlikely to get anything "good" without just guessing.

for example Put counts in temp table
      - 1 for bulk ...

what does " 1 for bulk " refer to?  I could guess 1 table named "bulk" ...

- Verify temp table counts against imported counts is not clear on what "imported counts" is meaning ? other table? ...

and so on and so forth...
0
 
tesla764Author Commented:
All I am trying to see is, for example, what would the SQL code look like to perform...

Put counts in temp table
      - 1 for bulk
      - 1 for others
- Verify temp table counts against imported counts

SQL code to create two temp tables - 1 temp table named bulk and a second named others.
SQL code to verify the temp table counts against counts that are imported, and so on. I need SQL code examples to perform everyone of the listed steps. I will do the fine tuning for our system once I can see how these steps can be coded correctly, including syntax.
Thanks.
0
 
tesla764Author Commented:
May be I should break this down into smaller individual functions.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
yes, good idea, to check out each individual sql syntax.

I mean, when you refer to "count", the number of rows of a table would be:
SELECT COUNT(*) FROM yourtable

however, if you want the count of distinct values, or counts as per some "value", the syntax will differ...
to insert that into a temp table INSERT INTO sometable SELECT ...


then: compare with ... in t-sql, you don't just "compare", but you do something ...
for example, if you have 2 rows (same table or different tables is just a matter of syntax...), and you want to "do something" if you have at least 1 "mismatch"
DECLARE @c INT
SELECT @c = COUNT(*) FROM table1 JOIN table2 ON ... WHERE table1.somefield <> table2.somefield
if @c <> 0
begin
   -- do something here
end 

Open in new window


or update some table from those temp tables:
http://www.experts-exchange.com/Database/Miscellaneous/A_1517-UPDATES-with-JOIN-for-everybody.html

reading the high-level description, you actually might want to run a MERGE statement, and not all that complex code:
http://msdn.microsoft.com/de-de/library/bb510625.aspx
0
 
tesla764Author Commented:
Thanks for your help.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now